ECMC PVC example file inharm1-1
#ECMC PVC and /sflib/x example "inharm1-1" :
# This is a reference example -- straight resynthesis of a violin
# tone, for comparison with examples inharm1-2, 1-3 and 1-4.
# The duration of input soundfile /sflib/string/vln.g3 is cut in half:
# time_expansion_contraction_factor=.5 # 1
# The inharmonator frequency is set to 196 to match the fundamental
# of the violin tone g3:
# INHARMONATOR_fundamental_frequency=196 # int, float or FUNC
# (In this example this change makes no difference, but in examples
# inharm1-2, inharm1-3 and inharm1-4 it is important.)
# No other resynthesis alterations are made to this source sound, and
# defaults are used for all other parameters except for a 2 dB gain reduction:
# MASTER_gain_in_decibels=-2 # int, float or FUNC
#******************************************************
#................. INHARMONATOR .......................
#******************************************************
     # ******ECMC CHANGES & ADDITIONS: ***************
#******** INPUT & OUTPUT SOUNDFILES *************
  # input soundfile, can be aiff or wave format on Linux, aiff only on SGI
inputsf=/sflib/string/vln.g3
outputsf=$SFDIR/inharm1-1  # output soundfile
outputformat=AIFF  # for Linux only : specify AIFF or WAVE output format
# ********************* #


   ##### 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 #####

#******************** OUTPUT **************************
output_data_format=0
   #  0=  Same as input file, 1 = integers 2 = rescaled floats 
#******************** INPUT ***************************
#........ BEGIN/END TIMES .............................
begintime=0
endtime=0
# (0 or less end time defaults to end of file)

#======================================================
#*** ANALYSIS PARAMETERS ******************************

FFT_length=1024  # must be power-of-2, usually 1024, 512 or 2048
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
        # 0 sets windowsize to 2 * FFT (or larger)
frames_per_second=200   # generally 200, occasionally 400 or 600 when time stretching

#======================================================
#*** RESYNTHESIS PARAMETERS ***************************

#.................. TIME ..............................
time_expansion_contraction_factor=.5 # speed is doubled, duration cut in half

#........... OUTPUT CHANNEL(S) .......................
output_channel=0

# (channels are numbered from 1-maximum)
  # channels are numbered from 1 to the maximum; 0 = all channels

#.............OSCIL THRESHOLD ........................
oscillator_resynthesis_threshold_in_dB=-80

#****************** MODIFICATIONS *********************

#.................. DECIBELS ..........................

MASTER_gain_in_decibels=-2  # int, float or FUNC

#======================================================
#********** SOURCE ************************************

SOURCE_frequency_shift=0  # int, float or FUNC
SOURCE_pitch_transposition_in_semitones=-0  # int, float or FUNC
SOURCE_gain_in_dB=-20  # int, float or FUNC

#............ AMPLITUDE RESPONSE ......................
SOURCE_attack_time_in_seconds=0  # int, float or FUNC
SOURCE_release_time_in_seconds=0  # int, float or FUNC

#********** NON TARGETS ********************************
NON_TARGETS_frequency_shift=0
NON_TARGETS_pitch_transposition_in_semitones=0 # int, float or FUNC
NON_TARGETS_gain_in_dB=-96  # int, float or FUNC
   # Range 0 to -96 (the default)
   # -96 provides the maximum possible suppression of non-target partials
   # but does not provide complete suppression
   # 0 causes no attenuation in the amplitude of the non-target partials
#======================================================
#********** TARGETS ********************************

#............ FUNDAMENTAL FREQUENCY .....................
INHARMONATOR_fundamental_frequency=196  # int, float or FUNC
#  IMPORTANT: If possible change the default value of 500 above
  #  to the fundamental frequency, in herz, of the input soundfile
  #  Use the "midinote" command, or else consult the help file "herz"  #  to determine this frequuency
  #  For inharmonic sounds, try changing the 500 default to various other
  #  values, and choose the value that provides the best result

#*****TARGETS SHIFT FILE: DATA FORMAT
# Edit the template table below, changing the 3 values for each partial
# and adding or deleting lines to specify more or less than 10 target
# partials. Do not include any comments or blank lines within this function
# definition and make sure that the \ at the end of each line is preceded
# by a space
# The 3 arguments on each line below specify the:
# 1) partial number
# 2) shift
# 3) change in gain in decibels

#==== CREATE TARGET SHIFT FILE DATA HERE ==============
echo \
1       1           0 \
2       1           0 \
3       1           0 \
4       1           0 \
5       1           0 \
\
6       1           0 \
7       1           0 \
8       1           0 \
9       1           0 \
10      1           0 \
> $SFDIR/inharmonatorfile  

#*************** TARGETS ********************************
TARGETS_shift_file=$SFDIR/inharmonatorfile #Do not change this line unless
                                         # you really know what you are doing
#======================================================
SHIFT_DATA_FORMAT=0
#  0 = frequency multiplier       1 = map to frequency 
#  2 = map to octave.pitchclass   3 = map to partial number 
#======================================================

TARGETS_partial_band_edge_decibels=-0

#.................. DECIBELS ..........................
TARGETS_frequency_shift=0  # int, float or FUNC
TARGETS_pitch_transposition_in_semitones=0 # int, float or FUNC
TARGETS_gain_in_dB=-0  # int, float or FUNC

#.................CONTROL  ..........................
TARGETS_freq_shift_control_proportion=1  # int, float or FUNC
#(control proportion is 0-1, 0=no shift, 1=full shift)


#............ SPECTRUM WARPSHAPE ......................
TARGETS_spectrum_warpshape_index=0

#............ RESPONSE ...............................

INHARMONATOR_attack_time_in_seconds=0 # int,float or FUNC
INHARMONATOR_release_time_in_seconds=0 # int,float or FUNC
INHARMONATOR_frequency_response_time_in_seconds=0 # int,float or FUNC

#======================================================
#........... RESCALE for floating point only ......
rescale_level_in_decibels=0
   # set to 1 to rescale to peak of input file; do not do this if input amplitude
   # is low
#********** 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)
#====================================================
PVCDIR=/usr/local/soundapps/PVC
PVCBIN=$PVCDIR/bin
cd $SFDIR  # ECMC

if  [ "$OSTYPE" = "irix" ]
then
   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 $inputsf -t au pvcin # ECMC
elif [ `echo "$OSTYPE" | grep linux`  ]
 then
  input_file=$inputsf
  output_file=$outputsf
fi
#  ****** end of ECMC changes & additions ****** #

pvroutine=inharmonator

PVFLAGS="\
\
-N$FFT_length \
-M$windowsize \
-D$frames_per_second \
-I$time_expansion_contraction_factor \
\
-C$output_channel \
-t$oscillator_resynthesis_threshold_in_dB \
\
-b$begintime \
-e$endtime \
\
-A$MASTER_gain_in_decibels \
\
-Q$SOURCE_frequency_shift \
-u$SOURCE_pitch_transposition_in_semitones \
-r$SOURCE_gain_in_dB \
-l$SOURCE_attack_time_in_seconds \
-L$SOURCE_release_time_in_seconds \
\
-f$INHARMONATOR_fundamental_frequency \
-v$INHARMONATOR_attack_time_in_seconds \
-V$INHARMONATOR_release_time_in_seconds \
-Y$INHARMONATOR_frequency_response_time_in_seconds \
-Z$SHIFT_DATA_FORMAT \
\
-a$NON_TARGETS_frequency_shift \
-P$NON_TARGETS_pitch_transposition_in_semitones \
-G$NON_TARGETS_gain_in_dB \
\
-F$TARGETS_shift_file \
-B$TARGETS_partial_band_edge_decibels \
-q$TARGETS_frequency_shift \
-X$TARGETS_pitch_transposition_in_semitones \
-m$TARGETS_gain_in_dB \
-S$TARGETS_shift_control_proportion \
\
\
-W$TARGETS_spectrum_warpshape_index \
\
-p$print_amplitude_statistics_0_no__1_yes \
-i$amplitude_statistics_time_interval \
\
-_$output_data_format \
-=$rescale_level_in_decibels \
\
\
"
echo "\n\n$pvroutine $PVFLAGS $input_file $output_file "

$pvroutine  $PVFLAGS $input_file $output_file   ; 
# *****  ECMC CHANGES & ADDITIONS: ******* #
if  [ "$OSTYPE" = "irix" ]
then
   echo 'Converting temporary NeXT format output soundfile to aiff format:"'
   /usr/local/bin/sox -t au pvcout -t aiff  $outputsf # ECMC
   /sbin/rm -f pvcin pvcout   # ECMC
   echo "Header information for output soundfile >> $outputsf << :"
   /usr/sbin/sfinfo -s $outputsf # ECMC
elif [ `echo "$OSTYPE" | grep linux`  ]
then
   if  [ "$outputformat" = "AIFF" ] 
     then
            echo "   Converting output soundfile $output_file to AIFF format ..."
            /usr/local/soundapps/PVC/bin/wav2aiff $output_file
   fi
   echo "Header information for output soundfile >> $outputsf << :"
   /usr/local/bin/sfinfo -s $outputsf 
fi
#  ****** end of ECMC changes & additions ****** #


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