#!/bin/csh -f

#     soundtrack.csh v.1.10
#               by
# L. Padilla (e-mail: padilla at domain "gae ucm es")
#  Madrid, January 2003 - June 2012
#
# Latest version at http://www.gae.ucm.es/~padilla/extrawork/soundtrack.csh


echo ""

if (-x /usr/bin/aumix) then

  if (-f ~/.aumixrc && ! -f ~/.aumixrc.stmp) mv -f ~/.aumixrc ~/.aumixrc.stmp

  /usr/bin/aumix -d /dev/mixer -S
  /usr/bin/aumix -d /dev/mixer -m 100 -m R
  /usr/bin/aumix -d /dev/mixer -i 100
  /usr/bin/aumix -d /dev/mixer -r 100

else

  echo "aumix not found, use your favorite mixer to"
  echo "set mic and rec channels to maximum level."
  echo ""

endif

echo "" > /tmp/soundtrack.tmp

while ("`cat /tmp/soundtrack.tmp`" != "x")

  sox -q -c 1 -s -w -r 48000 -t ossdsp /dev/dsp -t dat - | tr -d '\r' | grep -v Channels | soundtrack $*

  echo "Press x[enter] to exit or just [enter] to swipe again."

  head -c 1 > /tmp/soundtrack.tmp

end

rm -f /tmp/soundtrack.tmp

if (-x /usr/bin/aumix) then

  /usr/bin/aumix -d /dev/mixer -L > /dev/null

  if (-f ~/.aumixrc.stmp) then

    mv -f ~/.aumixrc.stmp ~/.aumixrc

  else

    rm -f ~/.aumixrc

  endif

else

  echo ""
  echo "aumix not found, use your favorite mixer to"
  echo "set mic and rec channels to minimum level."

endif

echo ""

exit
