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. And a couple of examples by Perry Cook. See paper references at the beginning of the clm instrument. This instrument was translated by Bill from the original C code as implemented for Perry's thesis.

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

(definstrument 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):
  • dur: duration of the synthesis frame
  • shape: shape of the vocal tract
  • glot: glotal excitation
  • frequency: frequency of glotal source
  • glotamp: amplitude of the glotal component
  • noiseamp: amplitude of the noise component
  • vibramt: percentage of vibrato
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:

  • test.glt
  • loud.glt
  • soft.glt
  • wide4.glt
  • wide5.glt
  • greekdefault.glt
  • lowbass.glt
Vocal Tract Shapes

  • aa.shp
  • hh2.shp
  • dhh.shp
  • aah.shp
  • hhh.shp
  • ohh.shp
  • ah.shp
  • oo.shp
  • ahh.shp
  • ee-.shp
  • hoo.shp
  • ooo.shp
  • ee.shp
  • ih.shp
  • ee2.shp
  • ihh.shp
  • open.shp
  • thh.shp
  • aw.shp
  • eee.shp
  • tt+.shp
  • aww.shp
  • eee2.shp
  • jjj.shp
  • ttt.shp
  • bb2.shp
  • eh.shp
  • kk+.shp
  • pipe1.shp
  • tzz.shp
  • bbb.shp
  • ehh.shp
  • kk2.shp
  • pp+.shp
  • uhh.shp
  • big.shp
  • euu.shp
  • kkk.shp
  • ppp.shp
  • uu.shp
  • fff.shp
  • ll2.shp
  • uuu.shp
  • lll.shp
  • rolledr.shp
  • vvv.shp
  • rolledrc.shp
  • mmm.shp
  • rolledro.shp
  • breath.shp
  • moo.shp
  • rr2.shp
  • chh.shp
  • gg2.shp
  • nng.shp
  • rrr.shp
  • wsp.shp
  • ggg.shp
  • nnn.shp
  • sh2.shp
  • xx2.shp
  • dd2.shp
  • ggg1.shp
  • noisahh.shp
  • shh.shp
  • xxx.shp
  • ddd.shp
  • gxx.shp
  • none.shp
  • sss.shp
  • zzz.shp
More definitions for both shapes and glots can be found in the following directories:

  • /usr/ccrma/dist/PRCStuff/SPASM/SPASM/glots
  • /usr/ccrma/dist/PRCStuff/SPASM/SPASM/shapes
  • /usr/ccrma/dist/PRCStuff/SPASM/BigLibrary/glots
  • /usr/ccrma/dist/PRCStuff/SPASM/BigLibrary/shapes
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 for the singer, I guess (you will need to find a gunshot sample if you want to run this code).

(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
  (&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).
  • 1.0 is nominal detuning
  • 0.0 is exactly in tune (no two stage decay...)
  • > 1.0 is out of tune...
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 (:srate 44100 :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 (:srate 44100 :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 (:srate 44100: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

(definstrument 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.

flute.ins

A stereo flute by Nicky Hind.

maraca.ins

Perry Cook's maraca from CMJ vol 21 no 3 (Fall 97) p 44.

Used by Juan Reyes in the piece "wadimusa or the monteria hat" (example played in class)


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