#!/bin/sh
# vim: set et sw=3 ft=sh:

set -e

if [ -z "$1" -o -z "$2" -o -z "$3" ]
then
   echo "ast2somix.sh expects three arguments" 1>&2
   exit 1
fi

ast_format=$4

case "$ast_format" in
   "ulaw")
   sox_format="ul"
   ;;
   "alaw")
   sox_format="al"
   ;;
esac

if [ -z "$sox_format" -o -z "$ast_format" ]
then
   nice -n 19 soxmix $1 $2 $3 && rm -f $1 $2 &
else
   nice -n 19 soxmix -t $sox_format $1 -t $sox_format $2 -t $sox_format $3 && rm -f $1 $2 &
fi

