#!/bin/bash
# A.S. July 2003
if  ( [ $# == 0 ] ) ; then  # print usage summary
  echo "sfsamples: returns the number of sample frames in a soundfile"
  echo "syntax:  sfsamples  soundfile1 [soundfile2  soundfileN]"
  exit 0 ;
fi

cd $SFDIR
for i in $* ; do
    if ( ! ( test -s "${i}" ) ) ; then echo -e  "No soundfile named >> ${i} << found. Quitting." ; exit 0 ; fi
                   # exit if input file does not exist

SNDINFO=`csound -U sndinfo "${1}" 2> /dev/null | grep -e "sample\ frames"`
 SAMPLES=`echo  $SNDINFO | grep  -e "sample\ frames" | awk '{print $5}' | sed -e 's^(^^g'`
    echo $SAMPLES $1
done
