#!/bin/sh

_args='--codec riff_wave';

while [ -n "$1" ]
do
 k="$1";
 shift;

 case "$k" in
  '--')
   break;
  ;;
  '-h'|'--help')
   cat <<__AST2ROAR__END_OF_HELP_TEXT__
roarcat (libroar)
=========================================================================
Usage: rsdplay.r [ -h/--help | --raw | -r/--rate | -c/--channels | -B/--bits | -f/--file | -s/--server ]

rsdplay.r reads PCM data only through stdin (default) or a file, and sends this data directly to an rsound server.
Unless specified with --raw, rsdplay expects a valid WAV header to be present in the input stream.

 Examples:
        rsdplay.r -s foo.net < bar.wav
        cat bar.wav | rsdplay -s foo.net -p 4322 --raw -r 48000 -c 2

--raw: Enables raw PCM input. When using --raw, rsdplay will generate a fake WAV header
-r/--rate: Defines input samplerate (raw PCM)
        Example: -r 48000. Defaults to 44100
-c/--channel: Specifies number of sound channels (raw PCM)
        Example: -c 1. Defaults to stereo (2)
-B: Specifies sample format in raw PCM stream
        Supported formats are: S16LE, S16BE, U16LE, U16BE, S8, U8.
-h/--help: Prints this help
-f/--file: Uses file rather than stdin
-s/--server: More explicit way of assigning hostname

__AST2ROAR__END_OF_HELP_TEXT__
   exit 0;
  ;;
  '--server')
   _args="$_args --server $1";
   shift;
  ;;
  '--rate')
   _args="$_args --rate $1";
   shift;
  ;;
  '-B')
   _args="$_args -B $1";
   shift;
  ;;
  '--bits')
   _args="$_args --bits $1";
   shift;
  ;;
  '-s')
   _args="$_args --server $1";
   shift;
  ;;
  '-r')
   _args="$_args --rate $1";
   shift;
  ;;
  '-c')
   _args="$_args --chans $1";
   shift;
  ;;
  '--channels')
   _args="$_args --chans $1";
   shift;
  ;;
  '-f')
   _args="$_args   $1";
   shift;
  ;;
  '--file')
   _args="$_args   $1";
   shift;
  ;;
  '--raw')
   _args="$_args --codec default";
  ;;
  '-'*)
   echo "Unknown option" >&2;
   exit 1;
  ;;
  *)
   echo "Unknown option" >&2;
   exit 1;
  ;;
 esac;
done

if [ "$*" != "" ]
then
 echo "Unknown option" >&2;
 exit 1;
fi

exec roarcat $_args


#ll
