ECMC PVC example file bandamp2
# ECMC PVC example script "bandamp2" uses the frequency response
# file created by example script "freqresponse2" - a fragmentary
# analysis (between times .3 and .6 seconds) of a cello pizzicato tone

# All frequenciies greater than -15 dB (all "louder" frequencies within
# the source cello pizz tone) are suppressed:
# WINDOW_type__bandpass_0__bandreject_1=0
# WINDOW_upper_threshold_in_dB=-15 # int, float or FUNC
# WINDOW_lower_threshold_in_dB=-90 # int, float or FUNC
# Suppression of the stronger frequency components of the source sound
# would result in a very low output level. We compensate for this
# by introducing a 12 dB gain, as well as a fade-out, in this
# amplitude function:
# gen4 -L1000 0 1. -1 4.6 1. -1 4.8 0 | reshape -M18. > $SFDIR/gainfunc
# gain_in_decibels=$SFDIR/gainfunc # int, float or FUNC
# "bandamp" tends to produce artifacts -- clicks or noise.
# Smoothing out changes in the amplitudes of frequency components,
# , as in the two lines below, often helps remove these artifacts.
# envelope_attack_in_seconds=.05 # int, float or FUNC
# envelope_release_in_seconds=.05 # int, float or FUNC

#******************************************************
#*************** BANDAMP (ECMC version)  **************
# ******ECMC CHANGES & ADDITIONS: ***************
PVCDIR=/usr/local/soundapps/PVC
PVCBIN=$PVCDIR/bin
cd $PVCBIN
#******** AIFF INPUT & OUTPUT SOUNDFILES *************
aiffinput=/sflib/string/vc.p.e2
aiffoutput=bandamp2
freqresponsefile=vc.p.e2.mid.fr
#******************************************************
##### Cmusic function file generator tempates #####
#   gen4 generates exponenetial segments; "a" values determine shape &
#  depth of curve: 0 = linear, neg. = exponential, pos. = inverse expo.
 gen4 -L1000 0 1. -1 4.6 1. -1 4.8 0 | reshape -M18. > $SFDIR/gainfunc
# gen4 -Llength t1 v1 a1 ... tN vN

#------------------------------------------------------
#******************** ANALYSIS ************************
#------------------------------------------------------

peaks_analysis_file=$freqresponsefile

peak_analysis_begintime=0
peak_analysis_endtime=0

ANALYSIS_METHOD_average_0_peak_1_flag=1
ANALYSIS_frames_per_second=32

ANALYSIS_print_response_to_terminal_0_no__1_yes=0

#------------------------------------------------------
#******************* SYNTHESIS ************************
#------------------------------------------------------

#******** BEGIN/END TIMES *****************************
# (-1 end time defaults to end of file)
begintime=0
endtime=-1  # begin & end times determine output duration

FFT_length=2048 # 1024
windowsize=0

frames_per_second=200
time_expansion_contraction_factor=2


#**** OUTPUT CHANNEL(S) *******************************
channel_1_to_max__0_all=0
# (channels are numbered from 1-maximum)
# (0 = all channels)

oscillator_resynthesis_threshold_in_dB=-96

#****** DYNAMIC PARAMETERS ****************************
frequency_shift=0  # int, float or FUNC
gain_in_decibels=$SFDIR/gainfunc  # int, float or FUNC
pitch_transposition_in_semitones=1  # int, float or FUNC

#****** WINDOW PARAMETERS *****************************
peaks_response_smooth_factor_in_octaves=0
print_smoothed_freq_response_to_terminal_0_no__1_yes=0

WINDOW_type__bandpass_0__bandreject_1=0
WINDOW_upper_threshold_in_dB=-15  # int, float or FUNC
WINDOW_lower_threshold_in_dB=-90  # int, float or FUNC

#******** LOW/HIGH SHELF EQ (post transpose/shift) ****
LOW_SHELF_EQ_gain_in_decibels=-0
LOW_SHELF_EQ_frequency=200

HIGH_SHELF_EQ_gain_in_decibels=-0
HIGH_SHELF_EQ_frequency=4000
#************ENVELOPE RESPONSE **********************
envelope_attack_in_seconds=.05  # int, float or FUNC
envelope_release_in_seconds=.05  # int, float or FUNC

#********** AMPLITUDE STATISTICS ******************** 
print_amplitude_statistics_0_no__1_yes=1
amplitude_statistics_time_interval=.25


#====================================================
# COMMAND LINE SETUP -- OFFICE USE ONLY
#      (DO NOT WRITE BELOW THIS LINE)
#====================================================
# *****  ECMC CHANGES: ******* #
cd $SFDIR  # ECMC
input_file=pvcin  # ECMC temporary NeXT format input soundfile
output_file=pvcout  # ECMC temporary NeXT format output soundfile
/sbin/rm -f pvcin pvcout  #
#  Create temporary NeXT format input soundfile "pvcin:" ECMC
/usr/local/bin/sox -t aiff $aiffinput -t au pvcin # ECMC
pvanalysisroutine=$PVCBIN/freqresponse  # ECMC
#  ****** end of ECMC changes & additions ****** #
# ANALYSIS

PVFLAGS="\
\
-N$FFT_length \
-M0 \
-D$ANALYSIS_frames_per_second \
\
-b$peak_analysis_begintime \
-e$peak_analysis_endtime \
\
-c$ANALYSIS_METHOD_average_0_peak_1_flag \
\
-P$ANALYSIS_print_response_to_terminal_0_no__1_yes \
\
-C$channel_1_to_max__0_all \
\
-B1 \
\
"
echo "\n$pvanalysisroutine $PVFLAGS $input_file $peaks_analysis_file"

$pvanalysisroutine $PVFLAGS $input_file $peaks_analysis_file ;

#====================================================
# SYNTHESIS
pvroutine=$PVCBIN/bandamp   # ECMC


PVFLAGS="\
\
-N$FFT_length \
-M$windowsize \
-D$frames_per_second \
-I$time_expansion_contraction_factor \
\
-a$frequency_shift \
-P$pitch_transposition_in_semitones \
-A$gain_in_decibels \
\
-C$channel_1_to_max__0_all \
-t$oscillator_resynthesis_threshold_in_dB \
\
-b$begintime \
-e$endtime \
\
-F$peaks_analysis_file \
-Q$WINDOW_upper_threshold_in_dB \
-q$WINDOW_lower_threshold_in_dB \
-S$peaks_response_smooth_factor_in_octaves \
-Z$print_smoothed_freq_response_to_terminal_0_no__1_yes \
-L$envelope_release_in_seconds \
-l$envelope_attack_in_seconds \
-W$WINDOW_type__bandpass_0__bandreject_1 \
\
-H$LOW_SHELF_EQ_gain_in_decibels \
-m$LOW_SHELF_EQ_frequency \
\
-X$HIGH_SHELF_EQ_gain_in_decibels \
-R$HIGH_SHELF_EQ_frequency \
\
-p$print_amplitude_statistics_0_no__1_yes \
-i$amplitude_statistics_time_interval \
\
"
echo "\n$pvroutine $PVFLAGS $input_file $output_file"

$pvroutine  $PVFLAGS $input_file $output_file   ; 

# *****  ECMC CHANGES & ADDITIONS: ******* #
echo 'Converting temporary NeXT format output soundfile to aiff format:"'
/usr/local/bin/sox -t au pvcout -t aiff  $aiffoutput # ECMC
/sbin/rm -f pvcin pvcout   # ECMC
/usr/sbin/sfinfo -s $aiffoutput # ECMC
#  ****** end of ECMC changes & additions ****** #

# If you have created any gen function files above delete them below:
rm $SFDIR/gainfunc