#!/bin/csh -f
# plainpvtp : TKLA script that provides another script, based on
# Paul Koonce's  S.plainpv, to run plainpv with user parameters and
# conversions 
# A. S. 5/11/98, revised 12/02/00 and 11/2003

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

switch ($1)
case -:
  cat $PVCDIR/TKLA/plainpv.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
  endif
else
    echo "ERROR: Incorrect number of arguments."
    echo "plainpvtp syntax:   plainpvtp  insound [outsound] "
    echo ' where "insound" is the name (and, if necessary, path) of the input'
    echo ' soundfile and the optional "outsound" argument is the nameof the'
    echo ' output resynthesis soundfile. If the "outsound" argument is omitted'
    echo ' the output soundfile will be named "test."'
    echo "Your arguments are:"
    echo  "    plainpvtp $argv[1-$#argv] "
    #echo "Quitting."
    exit 1
endif

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

cat $PVCDIR/TKLA/plainpv.template  | sed -e 's/INPUTSF/'$INPUTSOUNDFILE'/g' | sed -e 's/OUTPUTSF/'$OUTPUTSOUNDFILE'/g'  

