#!/bin/csh -f
# twarptp : TKLA script that provides another script, based on
# Paul Koonce's  S.twarp, to run twarp with user parameters and
# on Irix systems, or optional conversion from WAVE to AIFF on Linux systems
# A. S. 5/11/98, revised for Linux & SGI 12/05/00

if ($#argv == 0) then
    echo "twarptp syntax:  twarptp  inanal [outsound] [> scriptfile]"
    echo ' where "inanal" is the name (and, if necessary, path) of the input'
    echo ' analysis file 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 twarp with this script file with the command:'
    echo '      sh scriptfile'
    echo ' To see a "twarp" template file without providing soundfile arguments type'
    echo '     twarptp -'
    exit 1
endif

switch ($1)
case -:
  cat $PVCDIR/TKLA/twarp.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 analysis file >> $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 "twarptp syntax:  twarptp  inanal [outsound] [> scriptfile]"
    echo ' where "inanal" is the name (and, if necessary, path) of the input'
    echo ' analysis file 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 "Your arguments are:"
    echo  "    twarptp $argv[1-$#argv] "
    #echo "Quitting."
    exit 1
endif

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

cat $PVCDIR/TKLA/twarp.template  | sed -e 's/ANALFILE/'$INPUTANALFILE'/g' | sed -e 's/OUTFILE/'$OUTPUTFILE'/g'  

