# !/bin/sh

set -e

echo target sampling rate is $1
echo input file is $2
echo output file is $3

ftmp=`mktemp`
mv "${ftmp}" "${ftmp}".wav

echo first decoding mp3...
madplay --output=wave:"${ftmp}".wav "${2}"
echo now converting into raw and resampling
sox "${ftmp}".wav -r "${1}" -t raw -u -b -c 1 "${3}"
rm -f "${ftmp}".wav
echo done.
