CCRMA

Physical Modelling and Waveshaping


Lecture Slides

A series of gif images of the lecture slides... (sorry, only accesible from within Stanford University)


Physical Modelling


Examples

singer.ins

Perry Cook's Singer physical modeling instrument in clm.

Here is the (very simple!) header of the instrument and a short description of its parameters:

(defcinstrument singer (beg amp data)

Mandatory parameters

beg
starting time in seconds
amp
amplitude
data
a list of lists that contains information for each synthesis "frame". Each component list has the following components (see the examples below):
The shape and glot parameters in the frame list can be a lisp variable containing a vocal tract shape or glotal excitation or can be a pointer to a file that contains it. If you compile and load the singer.ins instrument you will also load a default collection of shapes and glots. These are the available default definitions:

Glotal excitations:

Vocal Tract Shapes

More definitions for both shapes and glots can be found in the following directories:

Some examples...

(with-sound () 
  (singer 0 .1 '((.4 ehh.shp test.glt 523.0 .8 0.0 .01) 
                 (.6 oo.shp test.glt 523.0 .7 .1 .01))))
(with-sound () 
  (singer 0 .1 '((.05 ehh.shp test.glt 523.0 0.8 0.0 .01) 
		 (.15 ehh.shp test.glt 523.0 0.8 0.0 .01) 
		 (.05 kkk.shp test.glt 523.0 0.0 0.0 .01) 
		 (.05 kkk.shp test.glt 523.0 0.0 0.0 .01) 
		 (.02 kk+.shp test.glt 523.0 0.0 1.0 .01) 
		 (.08 kk+.shp test.glt 523.0 0.0 0.2 .01) 
		 (.05 ooo.shp test.glt 523.0 0.8 0.0 .01) 
		 (.15 ooo.shp test.glt 523.0 0.8 0.0 .01) 
		 (.05 eee.shp test.glt 523.0 0.8 0.0 .01) 
		 (.15 eee.shp test.glt 523.0 0.8 0.0 .01) 
		 (.05 ehh.shp test.glt 523.0 0.8 0.0 .01) 
		 (.15 ehh.shp test.glt 523.0 0.8 0.0 .01) 
		 (.05 mmm.shp test.glt 523.0 0.8 0.0 .01) 
		 (.15 mmm.shp test.glt 523.0 0.8 0.0 .01)
		 (.10 mmm.shp test.glt 523.0 0.0 0.0 .01) )))
In the following example we are using a soundfile as an excitation function. In this case a gunshot would be processed by the vocal tract of the model. Highly unpleasant, I guess.

(with-sound () 
  (singer 0 .1 '((.05 ehh.shp "pistol.snd" 523.0 0.8 0.0 .01) 
		 (.15 ehh.shp "pistol.snd" 523.0 0.8 0.0 .01) 
		 (.05 kkk.shp "pistol.snd" 523.0 0.0 0.0 .01) 
		 (.05 kkk.shp "pistol.snd" 523.0 0.0 0.0 .01) 
		 (.02 kk+.shp "pistol.snd" 523.0 0.0 1.0 .01) 
		 (.08 kk+.shp "pistol.snd" 523.0 0.0 0.2 .01) 
		 (.05 ooo.shp "pistol.snd" 523.0 0.8 0.0 .01) 
		 (.15 ooo.shp "pistol.snd" 523.0 0.8 0.0 .01) 
		 (.05 eee.shp "pistol.snd" 523.0 0.8 0.0 .01) 
		 (.15 eee.shp "pistol.snd" 523.0 0.8 0.0 .01) 
		 (.05 ehh.shp "pistol.snd" 523.0 0.8 0.0 .01) 
		 (.15 ehh.shp "pistol.snd" 523.0 0.8 0.0 .01) 
		 (.05 mmm.shp "pistol.snd" 523.0 0.8 0.0 .01) 
		 (.15 mmm.shp "pistol.snd" 523.0 0.8 0.0 .01) 			      
		 (.10 mmm.shp "pistol.snd" 523.0 0.0 0.0 .01) )))

piano.ins

Scott Van Dyne's piano physical modeling instrument in clm.

Here is the header of the instrument and a short description of some of its parameters:

(definstrument (p :language :c :c-options "-c -O3")
  (&key
   (start 0.0)
   (duration 1.0)
   (keyNum 60.0)
   (strike-velocity 0.5)
   (pedal-down nil)
   (release-time-margin 0.75)
   (amp .5)
;;slider controls
   (detuningFactor 1.0)
   (detuningFactor-table '())
   (stiffnessFactor 1.0)
   (stiffnessFactor-table '())
   (pedalPresenceFactor .3)
   (longitudinalMode 10.5)
   (StrikePositionInvFac -0.9)
   (singleStringDecayRateFactor 1.0)
;; parameter tables indexed by keyNum
;; NB: you can override the loudPole-table by directly setting :loudPole to a value
   loudPole (loudPole-table default-loudPole-table)
   softPole (softPole-table default-softPole-table)
   loudGain (loudGain-table default-loudGain-table)
   softGain (softGain-table default-softGain-table)
   strikePosition (strikePosition-table default-strikePosition-table)
   detuning2 (detuning2-table default-detuning2-table)
   detuning3 (detuning3-table default-detuning3-table)
   stiffnessCoefficient (stiffnessCoefficient-table default-stiffnessCoefficient-table)
   singleStringDecayRate (singleStringDecayRate-table default-singleStringDecayRate-table)
   singleStringZero (singleStringZero-table default-singleStringZero-table)
   singleStringPole (singleStringPole-table default-singleStringPole-table)
   releaseLoopGain (releaseLoopGain-table default-releaseLoopGain-table)
   DryTapFiltCoefT60 (DryTapFiltCoefT60-table default-DryTapFiltCoefT60-table)
   DryTapFiltCoefTarget (DryTapFiltCoefTarget-table default-DryTapFiltCoefTarget-table)
   DryTapFiltCoefCurrent (DryTapFiltCoefCurrent-table default-DryTapFiltCoefCurrent-table)
   DryTapAmpT60 (DryTapAmpT60-table default-DryTapAmpT60-table)
   sustainPedalLevel (sustainPedalLevel-table default-sustainPedalLevel-table)
   pedalResonancePole (pedalResonancePole-table default-pedalResonancePole-table)
   pedalEnvelopeT60 (pedalEnvelopeT60-table default-pedalEnvelopeT60-table)
   soundboardCutoffT60 (soundboardCutoffT60-table default-soundboardCutoffT60-table)
   DryPedalResonanceFactor (DryPedalResonanceFactor-table default-DryPedalResonanceFactor-table)
   unaCordaGain (unaCordaGain-table default-unaCordaGain-table))

Some key parameters

start 0.0
start time in seconds
duration 1.0
duration in seconds of the note
keyNum 60.0
key number; middleC=60: can use the fractional part to detune
strike-velocity 0.5
corresponding normalized velocities (range: 0.0 ... 1.0)
pedal-down nil
set to t for sustain pedal down... pedal-down-times not yet implemented
release-time-margin 0.75
extra compute time allowed beyond duration to allow transients to decay to cero
amp .5
amp scale of noise inputs
detuningFactor-table '()
if there is a detuning table specified interpolate the detuning factor by using hte keyNum as input (the detuning factor is used in multiple string notes to slightly detune the second and third strings).
detuningFactor 1.0
if there is no detuning table specified then use this constant as the detuning factor
stiffnessCoefficient-table '()
lookup table for stiffness of strings (interpolated by keyNum). 0.0 to 1.0 is less stiff, 1.0 to 2.0 is more stiff...
stiffnessCoefficient 1.0
constant stiffness, used only if there is no stiffness table present
pedalPresenceFactor .3
longitudinalMode 10.5
StrikePositionInvFac -0.9
singleStringDecayRateFactor 1.0
DryPedalResonanceFactor .25
0 is no open string resonance; 1.0 is about full resonance of dampers raised; can be greater than 1.0
Some examples...

Normal...

(with-sound (:output "/zap/thnormal.snd")
   (loop for i from 0 to 7 do
      (p
       (* i .5)
       :duration .5
       :keyNum (+ 24 (* 12 i))
       :strike-velocity .5            ; 0 to 1, 0 is softest played note, 1 is loud note
       :amp .4			      ;overall volume level
       :DryPedalResonanceFactor .25   ;0 no open string resonance
				      ;1.0 is about full resonance of dampers raised
				      ;can be greater than 1.0
       )))

Detuning and stiffness...

(with-sound (:output "/zap/thstiff.snd")
   (loop for i from 0 to 7 do
      (p
       (* i .5)
       :duration .5
       :keyNum (+ 24 (* 12 i))
       :strike-velocity .5            ;0 to 1, 0 is softest played note, 1 is loud note
       :amp .4                        ;overall volume level
       :DryPedalResonanceFactor .25   ;0 no open string resonance
				      ;1.0 is about full resonance of dampers raised
				      ;can be greater than 1.0
    ;;modification to do detunedness
       :detuningFactor-table '(24 5 36 7.0 48 7.5 60 12.0 72 20 84 30 96 100 108 300)
          ;scales the above detuning values
	  ;  so 1.0 is nominal detuning
	  ;  0.0 is exactly in tune (no two stage decay...)
	  ;  > 1.0 is out of tune...

    ;;modification to do stiffness
       :stiffnessFactor-table '(21 1.5 24 1.5 36 1.5 48 1.5 60 1.4 72 1.3 84 1.2 96 1.0 108 1.0)
          ;0.0 to 1.0 is less stiff, 1.0 to 2.0 is more stiff...
       )))

Overdamped...

(with-sound (:output "/zap/thdamped.snd")
   (loop for i from 0 to 7 do
      (p
       (* i .5)
       :duration .5
       :keyNum (+ 24 (* 12 i))
       :strike-velocity .5              ;0 to 1, 0 is softest played note, 1 is loud note
       :amp .4                          ;overall volume level
       :DryPedalResonanceFactor .25     ;0 no open string resonance
					;1.0 is about full resonance of dampers raised
					;can be greater than 1.0
       
       ;;modifications to do damped sounds
       :singleStringDecayRate-table '(21 -5 24.000 -5.000 36.000 -5.4 41.953 -5.867 
                                      48.173 -7.113 53.818 -8.016 59.693 -8.875 66.605 -9.434 
                                      73.056 -10.035 78.931 -10.293 84.000 -12.185)
       :singleStringPole-table '(21 .8 24 0.7  36.000 .6 48 .5 60 .3 84 .1 96 .03 108 .03)
       :stiffnessCoefficient-table '(21.000 -0.920 24.000 -0.900 36.000 -0.700 48.000 -0.250 
                                     60.000 -0.100 75.179 -0.040 82.986 -0.040 92.240 .3 
                                     96.000 .5 99.000 .7 108.000 .7)
				     ;these are the actual allpass coefficients modified here
				     ;to allow dampedness at hig freqs
       )))

prc-toolkit95.lisp

Perry Cook's physical modelling toolkit translated to clm.

Karplus Strong synthesis

(defcinstrument plucky (beg dur freq amplitude &optional (maxA 1.0))

Mandatory and optional parameters

beg
starting time in seconds
dur
duration in seconds
freq
frequency in hertz
amplitude
amplitude (from 0 to 1)
maxA
amplitude of the initial noise component

Bowed string

(defcinstrument bow (beg dur frq amplitude &optional (maxA 1.0))
NOTE: freq is off in this one (in PRC's original also)

Mandatory and optional parameters

beg
starting time in seconds
dur
duration in seconds
freq
frequency in hertz
amplitude
amplitude (from 0 to 1)
maxA
maximum velocity

Wind instruments

(defcinstrument brass (beg dur freq amplitude &optional (maxA 1.0))

(defcinstrument clarinet (beg dur freq amplitude &optional (maxA 1.0))

(defcinstrument flute (beg dur freq amplitude &optional (maxA 1.0))

Mandatory and optional parameters

beg
starting time in seconds
dur
duration in seconds
freq
frequency in hertz
amplitude
amplitude (from 0 to 1)
maxA
maximum velocity

pluck.ins

The Karplus-Strong algorithm as extended by David Jaffe and Julius Smith

(definstrument pluck (start dur freq amp
			    &key
			    (weighting 0.9)
			    (lossfact 0.99)
			    (decaytime 6)
			    (attacktime 0.01))

Mandatory and key parameters

start
starting time in seconds
dur
duration in seconds
freq
frequency in hertz
amp
amplitude (from 0 to 1)
weighting 0.9
weighting is the ratio of the once-delayed to the twice-delayed samples. It defaults to .5=shortest decay. anything other than .5 = longer decay. Must be between 0 and less than 1.0.
lossfact 0.99
lossfact can be used to shorten decays. Most useful values are between .8 and 1.0.

Assignment

Make Sheila sing a tune (Sheila is the name of Perry Cook's virtual physically modelled singer).


©1997/98 Fernando Lopez-Lezcano. All Rights Reserved.
nando@ccrma.stanford.edu