   # Example PVC script file >> pvcanal2 << :
# ECMC PVC example "pvcanal2" creates an analysis file of /sflib/wind/fl.c4
# The resulting analysis file is used in example "convolver2"
 #******************************************************
#... PHASE VOCODER ANALYSIS ...........................
#******************************************************

     # ******TKLA CHANGES & ADDITIONS: ***************
#******** INPUT & OUTPUT SOUNDFILES *************
  # input soundfile, can be aiff or wave format on Linux, aiff only on SGI
inputsf=/sflib/wind/fl.c4.wav
analysis_outputfile=$SFDIR/fl.c4.pvc  # output analysis file used by other pvc programs
# ********************* #

   ##### Cmusic function file generator tempates #####
#   gen0  normalizes function files previously created with other gen routines
# gen0 -Llength  max < inputfuncfile > outputfuncfile
#   gen1 creates linear {straight line} segments, like Csound gen 7
# gen1 -Llength t1 v1 ... tN vN
#   gen2 generates harmonic waveforms from sine {a} & cosine {b} amps
# gen2 -Llength [-o (default) or -c] a1 ... aN b0 ... bM N
#  gen3 generates amp values & linear connections at equally spaced time points
# gen3 -Llength v1 v2 ... vN
#   gen4 generates exponenetial segments; "a" values determine shape &
#  depth of curve: 0 = linear, neg. = exponential, pos. = inverse expo.
# gen4 -Llength t1 v1 a1 ... tN vN
#  gen5 is like Csound gen 9 : harmonic1/amp/phase harmonic2/amp/phase
# gen5 -Llength h1 a1 p1 ... hN aN pN
#     gen6 generates a table of random numbers between +1 and -1
# gen6 -Llength
#    cspline: smooth curve {cubic spline} interpolator
# cspline len_flag [flags] x0 y0 x1 y1 ... xN yN
#   genraw reads in a previously created function file
# genraw -LN filename    (where N is the length of the output function.)
# For a usage summary of "reshape" type  "reshape"  with no arguments.
   ##### End of gen routine function generator tempates #####

#........ BEGIN/END TIMES to read input soundfile ........................
 # analyze entire input soundfile
begintime=0        # time in input soundfile to BEGIN analysis
endtime=0          # time in input soundfile to END analysis
                   # (0 or negative end time defaults to end of file)
#======================================================
#*** ANALYSIS PARAMETERS ******************************
FFT_length=1024 # must be power-of-2, usually 1024, 512 or 2048
      # do not set FFT_length lower than 1024 if samp. rate = 96000
window_type=2
    # window type: 0 = Hamming,1 = rectangular, 2 = Blackman (DEFAULT),
    #  3 = Bartlett triangular, 4-12 = Kaiser windows for alpha = 4-12
    # generally recommended: 2 or 8
windowsize=0    # default 0 sets windowsize (in samples) to 2 * FFT_length if
  #  samp. rate <= 48000 or to 4 * FFT_length if samp. rate > 48000
frames_per_second=200   # generally 200, occasionally 400 or 600 when time stretching
#.......... ANALYSIS CHANNEL(S) .......................
analysis_channel_1_to_max=0
    # (channels are numbered from 1-maximum)  (default 0 = use all channels)

#======================================================
#************* MODIFICATIONS **************************
#======================================================

#.................. Amplitude in DECIBELS ..........................

gain_in_decibels=0   # use to increase or decrease amplitude during resynthesis

#********ANALYSIS LOW/HIGH SHELF EQ *******************

ANALYSIS_LOW_SHELF_EQ_gain_in_decibels=0  # change to boost or cut low freqs
ANALYSIS_LOW_SHELF_EQ_frequency=300

ANALYSIS_HIGH_SHELF_EQ_gain_in_decibels=0  # change to boost or cut high freqs
ANALYSIS_HIGH_SHELF_EQ_frequency=600

#................. WARP ...............................

spectrum_warpshape_index=0  # int, float or FUNC
       # timbral modification, boosting (negative) or reducing (positive)
       # frequency components  of low amplitude
#.............. PRINT ................................ 

print_average_spectrum=0  # 0 = do not print, 1 = print

#====================================================
# COMMAND LINE SETUP -- OFFICE USE ONLY
#      (DO NOT WRITE BELOW THIS LINE)
#====================================================
cd $SFDIR
 SR=`sfsr $inputsf | awk '{print $1}'`
if ( ( [ `expr "$SR" \> "48000"` == 1 ] ) &&  ( [ "$windowsize" == "0" ] ) ) ; then
       # if SR is > 48000 & windowsize is set to 0 increase default windowsize
  windowsize=`expr $FFT_length \* 4`
fi
# Determine if input soundfile is 24 bit. If so, compile 32 bit float outputs, the
n
# convert to 24 bit ints
WORDSIZE=`/usr/local/bin/sfbits "${inputsf}" | awk '{print $1}'`
if [ "$WORDSIZE" == "24" ] ; then rm -f pvcin ; 24tofloat $inputsf pvcin ; input_file=pvcin
else # not 24 bit input ; 16 bit int or 32 bit float input
    input_file=$inputsf
fi
#  ****** end of TKLA changes & additions ****** #
# ANALYSIS

pvanalysisroutine=pvanalysis
PVFLAGS="\
\
-N$FFT_length \
-M$windowsize \
-w$window_type \
-D$analysis_frames_per_second \
\
-A$gain_in_decibels \
\
-b$begintime \
-e$endtime \
\
-C$analysis_channel_1_to_max \
\
-H$ANALYSIS_LOW_SHELF_EQ_gain_in_decibels \
-m$ANALYSIS_LOW_SHELF_EQ_frequency \
\
-X$ANALYSIS_HIGH_SHELF_EQ_gain_in_decibels \
-R$ANALYSIS_HIGH_SHELF_EQ_frequency \
\
-W$spectrum_warpshape_index \
\
\
-p1 \
-P$print_average_spectrum \
\
"
echo "\n\n$pvanalysisroutine $PVFLAGS $input_file $analysis_outputfile  "

$pvanalysisroutine $PVFLAGS $input_file $analysis_outputfile ; 

   # *****  TKLA CHANGES & ADDITIONS: ******* #
if ( ( [ "$WORDSIZE" == "24" ] ) && ( [ test -f "pvcin" ] ) ) ; then rm -f pvcin ; fi
echo "    -------------------------------------------------"
if ( ( test -f "$analysis_outputfile" ) ) ; then
echo "Output analysis file:"
ls -l $analysis_outputfile
fi
   echo " -------------------------------------------------------"
#  ****** end of TKLA changes & additions ****** #
