#!/bin/bash
# Signed 16 bit Little Endian, Rate 22050 Hz, Mono
#
# use "play" command to play back audio

if [ -z "$1" ]; then
  for INFILE in *.raw; do
    OUTFILE="`basename \"$INFILE\" .raw`.wav"
    echo "converting $INFILE to $OUTFILE"
    #sox -r 44100 -e unsigned -b 8 -c 1 <RAW_FILE> <TARGET_FILE>
    sox -r 22050 -e signed -b 16 -L -c 1 "$INFILE" "$OUTFILE"
  done
else
  INFILE="$1"
  OUTFILE="`basename \"$INFILE\" .raw`.wav"
  echo "converting $INFILE to $OUTFILE"
  #sox -r 44100 -e unsigned -b 8 -c 1 <RAW_FILE> <TARGET_FILE>
  sox -r 22050 -e signed -b 16 -L -c 1 "$INFILE" "$OUTFILE"
fi
