#!/bin/csh -f
# pvanalysistp {pvcanaltp} : TKLA script that provides a template script,
# based on Koonce's  S.pvanalysis, to run pvanalysis with user parameters and, on
# SGI systems, conversions between aiff and NeXT formats for the input soundfile
# A. S. 5/11/98, revised 12/12/00 for Linux & SGI using pvc version 3.0

if ($#argv == 0) then
    echo "pvanalysistp syntax:   pvanalysistp  insound [outanal] [> scriptfile]"
    echo " or :  pvcanaltp  insound [outanal] [> scriptfile]"
    echo ' where "insound" is the name (and, if necessary, path) of the input'
    echo ' soundfile and "outanal" argument is the name of the'
    echo ' output analysis file. If the "outanal" argument is omitted'
    echo ' the output analysis file will be named "test.pvc"'
    echo ' After capturing this template in an ascii file and editing this'
    echo ' file, run pvanalysis with this script file with the command:'
    echo '      sh scriptfile'
    echo ' To see a "pvanalysis" template file without providing an soundfile'
    echo '  argument, type'
    echo '   pvanalysistp -    or else     pvcanaltp -'
    exit 1
endif

switch ($1)
case -:
  cat $PVCDIR/TKLA/pvanalysis.template
  exit 1
breaksw
endsw

cd $SFDIR

if ($#argv == 1 || $#argv == 2) then
  if (-e $1) then
     set INARG = $1
  else
     echo " #### ERROR: Can't find input soundfile >> $1 << ####"
     echo " (Your current working soundfile directory is >> $SFDIR << )"
     exit 1
  endif
  if ($#argv == 2) then
     set OUTARG = $2
  else
     set OUTARG = test.pvc
  endif
else
    echo "ERROR: Incorrect number of arguments."
    echo "pvanalysistp syntax:   pvanalysistp  insound [outanal] "
    echo ' where "insound" is the name (and, if necessary, path) of the input'
    echo ' soundfile and "outanal" argument is the nameof the'
    echo ' output analysis file. If the "outanal" argument is omitted'
    echo ' the output analysis file will be named "test.pvc"'
    echo "Your arguments are:"
    echo  "    pvanalsysistp $argv[1-$#argv] "
    exit 1
endif

###########
 set INPUTSOUNDFILE = `echo $INARG | sed -e 's/\//\\\//g' `
 set OUTPUTANALFILE = `echo $OUTARG | sed -e 's/\//\\\//g' `

cat $PVCDIR/TKLA/pvanalysis.template  | sed -e 's/INPUTSF/'$INPUTSOUNDFILE'/g' | sed -e 's/OUTFILE/'$OUTPUTANALFILE'/g' 


