cmpt 318: lecture 12 physical modeling synthesistamaras/physmodeling/physmodeling.pdf · physical...
TRANSCRIPT
CMPT 318: Lecture 12Physical Modeling Synthesis
Tamara Smyth, [email protected] of Computing Science,
Simon Fraser University
March 22, 2006
1
Physical Modeling
• While the synthesis techniques we’ve been studying todate (AM, FM, waveshaping, additive and subtractivesynthesis etc), simulate sounds by reproducing asignal’s spectral content (analysis and thenresynthesis), physical models are based onmathematical descriptions of acoustic systemsthemselves.
• Though there is a strong tendency to model existingmusical instruments, physical modeling techniquescan be used to simulate any acoustic system.
• Modeling musical instruments can give us moreinsight in how the instrument functions, and allows usto extend the instrument in ways that would not bepossible “in the real world”.
• Once a system is digitally simulated, we are lessconstrained by scientific reality.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 2
Why physical modeling?
Control Parameters
• One of the strength of physical modeling lies in themore intuitive control parameters. Because they arebased on real instruments, the control parameterstend to be physical, and often more easily related tothe effect on the produced sound.
• If you try create a horn sound that has the variationin spectral content when played with different blowingpressures, you may have a very hard time figuring outwhich parameters to change in an FM synthesisalgorithm. With a good physical model and a windcontroller, all you have to do is increase blowingpressure at the input, and the sound produced willrespond accordingly.
Less Data Requirement
• Physical modeling is quite flexible and a singlealgorithm can achieve a variety of sounds, withoutrequiring more memory—unlike many other synthesistechniques which are really only as good as the datathey have.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 3
• Once a physical model is complete, it’s range ofsounds is produced by changing the parameters—notmy adding more complexity.
• If we have a physical model of a musical instrument,it’s very easy to extend the instrument in ways thatwould either not be possible or convenient in a realworld (like for instance, changing the length or shapeof the bore on a wind instrument to dimensions whichwould not be possible for a human to handle).
• Sound approaches acoustic quality
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 4
Virtual Musical Instruments
Plucked and Struck Wind Instruments
Classical guitar Trumpet
Harpsichord Tenor Saxophone
Piano Oboe and bassoon
Bowed Strings Electric Guitars
Double bass Bass pickup
Viola Distortion + feedback
Violin Wah-wah effect
A complete colloection of physical modelling soundexamples is available at http://www-ccrma.stanford.edu/̃jos/waveguide/Sound Examples.html
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 5
Physical vs. Signal Based Models
Physical Modelling Signal-Based Models
Case by case Same approach for all sounds
Represents sound source Represents sound receiver
Compact descriptions Large memory requirements
Attacks are natural Attacks are more difficult
Efficient expressivity Limited expressivity,(requires mapping“layer”)
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 6
A Very Brief Introduction to MusicalAcoustics
• Recall that sound is a wave which is created byvibrating objects and propagated through a mediumfrom one location to another.
• The basis for understanding physical modeling usingwaveguide synthesis is the physics of waves—and inparticular, mechanical waves.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 7
Mechanical Waves
• A mechanical wave can be described as a disturbancethat travels through a medium, transporting energyfrom one location to another location.
• The medium is simply the material through which thedisturbance is moving; it can be thought of as a seriesof interacting particles and can take the form of agas, liquid or solid.
• We will focus on the simplest case which is thetraveling wave.
• A traveling wave is any kind of wave whichpropagates in a single direction, i.e. along onedimension, with negligible change in shape.
• There are two basic types of wave motion fortravelling waves:
1. Longitudinal waves
2. Transverse waves
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 8
Traveling Waves
Longitudinal Wave
Particle displacement is parallel to the direction of wavepropagation.
Figure 1: Longitudinal wave. Animation, courtesy of Dr. Dan Russell, Kettering University,available on class website.
Transverse Wave
Particle displacement is perpendicular to the direction ofwave propagation.
Figure 2: Transverse Wave, animation courtesy of Dr. Dan Russell, Kettering University.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 9
Vibration in Musical Instruments
• Nearly all objects, when hit or struck or plucked orstrummed or somehow disturbed, will vibrate.
• If you drop a pencil on the floor, it will begin tovibrate.
• If you pluck a guitar string, it will begin to vibrate.
• If you blow over the top of a bottle, the air inside willvibrate.
• When each of these objects vibrate, they tend tovibrate at a particular frequency or a set offrequencies known as their natural frequency(ies).
• The natural frequency of a string can be changed bychanging its length (as we do with our fingers whenwe apply pressure on the string).
• Likewise in a trombone, we can make the tube longerand shorter, effectively changing the soundingfrequency.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 10
Standing Waves in Musical Instruments
• Very few objects vibrate at a single frequency.
• In many cases, the vibrations produce more complexwaveforms with a set of frequencies having a wholenumber mathematical relationships between them.That is, they are harmonics.
• Sometimes however, objects that vibrate at a set offrequencies that are not related by an integer and aretherefore less likely to produce a sounding pitch.
• The key to this phenomenon is understandingstanding wave patterns.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 11
Reflection and the Formation ofStanding Waves
• In a one dimensional medium, waves can propagate intwo directions.
• When a wave is confined to a given space along themedium, it will soon reach it’s end point, reflect andtravel back in the opposite direction.
• Depending on the end (boundary) condition, thereflection will either be inverted or remain unchanged.
Figure 3: Reflection of an impulse wave from a fixed end causes an inverse of the impulse.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 12
Interference and the Formation ofStanding Waves
• Reflection will cause both constructive and
destructive interference with the oncoming waves.
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−1
0
1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−1
0
1
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1−2
−1
0
1
2
Figure 4: Perfect construction and destructive interference causes the production of standingwaves.
• A standing wave is the pattern resulting from theperfectly timed interference of two waves (sometimesmore) of the same frequency with different directionsof travel within the same medium.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 13
Nodes and Antinodes
• The point at which there is no displacement is calleda node.
• Where there is maximum displacement is called anantinode.
Node Node Node Node Node
Antinode Antinode Antinode Antinode
Figure 5: Node-Antinode pattern.
• A standing waves is actually a pattern of nodes andantinodes.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 14
Standing Waves and Harmonics
• The addition of a node will likely require the additionof one or several antinode(s) to maintain the pattern.
• The shortes pattern with a hard-reflection at bothends is given by node-antinode-node (see firstharmonic).
• If we add another node to this pattern we will alsohave to add an antinode just before to obtain,node-antinode-node-antinode-node (see secondharmonic).
First Harmonic (fundamental frequency)Node Node
Antinode
Second HarmonicNode Node Node
Antinode Antinode
Third HarmonicNode Node Node Node
Antinode Antinode Antinode
Figure 6: Formation of Harmonics.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 15
Guitar String
• A guitar string, fixed at both ends (the nut and thebridge), has a number of frequencies at which it willnaturally vibrate, corresponding to the harmonics.
• If the length of a guitar string is known, thewavelength λ associated with each of the harmonicscan be found.
• The figure below gives the relationship between thewavelength of the harmonics and the string length.
L = 1/2 λ
L = λ
L = 3/2 λ
Figure 7: Guitar string.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 16
Open End Acoustic Tubes
• Wind instruments typically make use of an acoustictubes of varying lengths which often curve up onthemselves to conserve space (or other reasons). Thisdoesn’t, however, change their lengths!
• If both ends of the tube are open, then the tube issaid to contain an open end air column.
• The open ends are always pressure anti-nodes sinceair is free to oscillate.
L = 1/2 λ
L = λ
L = 3/2 λ
Figure 8: Open-open tube (eg. flute and wind chimes).
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 17
Closed End Acoustic Tubes
• The closed end acts as a fixed end which prevents theoscillation of air, and thus are always pressure nodes.
L = 1/4 λ
L = 3/4 λ
L = 5/4 λ
Figure 9: Closed-open tube (eg. clarinet) having first, third and fifth harmonics.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 18
Wave Equation
• Digital waveguide synthesis begins with D’Alembert’ssolution to the wave equation. The wave equation,given by
∂2y
∂t2= c2∂
2y
∂x2,
describes the displacement of the perfectly flexiblestring (without stiffness).
• D’Alembert observed that in a medium such as astring (or wind instrument), we find wave traveling tothe left and right along one dimension. He came upwith the generalized solution (or d’Alembert’ssolution) to the lossless, 1D, second order waveequation
y(t, x) = yr(t − x/c) + yl(t + x/c),
which means there are waves are traveling to the rightand left with velocity c.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 19
Digital Waveguides
• D’Alembert’s solution is given by
y(t, x) = yr(t − x/c) + yl(t + x/c),
• In sampling D’Alembert’s solution, we make thefollowing substitution
x −→ mX
x −→ nT
to obtain the equation for the digital waveguide
y(n,m) = yr(n − m) + yl(n + m).
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 20
Traveling Wave Simulation
Delay lines model acoustic propagation delay.
y(n−M)y(n)Delay by M samples
input sequence: 1, 2, 3, 4, 5, etc.
0 0 0 0 0 0 0 01 0
outin
M=3
0 0 0 0 0 0 0 01 M=3
in out
2
0 0 0 0 0 0 01 M=32 3
in out
0 0 0 0 0 01 M=32 3 4
inout
0 0 0 0 01 M=32 3 4 5
inout
output sequence: 0, 0, 0, 1, 2, etc.
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 21
Delay line in C
static double D[M]; /* initialized to zero */
static long ptr=0; /* read-write offset */
double delayline(double x)
{
double y = D[ptr]; /* read operation */
D[ptr++] = x; /* write operation */
if (ptr >= M) { ptr -= M; } /* wrap ptr */
return y;
}
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 22
Ideal Waveguide Simulation
• A digital waveguide is a bidirectional delay-linemodelling left and right travelling waves.
y(nT, 0) y(nT, ξ)
y+(n) y+(n-M)
y−(n-M)y−(n)
M sample delay
M sample delay
x=0 x=ξ x=L
y(nT,mX) = y+(n − M) + y−(n + M)
where T is the sampling period (time period betweensamples), and X is the spatial rate in m/s (X = cTwhere c is the wave velocity).
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 23
Waves on a String
• Simulating Displacement Traveling Waves on a String
-1output-1
H(ω)
String displacement
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 24
Practical Example
Pressure waves in an acoustic tube where L = 1.Sampling rate:
fs = 44100
Temporal sampling period:
T =1
44100
Spatial sampling period:
X = cT =340
44100= 7.7mm
Number of samples delay:
M =L
X=
1
cT=
1
0.0077= 130
CMPT 318: Fundamentals of Computerized Sound: Lecture 12 25