#!/bin/bash

# ----------------------------------------------------------------
# RPC Project :
# Run RPC_vectime_to_spectro : produce spectrogram from a VT file
#
# P. Robert, LPP, 2012-12-05
# ----------------------------------------------------------------

appli=`basename $0`
appli36=`echo "$appli                                 " | cut -c1-36`
Narg=5
echo " -------------------------------------------------------------------"
echo $appli $*

if( (test $# = 1 ) && (test $1 = -h ) ) ; then hh=1 ; else hh=0 ; fi

if test $# != $Narg || test $hh = 1
   then
   echo "$appli : produce spectrogram from a VT file"
   echo "$appli   require $Narg argument(s), ex:"
   echo "$appli   VT.rff SP.rff N_Kern N_shift Apod"
   echo ""
   echo "    VT.rff : name of an input  vectime RFF file"
   echo "    SP.rff : name of an output spectrogram RFF file"
   echo "    N_Kern   : Kernel size"
   echo "    N_shift  : for sliding window"
   echo "    Apod     : trapezium (t), Gaussian (g) or nothing (n)"
   echo " ex:"
   echo " $appli CLU1_STASC_NBR_VT_20010913.rff \\ "
   echo "        CLU1_STASC_NBR_SP_20010913.rff \\ "
   echo "        512 512 t"
   echo ""
   if test $hh = 1 ; then exit 0 ; fi
   echo "$appli36 : *** ERROR ! Command aborted." >&2
   exit 1
fi

datim1=`date +%F'  '%H':'%M':'%S `
julsec1=`date +%s`

# remove RPC_ from RPC command

appli=`echo $appli | cut -c5-`

# creating appli.in from arguments list

if test -f $appli.in ; then \mv $appli.in $appli.in.old ; fi

echo $1  > $appli.in
echo $2 >> $appli.in
echo $3 >> $appli.in
echo $4 >> $appli.in
echo $5 >> $appli.in

# run appli.exe 

. run_appli.bash $appli
err=$?
exit $err
