ECMC PVC example file chordmapper3-3
# ECMC PVC example >> chordmapper3-3 <<
# This example is very similar to ECMC PVC example "inharmonator1-3",
# illustrating again that many sound transformations possible with
# inharmonator also can be achieved with chordmapper.
# In this example, as in "inharmonator1-3", the first five partials of a
# violin tone are detuned by progressively greater amounts, which harmonics 6
# and up are resynthesized at their original pitch, detuning the violin tone.
# Each of the 1st 5 lines after the 'echo"statement contains all 12 arguments
# required to resynthesize a single partial frequency, while the final line
# creates all of the higher harmonics, beginning with harmonic 6:
# echo \
# 7.07 1 2.059 1 1 2 1 0 0 0 0 0 \
# 7.07 2 2.122 1 1 2 1 0 0 0 0 0 \
# 7.07 3 2.189 1 1 2 1 0 0 0 0 0 \
# 7.07 4 2.260 1 1 2 1 0 0 0 0 0 \
# 7.07 5 2.334 1 1 2 1 0 0 0 0 0 \
# 7.07 6 1.0 0 1 -4 1 0 0 0 0 0 \
# > $SFDIR/chordmapfile
# The first 5 lines after the "echo"statement each create a sinusoid. The fundmental
# is resynthesized at 2.059 times its original frequency (an minor ninth up), the
# 2nd harmonic is shifted up a majjor ninth (2.122), the third harmonic is transposed
# up a minor tenth (2.189), the 4th harmonic is shifted up a major tenth (2.26)
# and the 5th harmonic is shifted up a major tenth (2.334). All of these 5 partials
# are given a 2 dB boost, while the other, non-transposed partials are cut by 4 dB.
# TO avoid cliping we cut the master gain for ALL of these partials by 4 dB:
# MASTER_gain_in_decibels=-4 # in dB, int, float or FUNC

#******************************************************
#************** CHORDMAPPER ***************************
#******************************************************
     # ******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=chordmapper3-3  # output soundfile
outputformat=AIFF  # for Linux only : specify AIFF or WAVE output format
# ********************* #

   ##### Cmusic function file generator tempates #####
# (No gen functions used in this example)
   ##### End of gen routine function generator tempates #####
#......................................................
output_data_format=1
   #  0=  Same as input file, 1 = integers 2 = rescaled floats 

#******** BEGIN/END TIMES *****************************
   # beginning and end times within input soundfile for analysis/resynthesis
begintime=0    # time in input soundfile to begin analysis/resynthesis
endtime=0      # (-1 or 0 end time defaults to end of file)

#======================================================
#*** ANALYSIS PARAMETERS ******************************
FFT_length=1024  # usually 1024, sometimes 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_expansion_contraction_factor=.5
       # OUTPUT CHANNEL(S) .......................
output_channel=0
   # channels are numbered from 1 to the maximum; 0 = all channels
#.............OSCIL THRESHOLD ........................
oscillator_resynthesis_threshold_in_dB=-80
     #( Usually -60 to -80 unless dropouts become audible. )

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

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

MASTER_gain_in_decibels=-4   # in dB, int, float or FUNC

#********** SOURCE ************************************
#.................. DECIBELS ..........................
SOURCE_gain_in_dB=-96  # in dB, int, float or FUNC

#.................. PITCH .............................

SOURCE_frequency_shift=0  # int, float or FUNC
SOURCE_pitch_transposition_in_semitones=0 # int, float or FUNC

#======================================================
#**************** TARGETS *****************************
#======================================================
#.................. DECIBELS ..........................

TARGETS_gain_in_dB=-0  # int, float or FUNC

#.................. PITCH .............................
TARGETS_frequency_shift=0   # int, float or FUNC
TARGETS_pitch_transposition_in_semitones=0  # int, float or FUNC

#............ SPECTRUM WARPSHAPE ......................

spectrum_warpshape_index=0  # int, float or FUNC

#............ AMPLITUDE RESPONSE ......................
attack_time_in_seconds=0   # int, float or FUNC
release_time_in_seconds=0  # int, float or FUNC

#======================================================
#***** LOW/HIGH SHELF EQ (TARGETS ONLY) ***************

LOW_SHELF_EQ_gain_in_decibels=-0
LOW_SHELF_EQ_frequency=100

HIGH_SHELF_EQ_gain_in_decibels=0
HIGH_SHELF_EQ_frequency=1000

#======================================================
#...MASTER INTERPOLATION CONTROLS ......................

# (Using (0-1) control functions, these 3 variables provide
#  master controls for time varying manipulation of the amp, 
#  freq and null phase values of a tone. With the respective P-field 
#  of a tone set to 1 (on), the controls interpolate 
#  between the source value and target setting. For example, a 
#  function moving between 0 and 1 would cause the frequency to 
#  shift from the orginal source value to the tone's target 
#  setting. Setting the P-field to .5 would start the shift halfway 
#  between source and target values. Negative
#  produce the same as positive values except that they
#  invert the control value in its 0-1 range before using it. 

#.....AMPLITUDE: 
TARGETS_amp_interpolation_control__0_to_1=1
#....FREQUENCY:  
TARGETS_freq_interpolation_control__0_to_1=1
#....NULL PHASE: 
TARGETS_nullphase_interpolation_control__0_to_1=1

#======================================================

#........Two more TUNING conrtols: ........................

# Most of you will never use these variables (A.S.)
# There are two tuning control values; the first for the tone
#  and the second global value that sets the tuning base for
#  all tones. The partial_tuning_control determines the current tuning
#  of the tone by mapping its 0-1 value or function into the difference
#  between the base and tone tuning settings.  For example, 
#  a function progressing from 0 to 1, placed in the tuning control 
#  parameter would case the tuning to move from the base value to the 
#  target tuning.

TARGETS_partial_tuning_control=1 
   # (0-1 control value)

TARGETS_partial_tuning_base_value=0
   # 0 = original source tuning,  1 = tuned to target partial
  # < 0 = source tuning deviation amplified, 
  # > 1 = inverse amplified source tuning deviation

#======================================================
TARGETS_shift_file=$SFDIR/chordmapfile

#..............SOURCE POINT FORMAT ....................

SOURCE_POINT_DATA_FORMAT=1
 # 0 = pitch specified in frequency used in chordmapfile
 # 1 = pitch specified in octave.pitchclass used in chordmapfile

#.............. SHIFT POINT FORMAT ....................

SHIFT_DATA_FORMAT=0
# 0 = frequency multiplier  # 1 = partial shift adder 
# 2 = map to frequency ) 3 = map to octave.pitchclass 
 # (A.S. : I don't know what this parameter does)

#======================================================
#***** DATA SET for CHORDMAPPER "TONES" **********
# Create 12 values in the data file for each output tone.
  # Line 1 below
# 1)  source freq. or oct.pch (depending on SOURCE_DATA_FORMAT above)
# 2) lowest partial number  : 1 or higher
# 3) output freq. or oct.pch (depending on SOURCE_DATA_FORMAT above
# 4) number of partials above lowest  (0 = all below Nyquist)
# (5) partial bandwidth as proportion  of fundamental frequency 
  #  higher values = brighter timbres
# (6) gain or attenuation in dB
  # Line 2 below : these parameters used less frequently
# (7) partial spacing as proportion of fundamental,negative = rejectmode 
# (8) decibel rolloff per octave  beginning with lowest partial.
# Postive rolloff produces gain.rejectmode measure begins from fundamental
# (9) Amplitude interpolation switch/degree.
#	0 = off, 1 = on, -1 = inverse on, .5 = half on
# (10) Frequency interpolation switch/degree.
#	0 = off, 1 = on, -1 = inverse on,  .5 = half on
# (11) Tuning factor
#	0 = original source tuning,  1 = tuned to target partial
#	< 0 = source tuning-deviation amplified, 
#	> 1 = inverse of amplified source-tuning-deviation
# (12) Null phase factor, 0 = off,  1 = null phase,  
#	.5 = halfway to null phase
#======================================================
# Create CHORDMAPPER FUNCTION HERE:

echo \
7.07 1 2.059 1 1 2 1 0 0 0 0 0 \
7.07 2 2.122 1 1 2 1 0 0 0 0 0 \
7.07 3 2.189 1 1 2 1 0 0 0 0 0 \
7.07 4 2.260 1 1 2 1 0 0 0 0 0 \
7.07 5 2.334 1 1 2 1 0 0 0 0 0 \
7.07 6 1.0   0 1 -4 1 0 0 0 0 0 \
> $SFDIR/chordmapfile
#*****************************************************
# An * (asterisk) at the beginning of a data set will comment it out.
# Do not include any blank lines, # or other characters in this function
# definition. Be very careful - -chordmapper is VERY picky

#........... 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=chordmapper 

PVFLAGS="\
\
-N$FFT_length \
-M$windowsize \
-w$window_type \
-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 \
\
-G$SOURCE_gain_in_dB \
-a$SOURCE_frequency_shift \
-P$SOURCE_pitch_transposition_in_semitones \
\
-q$TARGETS_frequency_shift \
-X$TARGETS_pitch_transposition_in_semitones \
-m$TARGETS_gain_in_dB \
-F$TARGETS_shift_file \
\
-L$release_time_in_seconds \
-l$attack_time_in_seconds \
\
\
-c$TARGETS_amp_interpolation_control__0_to_1 \
-d$TARGETS_freq_interpolation_control__0_to_1 \
\
-B$TARGETS_nullphase_interpolation_control__0_to_1 \
-K$TARGETS_partial_tuning_control \
-J$TARGETS_partial_tuning_base_value \
\
\
-Z$SHIFT_DATA_FORMAT \
-Q$SOURCE_POINT_DATA_FORMAT \
-W$spectrum_warpshape_index \
\
\
-S$LOW_SHELF_EQ_gain_in_decibels \
-U$LOW_SHELF_EQ_frequency \
\
-T$HIGH_SHELF_EQ_gain_in_decibels \
-V$HIGH_SHELF_EQ_frequency \
\
\
-_$output_data_format \
-=$rescale_level_in_decibels \
\
-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: ******* #
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/chordmapfile