DIGITAL FILTER APPLICATIONS TO MODELING WAVE
Transcription
DIGITAL FILTER APPLICATIONS TO MODELING WAVE
DIGITAL FILTER APPLICATIONS TO MODELING WAVE PROPAGATION IN SPRINGS, STRINGS, MEMBRANES AND ACOUSTICAL SPACE a dissertation submitted to the department of music and the committee on graduate studies of stanford university in partial fulfillment of the requirements for the degree of doctor of philosophy Scott A. Van Duyne June 2007 c Copyright 2007 by Scott A. Van Duyne ! All Rights Reserved ii I certify that I have read this dissertation and that in my opinion it is fully adequate, in scope and quality, as a dissertation for the degree of Doctor of Philosophy. Chris Chafe (Principal Adviser) I certify that I have read this dissertation and that in my opinion it is fully adequate, in scope and quality, as a dissertation for the degree of Doctor of Philosophy. Jonathan Berger I certify that I have read this dissertation and that in my opinion it is fully adequate, in scope and quality, as a dissertation for the degree of Doctor of Philosophy. David Berners I certify that I have read this dissertation and that in my opinion it is fully adequate, in scope and quality, as a dissertation for the degree of Doctor of Philosophy. Jonathan Abel Approved for the University Committee on Graduate Studies: iii Preface This work is primarily archival in nature, documenting the research I did at CCRMA in the 1990s. Although new or unpublished material is presented herein, most of the research was completed, published, presented publicly and/or patented by me by 1999, at which time I stopped out of Stanford to pursue a start-up company in the valley. I have only now returned to my degree program in 2007. I have focused the narrative of this dissertation on the tools and methods of spectral analysis of hyperbolic differential equations, finite differences, multi-dimensional waveguide structures, linear and nonlinear coupling of modes and strings, linear and nonlinear excitation models and the basic model calibration methods. I rely heavily on my previously published works, internal reports, patent applications, etc. which are cited throughout as appropriate. iv Acknowledgments My most profound appreciation goes to these few: Jean-Claude Risset, who believed in me from the start, and who gave me my first true window into what computer music was about; John Chowning, who created the CCRMA culture of the 80s and 90s which was so fertile for so long to my random-walk research; John Pierce, who rolled up his sleeves with me on the passive nonlinearity, and gave me a glimpse at how the engineering giants of another time built the world we live in; Max Mathews, whose unshakable enthusiasm for hands-on exploration was a daily inspiration; Julius Smith, who provided me an introduction to the nuts and bolts of physical modeling; Chris Chafe, who never gave up on me, and whose help and advice was instrumental in getting me back on track after an extended detour; Dave Berners, Jonathan Abel and Jonathan Berger, who served beyond the call of duty on my various academic review committees; David Jaffe, Tim Stilson, and Sean Costello, fellow travelers who stuck with me beyond reason through SynthBuilder, SynthCore, Staccato Systems, SoundMAX, SMartTools, and VisualAudio till the very last day; and my wife Becky, who lovingly waited 17 years for me to finish up my degree. v Contents Preface iv Acknowledgments v 1 Traveling Wave Warm-Ups 1 1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 The Classical Wave Equation . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2.1 A Physical Derivation . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2.2 The Traveling-Wave Solution . . . . . . . . . . . . . . . . . . . . . . 4 Transforming the Wave Equation . . . . . . . . . . . . . . . . . . . . . . . . 5 1.3.1 A Frequency Domain Approach . . . . . . . . . . . . . . . . . . . . . 5 1.3.2 The Differential Equation as a Second-Order System . . . . . . . . . 6 1.3.3 Introduction to Spectral Amplification Factors . . . . . . . . . . . . 7 1.3.4 Allowed Frequencies on an Ideal String with Rigid Terminations . . 8 The Digital Waveguide Difference . . . . . . . . . . . . . . . . . . . . . . . . 9 1.4.1 Bi-Directional Delay Lines . . . . . . . . . . . . . . . . . . . . . . . . 9 1.4.2 Fractional Delay Line Lengths . . . . . . . . . . . . . . . . . . . . . 11 1.4.3 Analysis of the Internal Waveguide Filter Signals . . . . . . . . . . . 14 1.4.4 The Equivalent Finite Difference Scheme 1.4.5 Converging to the Differential Equation . . . . . . . . . . . . . . . . 17 1.3 1.4 1.5 . . . . . . . . . . . . . . . 14 Transforming the Waveguide Difference Scheme . . . . . . . . . . . . . . . . 19 1.5.1 A Frequency Domain Approach . . . . . . . . . . . . . . . . . . . . . 19 1.5.2 The Finite Difference as a Second-Order System . . . . . . . . . . . 20 1.5.3 Discrete Spectral Amplification Factors . . . . . . . . . . . . . . . . 20 1.5.4 Von Neumann Analysis . . . . . . . . . . . . . . . . . . . . . . . . . 21 vi 1.6 A More General Difference for c "= 1 . . . . . . . . . . . . . . . . . . . . . . 21 1.6.1 Deriving the General Difference . . . . . . . . . . . . . . . . . . . . . 22 1.6.2 Spectral Analysis of the General Difference . . . . . . . . . . . . . . 23 1.6.3 Numerical Instability when c > 1 . . . . . . . . . . . . . . . . . . . . 24 1.6.4 Dispersion Error when c < 1 . . . . . . . . . . . . . . . . . . . . . . 26 1.6.5 Digital Waveguide Structure Models Optimal Wave Speed . . . . . . 28 2 Inharmonicity, Decay and Coupling 2.1 2.2 2.3 30 Effects of Internal Loss and Stiffness on Traveling Waves . . . . . . . . . . . 30 2.1.1 The Spectral Amplification Factors . . . . . . . . . . . . . . . . . . . 30 2.1.2 Commuted Summary Filter Implementation . . . . . . . . . . . . . . 31 Stiffness in the Wave Equation . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.2.1 The Bar Equation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.2.2 The Stiff String Equation . . . . . . . . . . . . . . . . . . . . . . . . 33 2.2.3 A Piano String Example . . . . . . . . . . . . . . . . . . . . . . . . . 35 2.2.4 The More General Lossless Equation . . . . . . . . . . . . . . . . . . 36 Modeling Stiffness in the Digital Waveguide . . . . . . . . . . . . . . . . . . 39 2.3.1 Introducing Stiffness with Allpass Filters . . . . . . . . . . . . . . . 39 2.3.2 Rate of Stretching in the Partials of Stiff Strings . . . . . . . . . . . 40 2.3.3 Rate of Stretching in the Modes of a Delay Loop with Cascaded One-Pole Allpass Filters . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.4 2.5 2.6 Internal Loss in the Wave Equation . . . . . . . . . . . . . . . . . . . . . . . 44 2.4.1 Physically Valid Forms of the 1-D Isotropic Wave Equation . . . . . 44 2.4.2 Parameterizing the Wave Equation from Measured Data . . . . . . . 47 Loss and Dispersion at the Termination . . . . . . . . . . . . . . . . . . . . 48 2.5.1 Lumped Impedance . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 2.5.2 Force Waves, Velocity Waves, and Wave Impedance . . . . . . . . . 48 2.5.3 Terminating a String at a Lumped Impedance . . . . . . . . . . . . 49 2.5.4 Interpreting Stiffness Allpasses as a Termination Impedance . . . . . 51 Calibrating the Digital Waveguide String Model . . . . . . . . . . . . . . . . 53 2.6.1 The Summarized Loop Model . . . . . . . . . . . . . . . . . . . . . . 53 2.6.2 Calibration Approach . . . . . . . . . . . . . . . . . . . . . . . . . . 54 2.6.3 Obtaining the Data Directly from an Audio Recording . . . . . . . . 55 vii 2.7 2.8 2.6.4 Calibrating Loop Stiffness from Recorded Data . . . . . . . . . . . . 56 2.6.5 Calibrating Loop Loss From Recorded Data . . . . . . . . . . . . . . 59 Coupled Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 2.7.1 Two-Stage Decay Rate . . . . . . . . . . . . . . . . . . . . . . . . . . 63 2.7.2 The Loaded Scattering Junction . . . . . . . . . . . . . . . . . . . . 66 2.7.3 The Coupled String Model . . . . . . . . . . . . . . . . . . . . . . . 67 Calibrating the Coupling Filter . . . . . . . . . . . . . . . . . . . . . . . . . 69 2.8.1 First Method: Deducing Rb from Single-String Decay Rates 2.8.2 Second Method: Deducing Rb from First-Stage Decay Rates . . . . 71 3 The Waveguide Mesh . . . . 70 74 3.1 Traveling-Wave Solution to the Ideal Membrane Equation . . . . . . . . . . 75 3.2 The Membrane Equation in the Frequency Domain . . . . . . . . . . . . . . 75 3.3 3.4 3.2.1 Polar Coordinate View of the 2-D Fourier Transform . . . . . . . . . 76 3.2.2 Solving the Wave Equation . . . . . . . . . . . . . . . . . . . . . . . 77 The 2-D Digital Waveguide Mesh . . . . . . . . . . . . . . . . . . . . . . . . 78 3.3.1 The Lossless Scattering Junction . . . . . . . . . . . . . . . . . . . . 80 3.3.2 The Birth of Traveling Plane Waves . . . . . . . . . . . . . . . . . . 82 3.3.3 Terminating the Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Implementation Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 3.4.1 Empirical Evaluation of the Mesh . . . . . . . . . . . . . . . . . . . 87 3.4.2 Mirroring of the Spectrum . . . . . . . . . . . . . . . . . . . . . . . . 90 3.5 Dispersion in Plates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 3.6 Why the Thing Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 3.7 3.6.1 Finite Difference Scheme Equivalence . . . . . . . . . . . . . . . . . 94 3.6.2 The Difference as a Standard 2-D Scheme . . . . . . . . . . . . . . . 95 3.6.3 Converging to the 2-D Wave Equation . . . . . . . . . . . . . . . . . 96 Von Neumann Error Analysis in 2-D . . . . . . . . . . . . . . . . . . . . . . 99 3.7.1 Solving the Difference Directly in the Frequency Domain 3.7.2 Evaluation of the Error . . . . . . . . . . . . . . . . . . . . . . . . . 101 4 Other Mesh Structures 4.1 . . . . . . 99 105 Meshes Constructed of N-Port Scattering Junctions . . . . . . . . . . . . . . 105 4.1.1 Lossless N-Port Scattering Junctions . . . . . . . . . . . . . . . . . . 105 viii 4.1.2 Connecting Two Junctions with a Bidirectional Unit Delay . . . . . 106 4.1.3 The General Finite Difference Scheme . . . . . . . . . . . . . . . . . 108 4.1.4 Generalized Amplification Factors . . . . . . . . . . . . . . . . . . . 109 4.2 The 8-Port 2-D Multiply-Free Mesh . . . . . . . . . . . . . . . . . . . . . . 111 4.3 The 6-Port 2-D Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 4.3.1 4.4 4.5 4.6 The 6-Port 2-D Multiply-Free Non-Isotropic Mesh . . . . . . . . . . 113 The 6-Port 3-D Rectilinear Mesh . . . . . . . . . . . . . . . . . . . . . . . . 113 4.4.1 Animating the 6-Port 3-D Mesh . . . . . . . . . . . . . . . . . . . . 115 4.4.2 Dispersion Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 The 3-Port 2-D Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 4.5.1 Alternating Symmetry: Two Time Steps Needed . . . . . . . . . . . 120 4.5.2 Computing the Finite Difference . . . . . . . . . . . . . . . . . . . . 121 4.5.3 Verifying the FDA Converges to the PDE . . . . . . . . . . . . . . . 121 4.5.4 Dispersion Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 4.5.5 Animating the 3-Port 2-D Mesh . . . . . . . . . . . . . . . . . . . . 121 The 4-Port 3-D Tetrahedral Mesh . . . . . . . . . . . . . . . . . . . . . . . . 122 4.6.1 Motivation for the Tetrahedral Mesh . . . . . . . . . . . . . . . . . . 122 4.6.2 The Tetrahedral Difference . . . . . . . . . . . . . . . . . . . . . . . 124 4.6.3 Converging to the PDE . . . . . . . . . . . . . . . . . . . . . . . . . 128 4.6.4 Dispersion Analysis 4.6.5 Benefits of the Tetrahedral Mesh Over the Rectilinear Mesh . . . . . 133 . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 5 The Passive Nonlinear Filter 134 5.1 Nonlinearity in Musical Instruments: Spectral Energy Spreading . . . . . . 134 5.2 Memoryless Nonlinearities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 5.3 Passive Nonlinearity: The Physical Concept . . . . . . . . . . . . . . . . . . 137 5.4 5.3.1 First Attempt: The Bent Spring Termination . . . . . . . . . . . . . 137 5.3.2 Second Attempt: The Mass-Spring System with Alternating k . . . 137 5.3.3 The Equivalent Electrical Circuit: Nonlinear Inductor or Capacitor . 140 5.3.4 String Terminated with a Nonlinear Spring . . . . . . . . . . . . . . 140 Nonlinear Filter Derivation . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 5.4.1 The Simple Linear Spring . . . . . . . . . . . . . . . . . . . . . . . . 143 5.4.2 Terminating a String with a Spring . . . . . . . . . . . . . . . . . . . 143 ix 5.5 5.4.3 Bilinear Transform from s-Plane to z-Plane . . . . . . . . . . . . . . 144 5.4.4 Making the Spring Nonlinear . . . . . . . . . . . . . . . . . . . . . . 145 5.4.5 Finding the Digitally Correct Coefficient Gating Signal 5.4.6 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 . . . . . . . 145 Why It Works from a Phase Modulation Perspective . . . . . . . . . . . . . 148 5.5.1 Phase Response of the One–Pole Allpass Filter . . . . . . . . . . . . 149 5.5.2 Sinusoidal Variation of the Coefficient . . . . . . . . . . . . . . . . . 150 5.5.3 Step Variation of the Coefficient . . . . . . . . . . . . . . . . . . . . 152 5.6 Simple Models of Spectrally Active Sounds . . . . . . . . . . . . . . . . . . 154 5.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 6 The Wave-Decomposed Mass-Spring 157 6.1 Lumped Systems and Distributed Systems . . . . . . . . . . . . . . . . . . . 157 6.2 The Tuned One-Pole Allpass Feedback Loop . . . . . . . . . . . . . . . . . . 158 6.2.1 The Wave-Decomposed Mass-Spring Oscillator . . . . . . . . . . . . 159 6.2.2 Coupling the Oscillators with a Scattering Junction . . . . . . . . . 163 6.2.3 Calibrating the Coupling Filter . . . . . . . . . . . . . . . . . . . . . 165 6.3 Mass-Spring Oscillator vs. Mass-Spring Hammer . . . . . . . . . . . . . . . 166 6.4 Motivation for the Hammer . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 6.5 The Hammer Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 6.6 6.7 6.5.1 Overview of the Digital Waveguide String and Hammer Model . . . 168 6.5.2 The Mass and Spring System . . . . . . . . . . . . . . . . . . . . . . 169 6.5.3 Traveling Wave Decomposition of the Lumped System . . . . . . . . 171 6.5.4 Scattering Junction Connection . . . . . . . . . . . . . . . . . . . . . 175 Making the Felt Nonlinear . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 6.6.1 The Lossless Digital Model . . . . . . . . . . . . . . . . . . . . . . . 179 6.6.2 Hysteresis Loss in the Felt . . . . . . . . . . . . . . . . . . . . . . . . 180 Empirical Evaluation with Published Data . . . . . . . . . . . . . . . . . . . 184 7 The Commutable Piano Hammer 186 7.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 7.2 Linearizing the Piano Hammer . . . . . . . . . . . . . . . . . . . . . . . . . 187 7.2.1 Impedance of the Un-Terminated Ideal String . . . . . . . . . . . . . 189 7.2.2 Impedance of the Terminated Ideal String . . . . . . . . . . . . . . . 189 x 7.2.3 Impedance of the Ideal Linear Hammer . . . . . . . . . . . . . . . . 190 7.2.4 Connecting the Hammer to the String . . . . . . . . . . . . . . . . . 190 7.2.5 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 7.3 Analysis of Real Hammer-String Interaction Data . . . . . . . . . . . . . . . 193 7.4 Spectral Modeling Approach to the Multi-Pulse Effect . . . . . . . . . . . . 195 7.5 Excitation Synthesis with Nonlinearly Filtered Noise . . . . . . . . . . . . . 196 7.5.1 7.6 Synthesizing Sustain Pedal Effect . . . . . . . . . . . . . . . . . . . . 200 Wrap Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 A Pick-Up Point Modulation 202 A.1 Implementation of a Variable Pick-Up Point on a Waveguide String Model with FM/AM Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 A.2 Background and Description of the Model . . . . . . . . . . . . . . . . . . . 202 A.3 Moving the Pick-Up Point . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 A.4 Modulating the Pick-Up Position at Audio Rates . . . . . . . . . . . . . . . 210 A.5 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 B Pitchbendable Allpass Interpolation 214 B.1 The Problem Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 B.2 Puzzle Pieces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 B.2.1 Minimizing the Transient Effect . . . . . . . . . . . . . . . . . . . . . 215 B.2.2 Legato Crossfade of Digital Waveguide String Models . . . . . . . . 215 B.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 B.3.1 Psychoacoustical Detail . . . . . . . . . . . . . . . . . . . . . . . . . 217 B.3.2 A DSP Implementation Trick . . . . . . . . . . . . . . . . . . . . . . 218 C Stiffness Using Regions of FM 219 C.1 Analysis/Synthesis Model of the Spectral Structure . . . . . . . . . . . . . . 219 C.2 Construction of Decay Envelopes . . . . . . . . . . . . . . . . . . . . . . . . 223 C.3 Fine Points: Beating in the Partials . . . . . . . . . . . . . . . . . . . . . . 224 C.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 xi List of Figures 1.1 Transverse Force Component of String with Constant Tension K . . . . . . 1.2 The Digital Waveguide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.3 Linearly Interpolated Delay Line . . . . . . . . . . . . . . . . . . . . . . . . 11 1.4 Allpass Interpolated Delay Line . . . . . . . . . . . . . . . . . . . . . . . . . 12 1.5 Phase Response of One-Pole Allpass . . . . . . . . . . . . . . . . . . . . . . 13 1.6 Close-Up of the Digital Waveguide . . . . . . . . . . . . . . . . . . . . . . . 15 1.7 Magnitude of Spectral Amplification Factor, |gω+ | . . . . . . . . . . . . . . . 25 1.8 3 Normalized Frequency-Dependent Traveling-Wave Speed . . . . . . . . . . . 28 2.1 Lumped Implementation of the Lossy Dispersive Traveling Wave . . . . . . 31 2.2 Measured Partials from an A0 Piano String . . . . . . . . . . . . . . . . . . 36 2.3 Measured Frequency Distance Between the A0 Partials . . . . . . . . . . . . 37 2.4 Rate of Stretching for Hypothetical A0 . . . . . . . . . . . . . . . . . . . . . 41 2.5 Dispersive Delay Loop System . . . . . . . . . . . . . . . . . . . . . . . . . . 42 2.6 Modes on z −N H(z) vs. Modes on z −(N +1) . . . . . . . . . . . . . . . . . . . 43 2.7 Stretching of Partials on a Delay Loop . . . . . . . . . . . . . . . . . . . . . 44 2.8 String Terminated by Simple Spring . . . . . . . . . . . . . . . . . . . . . . 49 2.9 Mass/Spring Chain String Terminations . . . . . . . . . . . . . . . . . . . . 51 2.10 Waveguide String Loop Model Including Loss, Dispersion, and Yielding Terminations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 2.11 Simplified String Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 2.12 First Allpass Parameterization Optimization Method . . . . . . . . . . . . . 57 2.13 Parallel Computation Structure for Cascaded Allpasses . . . . . . . . . . . . 58 2.14 Measured Decay Rates in C5 Piano Tone xii . . . . . . . . . . . . . . . . . . . 61 2.15 Modes of Two Identical Strings Coupled Together by a Bridge: Reactive Coupling (left graph) and Resistive Coupling (right graph). Adapted from (Fletcher and Rossing, 1991). . . . . . . . . . . . . . . . . . . . . . . . . . . 63 2.16 Decay Trajectories Measured on Piano G4 Tone: Single String vs. Three String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 2.17 G4 Decay Trajectories Measured on Synthesized G4 Piano Tone: Tuned Exactly vs. Slight Detuning . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 2.18 Two Strings Coupled at a Lumped Impedance . . . . . . . . . . . . . . . . . 66 2.19 Three Piano Strings Coupled at a Bridge Termination . . . . . . . . . . . . 68 2.20 G4 Piano Tone: Single- and Triple-String Decay Rates . . . . . . . . . . . . 72 3.1 The 2-D Digital Waveguide Mesh . . . . . . . . . . . . . . . . . . . . . . . . 79 3.2 Four-Way Scattering Junction . . . . . . . . . . . . . . . . . . . . . . . . . . 80 3.3 Rigidly Terminated Membrane . . . . . . . . . . . . . . . . . . . . . . . . . . 83 3.4 Open Termination of the Mesh . . . . . . . . . . . . . . . . . . . . . . . . . 84 3.5 Mesh Terminated with Arbitrary Wave Transfer Functions . . . . . . . . . . 85 3.6 Wave Propagation on the Mesh . . . . . . . . . . . . . . . . . . . . . . . . . 88 3.7 Comparison of Theoretical Modes on a Square Membrane (shown above) and Measured Modes on a 10 × 10 Waveguide Mesh (shown below) . . . . . 89 3.8 Spectrum Reflecting Around π/4 . . . . . . . . . . . . . . . . . . . . . . . . 91 3.9 Stretching Modes on the Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . 92 3.10 Detail View of the 4-Port Rectilinear Waveguide Mesh . . . . . . . . . . . . 93 3.11 Frequency-Dependent Dispersion in the 4-Port Rectilinear Mesh. Vertical axis is fraction of full speed for that spatial frequency. . . . . . . . . . . . . 101 3.12 Frequency-Dependent Dispersion in the 4-Port Rectilinear Mesh. Contour lines are shown at 1% intervals. . . . . . . . . . . . . . . . . . . . . . . . . . 103 3.13 Time-Domain View of Dispersion in the 4-Port Rectilinear Mesh. . . . . . . 104 4.1 The Lossless N-Port Scattering Junction . . . . . . . . . . . . . . . . . . . . 106 4.2 Scattering Junctions Connected by a Bidirectional Unit Delay . . . . . . . . 107 4.3 8-Port Rectilinear Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 4.4 Dispersion in the 8-Port Rectilinear Mesh . . . . . . . . . . . . . . . . . . . 111 4.5 6-Port Triangular Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 4.6 Dispersion in the 6-Port 2-D Mesh . . . . . . . . . . . . . . . . . . . . . . . 113 xiii 4.7 6-Port Mesh with Non-Isotropic Wave Impedance . . . . . . . . . . . . . . . 114 4.8 Dispersion in the Non-Isotropic 6-Port Mesh . . . . . . . . . . . . . . . . . 114 4.9 Structure of the 6-Port Rectilinear 3-D Mesh . . . . . . . . . . . . . . . . . 115 4.10 Animation of the 3-D Rectilinear Mesh Modeling Compression Wave Through a Tube . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 4.11 Rectilinear Dispersion: ωz = 0 . . . . . . . . . . . . . . . . . . . . . . . . . . 117 4.12 Rectilinear Dispersion: ωz = ωx . . . . . . . . . . . . . . . . . . . . . . . . . 117 4.13 Rectilinear Dispersion: |ω| = π/2 . . . . . . . . . . . . . . . . . . . . . . . . 118 4.14 The 3-Port 2-D Hexagonal Mesh . . . . . . . . . . . . . . . . . . . . . . . . 119 4.15 Close-up Showing Alternating Symmetry . . . . . . . . . . . . . . . . . . . . 120 4.16 Three-Port Dispersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 4.17 The Animated 3-way 2-D Hexagonal Mesh . . . . . . . . . . . . . . . . . . . 123 4.18 Methane: Tetrahedral Bonds on the Carbon Atom . . . . . . . . . . . . . . . 124 4.19 Diamond: The Tetrahedral Carbon Mesh . . . . . . . . . . . . . . . . . . . . 125 4.20 3-D Tetrahedral Mesh Structure . . . . . . . . . . . . . . . . . . . . . . . . . 126 4.21 Bi-Directional Delay Unit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 4.22 Tetrahedral Dispersion: ωx = 0 . . . . . . . . . . . . . . . . . . . . . . . . . 129 4.23 Tetrahedral Dispersion: ωy = 0 . . . . . . . . . . . . . . . . . . . . . . . . . 130 4.24 Tetrahedral Dispersion: ωz = 0 . . . . . . . . . . . . . . . . . . . . . . . . . 130 4.25 Tetrahedral Dispersion: |ω| = π/2 . . . . . . . . . . . . . . . . . . . . . . . . 131 5.1 Delay Loop with Square Law Nonlinearity . . . . . . . . . . . . . . . . . . . 136 5.2 String with Bent Springy Termination and Gong Viewed as Bent Plate . . . 138 5.3 Passive Nonlinear Mass/Spring Oscillator . . . . . . . . . . . . . . . . . . . 139 5.4 Equivalent Electrical Capacitance Circuit . . . . . . . . . . . . . . . . . . . . 139 5.5 Equivalent Electrical Inductance Circuit . . . . . . . . . . . . . . . . . . . . 140 5.6 String Terminated with Double Spring . . . . . . . . . . . . . . . . . . . . . 141 5.7 Nonlinearly Terminated Transmission Line . . . . . . . . . . . . . . . . . . 142 5.8 Simple Linear Spring System . . . . . . . . . . . . . . . . . . . . . . . . . . 143 5.9 String Terminated by Simple Spring . . . . . . . . . . . . . . . . . . . . . . 144 5.10 The Allpass Spring Termination . . . . . . . . . . . . . . . . . . . . . . . . . 145 5.11 Nonlinear String/Spring System . . . . . . . . . . . . . . . . . . . . . . . . . 148 5.12 Phase Response of the One–Pole Allpass Filter . . . . . . . . . . . . . . . . 149 xiv 5.13 Effect of Varying acenter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 5.14 Effect of Varying ∆a . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 5.15 Output Spectrum from Sinusoidally Driven, Sinusoidally-Modulated Allpass Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 5.16 Evolving Spectrum of String/PNF System . . . . . . . . . . . . . . . . . . . 152 5.17 Harmonic Loop with Lowpass Filter . . . . . . . . . . . . . . . . . . . . . . . 153 5.18 Harmonic Loop with Lowpass Filter and Passive Nonlinear Filter . . . . . . 153 5.19 Inharmonic Loop with Lowpass Filter . . . . . . . . . . . . . . . . . . . . . . 154 5.20 Inharmonic Loop with Lowpass Filter and Passive Nonlinear Filter . . . . . 154 6.1 The Tuned One-Pole Allpass Filter Feedback Loop . . . . . . . . . . . . . . . 158 6.2 The Very Short Waveguide 6.3 The Wave-Decomposed Second-Order Oscillator . . . . . . . . . . . . . . . . 160 6.4 Geometric Computation of Impedance Phase Response . . . . . . . . . . . . 161 6.5 Impedance of This System is F (s)/V (s) = ks/(s2 + k/m) . . . . . . . . . . 162 6.6 Mass-Spring Oscillators Coupled at a Spring-Loaded Junction . . . . . . . . 163 6.7 Digital Implementation of Second-Order Oscillators Coupled at a Loaded . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 Junction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 6.8 The Digital Waveguide String/Hammer System . . . . . . . . . . . . . . . . 168 6.9 Mass and Spring Force Diagram . . . . . . . . . . . . . . . . . . . . . . . . 169 6.10 The Continuous-Time Mass-Spring System with Initial Velocity . . . . . . . 171 6.11 The Digital Wave-Decomposed Mass and Spring Filter . . . . . . . . . . . . 174 6.12 String Loaded with Mass and Nonlinear Spring . . . . . . . . . . . . . . . . 175 6.13 Attaching the Wave Digital Hammer . . . . . . . . . . . . . . . . . . . . . . 176 6.14 Attaching the Wave Digital Hammer to a 2-D Digital Waveguide Mesh . . . 178 6.15 The Wave Digital Hammer . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 6.16 Nonlinear Spring and Dashpot . . . . . . . . . . . . . . . . . . . . . . . . . . 181 6.17 Equivalent Nonlinear Spring . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 6.18 Calculated Forces on Hammer Felt for v0 = 1,2,3, and 4 m/s . . . . . . . . 184 7.1 The Elaborate Physically Modeled Piano . . . . . . . . . . . . . . . . . . . . 188 7.2 String Terminated on One Side Only . . . . . . . . . . . . . . . . . . . . . . 189 7.3 The Linear Mass-Spring Hammer Model . . . . . . . . . . . . . . . . . . . . 190 7.4 Step-Driven Recursive Hammer Filter . . . . . . . . . . . . . . . . . . . . . 192 xv 7.5 Feed-Forward Hammer Filter . . . . . . . . . . . . . . . . . . . . . . . . . . 192 7.6 Impulse-Driven Recursive Hammer Filter . . . . . . . . . . . . . . . . . . . 192 7.7 Middle-C (261 Hz) Struck Hard: Force Signals Computed Using the WDH Parameterized with Physical Data Taken from (Chaigne and Askenfelt, 1994b)194 7.8 Spectral EQ Method of Modeling the Hammer Filter . . . . . . . . . . . . . 195 7.9 Sixth-Order Filter Fit to Ratio Spectrum . . . . . . . . . . . . . . . . . . . . 195 7.10 Synthesis of Soundboard Tap with Nonlinearly Filtered Noise . . . . . . . . . 197 7.11 1-Pole Soundboard Resonance Implementation . . . . . . . . . . . . . . . . . 197 7.12 Noise-Plus-Resonator Soundboard Synthesis . . . . . . . . . . . . . . . . . . 197 7.13 dB Frequency Response of a Recorded Piano Soundboard Tap (above) and a Close-Up of the Lower Frequencies (below) . . . . . . . . . . . . . . . . . . 198 7.14 Synthetic Soundboard Tap Using a Swept 1-Pole and Noise . . . . . . . . . 199 7.15 “Pedal-Down” Synthesis of Dry Soundboard Tap Plus “Wet” Open Strings Tap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 A.1 Terminated String and Pick-up Placement Model . . . . . . . . . . . . . . . 203 A.2 Close-up of the Interpolated Position of the Pick-up . . . . . . . . . . . . . . 204 A.3 Slow Continuous Pick-up Point Motion Over the String Length . . . . . . . 205 A.4 Fast Discontinuous Pick-up Point Speeds . . . . . . . . . . . . . . . . . . . . 206 A.5 Effect of Accelerating Pick-up Point Position . . . . . . . . . . . . . . . . . 208 A.6 Sinusoidally Oscillating Pick-up Point Position . . . . . . . . . . . . . . . . 209 A.7 Effects of Constant Speed Plus Modulation Modulating on Pick-up Position 211 A.8 Effects of Accelerating Pick-up Position with Modulation . . . . . . . . . . . 212 B.1 The Interpolated Allpass Crossfade Structure . . . . . . . . . . . . . . . . . 216 B.2 Timing Diagram for the Alternating Crossfade Between Read Point Outputs 217 C.1 Plotter Data Showing Natural Groupings of Partials of A0 . . . . . . . . . . 220 C.2 Spectral Evolution of A0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 C.3 Measured Partial Frequencies in Hz for A0 . . . . . . . . . . . . . . . . . . . 222 C.4 MUSIC 5 Diagram of Instrument . . . . . . . . . . . . . . . . . . . . . . . . 223 xvi Chapter 1 Traveling Wave Warm-Ups 1.1 Introduction This first chapter investigates the partial differential equation of the vibrating string and its relationship to the digital waveguide filter implementation and the equivalent finite difference approximations. Understanding the wave equation and its traveling-wave solution is fundamental to the digital waveguide physical modeling approach (Smith, 1992). Furthermore, a grasp of the numerical properties of finite difference approximations to differential equations is illuminating in the one-dimensional case of vibrating strings, and is indispensable in the development of the multi-dimensional digital waveguide mesh solutions for traveling waves in membranes, plates, and rooms presented here in Chapters 3 and 4, and originally published in (Van Duyne and Smith, 1996; Van Duyne and Smith, 1993b; Van Duyne and Smith, 1993a; Van Duyne and Smith, 1995a). Inasmuch as finite difference approximations are a fundamental computational tool to the scientific community (Strikwerda, 1989), we review the derivation of the flexible string equation and derive the traveling-wave solutions in both the continuous time–space equation and in the standard finite difference approximation. We then review the digital waveguide computational model and show its exact equivalence to an optimally sampled finite difference approximation. Chapter 2 follows up with modeling stiffness and loss in strings and coupled strings including calibration methods to make the models useful. Chapter 5 addresses nonlinear coupling of modes. Chapter 6 introduces traveling-wave decomposition of lumped impedances, in particular, a coupled-mode synthesis method, and a nonlinear piano hammer 1 2 CHAPTER 1. TRAVELING WAVE WARM-UPS design. Chapter 7 investigates how to commute the piano soundboard response through a nonlinear hammer excitation to create efficient piano tone synthesis algorithms. The Appendices provide some interesting sidelights: a hybrid waveguide/FM pick-up point modulation synthesis method, a stiff-string FM-based synthesis model, and an interesting way to do signal-controlled artifact-free allpass interpolation of delay line loop lengths. Now on to the analysis of the 1-D wave equations and finite difference schemes in both the continuous time and space domains and the discrete time and space domains, spectral amplification factors, and techniques for evaluating and correlating the digital waveguide filters, finite difference schemes and differential equations which describe traveling wave behavior in isotropic media. 1.2 1.2.1 The Classical Wave Equation A Physical Derivation The ideal flexible string equation is worked out fully in (Morse, 1976), and in many other places. We review here the basic physical intuition of the equation. Assume an ideal lossless flexible string whose transverse displacement is given by y(t, x), where t is time, and x is horizontal position along the string. Assume it is infinitely long, that is, there are no termination boundary conditions to worry about for now. There is a constant tension, K, on the string; and the string has a mass per unit length of ε. We may apply Newton’s Second Law, f = ma, that is, force = mass × acceleration, to a small piece of the string between point x and point x + ∆x. The mass of this small string segment is its mass density times its length, ε∆x. Its acceleration is the second partial time derivative of its transverse position, ∂ 2 y/∂t2 . Figure 1.1 shows the transverse force on the right end point of the string segment as the transverse component of the string tension, which may ∆ be approximated, for small string deflection angles, θ, as K sin θ ≈ K tan θ = K∂y/∂x evaluated at the point x + ∆x. The transverse force on the left end point of the string segment may be similarly approximated as −K∂y/∂x evaluated at the point x. Hence, the total transverse force is the sum of these two forces. Substituting these values for force, mass and acceleration into f = ma, we obtain the relationship, K ! ∂y(t, x + ∆x) ∂y(t, x) − ∂x ∂x " = ε∆x ∂2y ∂t2 (1.1) 3 CHAPTER 1. TRAVELING WAVE WARM-UPS K K sinθ θ y(x) x x+Δx Figure 1.1: Transverse Force Component of String with Constant Tension K Dividing both sides by ∆x and taking the limit as ∆x goes to zero, we note that the left-hand side of the equation contains the definition of the second partial derivative of y with respect to x. ∂y(t, x + ∆x) ∂y(t, x) − ∂2y ∂x ∂x =ε 2 K lim ∆x→0 ∆x ∂t Hence, we may write, K ∂2y ∂2y = ε ∂x2 ∂t2 (1.2) (1.3) A derivation along these lines may be found in (Morse, 1976) or (Graff, 1975). This is a simple looking equation. However, it is just an approximation of real string behavior, even ideal string behavior. Recall that, in order to obtain this conveniently linear equation, we assumed that tension on the string was constant at all times, that there is no longitudinal motion of the string, transverse motion was allowed in only one plane, and that the string was completely flexible, i. e., it had no diameter. However, even with these idealized assumptions, we have still approximated the transverse force component, taking sin θ ≈ tan θ, which is only true for very small string deflection angles, θ. As soon as the string starts moving, error is introduced into the approximation; even this idealized string is inherently nonlinear (Pierce, 1974). A more detailed treatment of the nonlinear vibration problem may be found in (Carrier, 1945), as well as a treatment of the nonlinear coupling between the three modes of vibration, horizontal transverse CHAPTER 1. TRAVELING WAVE WARM-UPS 4 waves, vertical transverse waves, and longitudinal compression waves, all of which play an important role in the vibration of real strings. These three modes of vibration are linear and may be separated into orthogonal, non-coupled modes in the ideal string only when deflections remain small enough (Elmore and Heald, 1985). 1.2.2 The Traveling-Wave Solution Returning to the simplified case, Jean Le Rond d’Alembert published the traveling-wave solution to the wave equation in 1749 in his Recherches sur la courbe que forme une corde tendue mise en vibration (d’Alembert, 1749). It is easy to verify by substitution that the ideal wave equation (1.3) is solved by the sum of two arbitrary traveling waves, y(t, x) = y + (x − ct) + y − (x + ct) (1.4) where y + (x − ct) represents an arbitrary fixed wave shape traveling to the right at speed c, and y − (x + ct) represents an arbitrary fixed wave shape traveling to the left at speed c. Defining ÿ ± as the second derivatives of the traveling-wave shape functions y ± , ∆ ÿ ± (ξ) = d2 y ± (ξ) dξ 2 (1.5) we take second-order partial derivatives of (1.4) to obtain ∂ 2 y(t, x) ∂t2 2 ∂ y(t, x) ∂x2 Substituting, we see, = c2 ÿ + (x − ct) + c2 ÿ − (x + ct) (1.6) = ÿ + (x − ct) + ÿ − (x + ct) (1.7) 2 ∂ 2 y(t, x) 2 ∂ y(t, x) = c ∂t2 ∂x2 ∆ which is equivalent to (1.3) with c = (1.8) # K/ε. Hence, the traveling-wave solution of the wave equation is verified by direct substitution. The arbitrary traveling waves may be expressed as sums of their traveling sinusoidal components: y ± (x ∓ ct) = $ k jωk (x∓ct) A± ke (1.9) CHAPTER 1. TRAVELING WAVE WARM-UPS 5 where the A± k are complex amplitude scalers containing magnitude and phase information, and ejωk (x∓ct) represents a complex sinusoid of spatial frequency ωk traveling at speed c. Note that, in this formulation, the corresponding temporal frequency observed at some fixed point on the string would be ωk c. 1.3 1.3.1 Transforming the Wave Equation A Frequency Domain Approach If we lack the intuition of d’Alembert, or otherwise prefer not to guess at the solutions of the wave equation, we may derive the traveling-wave solution from Equation (1.8) by applying straightforward spectral transform methods. An application of the generalized bi-directional Laplace transform to the space dimension of the wave equation may be found in (Zemanian, 1987). However, we do not follow this method; our approach will be to apply the Fourier transform to the continuous space dimension, −∞ < x < ∞, mapping to the continuous frequency variable, −∞ < ω < ∞; then to apply the uni-directional Laplace transform to the continuous time dimension, t > 0, mapping to the complex frequency variable, s, over the complex plane where the imaginary part of s corresponds to real frequencies, and the real part of s corresponds to decaying exponentials. First, we take the Fourier transform of (1.8) over the spatial coordinate, mapping, F ∆ y(t, x) ←→ yω (t) = % ∞ −∞ y(t, x)e−jωx dx (1.10) and taking advantage of the derivative theorem (Hsu, 1984) which states, ∂y(t, x) F ←→ jωyω (t) ∂x (1.11) to obtain the ordinary differential equation in time, ∂ 2 yω (t) = c2 (jω)2 yω (t) ∂t2 (1.12) where yω (t) is the Fourier transform of y(t, x) along x. Applying the uni-directional Laplace transform to 1.12, mapping, L ∆ yω (t) ←→ Yω (s) = % 0 ∞ yω (t)e−st dt (1.13) 6 CHAPTER 1. TRAVELING WAVE WARM-UPS and then applying the Laplace derivative theorems, and ∂yω (t) L ←→ sYω (s) − yω (0) ∂t (1.14) ∂ 2 yω (t) L 2 ←→ s Yω (s) − syω (0) − ẏω (0), ∂t2 (1.15) s2 Yω (s) − syω (0) − ẏω (0) = c2 (jω)2 Yω (s) (1.16) we find ∆ where yω (0) is the initial condition spatial spectrum at time zero, and ẏω (0) = ∂yω /∂t evaluated at ω = 0 is the first partial time derivative of the spatial spectrum at time zero. Solving for Yω (s) and making a partial fraction expansion, we obtain the result, Yω (s) = syω (0) + ẏω (0) yω+ yω− = + s2 + c2 ω 2 s + jωc s − jωc where, ∆ yω± = 1.3.2 ! 1 ẏω (0) yω (0) ∓ 2 jωc " (1.17) (1.18) The Differential Equation as a Second-Order System We may view Equation (1.17) as a continuum of second-order analog filter systems which operate pointwise on space spectrum point signals. The filter continuum is tuned according to the frequency ω of the spatial spectrum point on which it is working. Noting that, L eat ←→ 1 s−a (1.19) we take inverse Laplace transform of Equation (1.17) to get, yω (t) = yω+ e−jωct + yω− ejωct (1.20) Applying the inverse Fourier transform in space, taking advantage of the shift theorem, which maps linear phase modulation in the spectral domain to constant distance shift in the space domain, we obtain the classical traveling-wave solution, y(t, x) = y + (x − ct) + y − (x + ct) (1.21) 7 CHAPTER 1. TRAVELING WAVE WARM-UPS Furthermore, taking the inverse Fourier transform of Equation (1.18), we may express the left and right displacement wave components in terms of the initial displacement, y(0, x), and initial transverse velocity, ∂y(0, x)/∂t, of the the string: y ± (x) = ! 1 1 y(0, x) ∓ 2 c % x −∞ ∂y(0, ξ) dξ ∂t " (1.22) These initial condition relations are reached in (Morse and Ingard, 1968) in an entirely time-space domain approach. 1.3.3 Introduction to Spectral Amplification Factors Our spectral transform approach is somewhat heavy-handed if its only purpose is to solve the 1-D wave equation. However, we have in mind to apply this same method to finite difference approximations to the wave equation in the multi-dimensional cases. These methods will give us a way to evaluate quantitatively the numerical error in finite approximation schemes. We work out the details here in the one-dimensional case, and apply the same principles to the analysis of the digital waveguide mesh solutions to the multi-dimensional wave equation in Chapters 3 and 4. To proceed, we may study the behavior of wave travel in the wave equation by tracing the evolution of the spatial spectrum over time. In particular, we may compute a set of spectral amplification factors (Strikwerda, 1989) which describe how the spatial spectrum changes over a given time interval, ∆t. Equation (1.20) expresses the spatial spectrum at time t as the sum of two initial constant spectra, yω± , modulated by linear phase terms, e±jωt . We may investigate how the spatial spectrum changes over the interval from t to t + ∆t by comparing (1.20) with the following: yω (t + ∆t) = yω+ e−jωc(t+∆t) + yω− ejωc(t+∆t) = yω+ e−jωct gω+ (∆t) + yω− ejωct gω− (∆t) (1.23) (1.24) where, ∆ gω± (∆t) = e∓jωc∆t (1.25) are the spectral amplification factors. The magnitude of these factors is equal to 1, which CHAPTER 1. TRAVELING WAVE WARM-UPS 8 means there is no loss in this equation. However there is a spatial phase shift of % gω± (∆t) = ∓ωc∆t (1.26) This is the number of radians that a given spatial frequency, ω, will advance in phase after a time interval ∆t. Phase Distance By analogy with the concept of phase delay, or really phase advance, in the time domain, we may define a phase distance which is intuitively the distance which a space wave travels in the time interval corresponding to the apparent phase advance at the given frequency. Phase distance is the phase advance normalized by spatial frequency, −% gω± (∆t) = ±c∆t ω (1.27) Speed of Wave Travel Of course, we may define the speed of wave travel as phase distance traveled per unit of time, 1.3.4 −% gω± (∆t) = ±c ω∆t (1.28) Allowed Frequencies on an Ideal String with Rigid Terminations Allowed frequencies on a rigidly terminated vibrating ideal string of length, L, and traveling-wave speed, c, can be computed as follows: Rigid terminations reflect and invert traveling waves (Morse, 1976), so round-trip traveling-wave length of the string system is 2L. Supported wave lengths on the string are those that have multiples equal to the round-trip traveling-wave path. Call the spatial wave lengths of partial frequencies allowed on the terminated string, Tn , where Tn = 2L/n and n = 1, 2, . . . are the partial frequency index numbers. (1.29) 9 CHAPTER 1. TRAVELING WAVE WARM-UPS Spatial frequencies associated with these wave lengths would be ωn = nπ 2π = Tn L (1.30) ∆ Defining the travel speed of the spatial frequencies to be C(ωn ) = c, constant for all spatial frequencies, then the allowed partial frequencies, p(n), are computed as p(n) = C(ωn ) nc = Tn 2L (1.31) which can be written, p(n) = n p(1) (1.32) Allowed partial frequencies are simply multiples of the fundamental frequency, p(1). Although this computation is evidently trivial and not surprising in the ideal flexible string case, this method is general and will permit us to compute allowed frequencies on terminated media where C(ωn ) is not constant over ωn . 1.4 The Digital Waveguide Difference For an excellent technical overview and history of the delay-line loop-based string models, please see (Karjalainen et al., 1998). 1.4.1 Bi-Directional Delay Lines For the purpose of the present work, note that the digital waveguide is a direct implementation of the traveling-wave solution to the wave equation as a pair of bi-directional delay lines which represent both time delay and physical distance by their delay elements (Smith, 1987; Smith, 1992). Figure 1.2 illustrates a high-level view of the digital waveguide. Two arbitrary digital traveling-wave signals propagate independently in their respective leftand right-going directions in delay line registers, while the physical wave amplitude at any point may be obtained by summing the left- and right-going signals at a physical position. The physical signal output, u, is the transverse displacement of the vibrating string at some pick-up point on the string, and is computed as sum of its traveling components, u+ and u− . The full shape of the string can be computed by summing the traveling-wave signals at each point of the bidirectional delay lines. 10 CHAPTER 1. TRAVELING WAVE WARM-UPS u+ DELAY LINE + u DELAY LINE u– Figure 1.2: The Digital Waveguide The position of the pick-up point is critical in audio synthesis, as the choice of position comb filters (Dodge and Jerse, 1985; Parks and Burrus, 1987) the output signal significantly in relation to the modal shapes on the strings. Sometimes this is desirable, often not. In much physical modeling synthesis, the audio output can be taken directly from one of the traveling waves (without computing the sum of traveling waves), or in more advanced modeling, extracted form the bridge filter or scattering junction (Smith, 1987). In Chapters 3 and 4, we extract output audio from scattering junctions on the plane, but then a 2-D comb filtering effect is in place relating to the modal shapes on the membrane. Appendix A investigates the audio synthesis possibilities of sliding the position of the pick-up point along the length of the string model at constant velocity, accelerating it, or oscillating the position placement—something that would be hard to do in reality, but easy to do in a physical model. This exploits the comb filtering effect and the result is a combination of amplitude and frequency modulation (Chowning, 1973) effects on physical model output. 11 CHAPTER 1. TRAVELING WAVE WARM-UPS z-1 z-N ε 1–ε + Figure 1.3: Linearly Interpolated Delay Line 1.4.2 Fractional Delay Line Lengths We will need to model string systems whose loop delays are a non-integral number of samples long. However, we are in a time-sampled environment and there is no way to have a fractional delay except by some form of filtering. Much work has gone into this area of research and we do not intend to explore this area fully. See (Välimäki, 1995) for some excellent analysis and applications. For now, we may extract two simple methods which are in common use due to their efficiency and useful properties. Linear Interpolation If we require a delay line of length of N + ε samples, where ε is some number between 0 and 1, we may use the method of linear interpolation between two delay lengths as is shown in Figure 1.3 (Jaffe and Smith, 1983). Such a method is extremely convenient when variable delay lengths are to be expected, however, if the the delay line is to be part of a feedback loop, as in the simple string model presented in the next section, there is a major drawback. The very act of interpolation is equivalent to applying a one-zero lowpass filter inside the feedback loop. For example if ε = 0.5, the interpolation applies a two point averaging filter with a zero right on the Nyquist limit frequency (Parks and Burrus, 1987). Allpass Interpolation An alternative to linear interpolation, which does not attenuate the magnitude of the signal in the delay line is allpass interpolation (Jaffe and Smith, 1983). The idea is to 12 CHAPTER 1. TRAVELING WAVE WARM-UPS z-N Hε(z) Figure 1.4: Allpass Interpolated Delay Line insert an allpass filter into the delay line whose phase response delays the phase of the component frequencies in the signal so as to imitate the effect of a fractional delay. The first-order allpass filter is sufficient for this purpose. The one-pole digital allpass filter may be defined by its difference equation, y(n) = a0 x(n) + x(n − 1) − a0 y(n − 1) (1.33) where x(n) is its input signal and y(n) is its output signal, or by its Z–transform (Parks and Burrus, 1987), ∆ H(z) = a0 + z −1 1 + a0 z −1 (1.34) We take the coefficient, a0 , to be a real number between −1 and 1. The frequency response of this filter is obtained by replacing z with ejωT , where ω is the radian frequency and ∆ T = 1/fs is the sampling interval. The magnitude response, |H(ejωT )|, is always 1; therefore, we may re-write the frequency response in the following polar form, H(ejωT ) = ejφ(ωT ) (1.35) ∆ where the phase response is φ(ωT ) = % H(ejωT ). We may derive an analytic expression for the phase response, φ(ωT ) = arctan & ' Im H(ejωT ) Re{H(ejωT )} (a0 2 − 1) sin ωT = arctan 2a0 + (a0 2 + 1) cos ωT (1.36) (1.37) where the arc tangent function has been unwrapped. Since we restrict ω to positive frequencies, we can unwrap the values of the usual computer generated arc tangent function by subtracting π whenever the arctan function is positive. Figure 1.5 shows overlaid plots of φ(ωT ) for values of a0 ranging from −0.8 to 0.8. 13 CHAPTER 1. TRAVELING WAVE WARM-UPS ωT 0 0 π/4 π/2 3π/4 π a0 = 0.8 −π/4 φ(ωT) −π/2 −3π/4 a0 = −0.8 −π Figure 1.5: Phase Response of One-Pole Allpass The phase delay of the allpass filter is defined as the phase response normalized by frequency, ∆ Pd (ω) = φ(ωT )/ω (1.38) The phase delay tells us the effective number of samples that a particular frequency has been delayed. Therefore, if we need a fractional delay of ε, then we simply need an allpass filter whose phase delay is ε at all frequencies. This is not exactly possible, but the onepole allpass makes a convenient unattenuated approximation to this. An estimate of the correct allpass coefficient for a given fractional delay is given in (Jaffe and Smith, 1983), a0 ≈ 1−ε 1+ε (1.39) which is good for low frequencies. There is some dispersion at the higher end of the frequency response, but the effect is quite good when the coefficient is near zero, which is where the allpass reduces to the exactly linear phase case of one sample of pure delay. Therefore, it may be best to let your desired fractional delay, ε, range from .5 to 1.5, rather than from 0 to 1 by modifying the integral delay length appropriately. CHAPTER 1. TRAVELING WAVE WARM-UPS 14 See Appendix B for a brute-force psychoacoustics-based solution to the problem of making continuous pitchbend or glissandi on a string when using the lossless allpass interpolation approach. 1.4.3 Analysis of the Internal Waveguide Filter Signals Returning to the digital waveguide filter structure, per se, we note that the continuous time and space solution to the wave equation, y(t, x) may be sampled over space and time with a time sampling interval of T and a spatial sampling interval of X to define a discrete time–space function, vm (n), where n is the time index and m is the space index. If we take X = cT , then waves should travel at the rate of one spatial sample per time sample: ∆ (1.40) = y + (mX − cnT ) + y − (mX + cnT ) (1.41) vm (n) = y(nT, mX) = y + ((m − n)X) + y − ((m + n)X) ∆ = u+ (m − n) + u− (m + n) (1.42) (1.43) where u± are the sampled traveling-wave signals as in Figure 1.2 of the solution corresponding to the continuous traveling waves, y ± . In Figure 1.6, we now explicitly define separate traveling-wave signals between every + (n) is the signal output at position m delay unit in the upper and lower delay lines: vm − (n) is the signal output at position m on on the upper right-going delay line at time n; vm + (n) is the the lower left-going delay line at time n. To clarify by an example, note that vm + − (n) is the same signal as v + (n − 1). same signal as vm−1 (n − 1), similarly vm m+1 1.4.4 The Equivalent Finite Difference Scheme Figure 1.6 illustrates the basic computational structure in digital filter block diagram notation. The time index is represented by n and the spatial position is represented by + (0) is the initial spatial wave shape at time 0 which travels to the right m. The signal vm − (0) is the initial spatial wave shape at time 0 which travels as n increments. The signal vm to the left as n increments. The actual physical variable is given by + − vm (n) = vm (n) + vm (n) (1.44) 15 CHAPTER 1. TRAVELING WAVE WARM-UPS + (n) vm-1 + (n) vm z−1 + vm-1(n) − vm-1 (n) z−1 + v−m(n) z−1 + (n) vm+1 vm(n) z−1 + z−1 vm+1(n) − (n) vm+1 z−1 Figure 1.6: Close-Up of the Digital Waveguide Moving to the Z-Plane + (n), and v − (n) as three sets of time indexed signals which are assoIf we view vm (n), vm m ciated with spatial positions, m, we may perform a Z-transform (Kuo, 1966; Ludeman, 1986) on the entire set Z ∆ vm (n) ←→ Vm (z) = Z ∆ ± vm (n) ←→ Vm± (z) = ∞ $ n=0 ∞ $ vm (n)z −n (1.45) ± vm (n)z −n (1.46) n=0 With this, we observe the following relationships from the Figure 1.6: Vm (z) = Vm+ (z) + Vm− (z) (1.47) + (z) Vm+ (z) = z −1 Vm−1 (1.48) − (z) Vm− (z) = z −1 Vm+1 (1.49) Applying these observations, we may express the traveling-wave signals, Vm± (z) as combinations of the physical signals, Vm (z) + Vm+ (z) = z −1 Vm−1 (z) − = z −1 (Vm−1 (z) − Vm−1 (z)) (1.50) (1.51) CHAPTER 1. TRAVELING WAVE WARM-UPS = z −1 (Vm−1 (z) − z −1 Vm− (z)) = z −1 (Vm−1 (z) − z −1 (Vm (z) − Vm+ (z))) 16 (1.52) (1.53) = z −1 Vm−1 (z) − z −2 Vm (z) + z −2 Vm+ (z) (1.54) z −1 (Vm−1 (z) − z −1 Vm (z)) 1 − z −2 (1.55) Solving for Vm+ (z) we find, Vm+ (z) = Similarly for the left-going wave signals, Vm− (z) = z −1 (Vm+1 (z) − z −1 Vm (z)) 1 − z −2 (1.56) Eliminating the Wave Variables Hence, the physical variable signals, Vm (z), may be expressed in terms of other physical variable signals, and the wave variable signals may be eliminated, ∆ Vm (z) = Vm+ (z) + Vm− (z) z −1 = (Vm−1 (z) − 2z −1 Vm (z) + Vm+1 (z)) 1 − z −2 (1.57) (1 − z −2 )Vm (z) = z −1 (Vm−1 (z) + Vm+1 (z)) − 2z −2 Vm (z) (1.59) (1 + z −2 )Vm (z) = z −1 (Vm−1 (z) + Vm+1 (z)) (1.60) (1.58) Gathering terms, The Waveguide Difference Scheme The inverse Z-transform leads to the time domain expression, vm (n) + vm (n − 2) = vm−1 (n − 1) + vm+1 (n − 1) This is the difference scheme which the digital waveguide computes. (1.61) 17 CHAPTER 1. TRAVELING WAVE WARM-UPS 1.4.5 Converging to the Differential Equation In later chapters it will be useful to have a reliable method to verify exactly what partial differential equation a given finite difference scheme converges to as the grid interval sizes approach 0. In general we will be able to replace the discrete time and space variables with continuous time and space variables, and replace the unit spatial and time sample shifts in the finite difference with an ε. We can then apply a multi-dimensional power series expansion around an arbitrary point in all directions, and let ε converge to 0. When the finite difference relation under study represents wave propagation in a membrane or in 3-D space, and uses a non-rectilinear space grid, this may be the most direct way to glean the actual theoretical wave speed of the traveling waves in a closed form. Let’s apply the techniques in the simple 1-D case. Note that even in the 1-D case we will need a 2-D Taylor’s expansion as there are two variables, time and space. Definition of the 2-D Taylor’s Series Expansion The 2-D Taylor’s series expansion around the point, u(t, x) can be defined as follows (Courant and John, 1974) ∆ u(t + ∆t, x + ∆x) = ∞ $ ∞ $ u(nt ,nx ) (t, x)∆tnt ∆xnx nt nx = ( + ∆t ∆x2 (1,2) ∆x (1,1) u (t, x) + u (t, x) + . . . u(1,0) (t, x) + 1! 1! 2! + ∆t2 2! ∆x (0,1) ∆x2 (0,2) u(t, x) + u (t, x) + u (t, x) + . . . 1! 2! ( ( (2,0) u (1.62) nt !nx ! ) ) ∆x2 (2,2) ∆x (2,1) u (t, x) + u (t, x) + . . . (t, x) + 1! 2! ) + ... where u(n,m) (t, x) is the partial derivative of u of order n in the t direction and of order m in the x direction (and assumed to exist), evaluated at the point (t, x). 18 CHAPTER 1. TRAVELING WAVE WARM-UPS Making the Waveguide Difference a Continuous Function If we imagine a continuous function (with continuous derivatives) running through the discrete points of the difference, we can re-write the waveguide difference derived in Equation 1.61 as follows, u(t, x) + u(t − 2ε, x) = u(t − ε, x − ε) + u(t − ε, x + ε) (1.63) Expanding with 2-D Taylor’s Series Then we can replace each term with a full Taylor’s expansion around the point (t, x): ( u + u − 2εu (1,0) ( (1,0) ( (1,0) u − εu + ) (2ε)2 (2,0) + u + O{ε3 } 2! u − εu = (1.64) ) − εu (0,1) ε2 ε2 + u(2,0) + u(0,2) + ε2 u(1,1) + O{ε3 } 2! 2! + εu (0,1) ε2 ε2 + u(2,0) + u(0,2) − ε2 u(1,1) + O{ε3 } 2! 2! ) where O{ε3 } are terms of order ε3 or higher. Canceling and gathering terms, this reduces to ε2 u(2,0) = ε2 u(0,2) + O{ε3 } (1.65) Letting the Grid Size Shrink Dividing through by ε2 , u(2,0) = u(0,2) + O{ε3 } ε2 (1.66) and taking the limit as ε −→ 0, we arrive at the standard 1-D wave equation, u(2,0) = c2 u(0,2) where the wave speed c = 1. (1.67) 19 CHAPTER 1. TRAVELING WAVE WARM-UPS 1.5 Transforming the Waveguide Difference Scheme 1.5.1 A Frequency Domain Approach We wish now to arrive at the discrete traveling-wave solution by solving the difference scheme directly. To begin, we take the discrete Fourier transform of the infinite spatial series (DFTIS) in the difference equation mapping DF T IS vm (n) ←→ vξ (n) (1.68) where ξ is the spatial frequency variable and vξ (n) are a time sequence of spatial transforms. vξ (n) + vξ (n − 2) = vξ (n − 1)ejξ + vξ (n − 1)e−jξ (1.69) = 2vξ (n − 1) cos ξ (1.70) This is just a second-order difference equation in n of the indexed spatial transforms, which may be solved easily by taking the Z-transform over n, and applying the shift theorems which map Z (1.71) Z (1.72) y(n − 1) ←→ z −1 Y (z) + y(−1) y(n − 2) ←→ z −2 Y (z) + z −1 y(−1) + y(−2) We get, * + * + Vξ (z) + vξ (−2) + z −1 vξ (−1) + z −2 Vξ (z) = 2 cos ξ vξ (−1) + z −1 Vξ (z) (1.73) where vξ (−1) and vξ (−2) are initial spatial spectrum conditions at times −1 and −2. Solving for Vξ (z), Vξ (z) = 2vξ (−1) cos ξ − vξ (−2) − z −1 vξ (−1) 1 − 2z −1 cos ξ + z −2 (1.74) The denominator may be factored into two complex-conjugate poles and we may make a 20 CHAPTER 1. TRAVELING WAVE WARM-UPS partial fraction expansion of Vξ (z) as follows, Vξ (z) = vξ+ 1 − e−jξ z −1 + vξ− 1 − ejξ z −1 (1.75) where vξ+ and vξ− are some combination of the initial condition spatial spectra vξ (−1) and vξ (−2). 1.5.2 The Finite Difference as a Second-Order System We may view 1.75 as a continuum of second-order digital filter systems which operate pointwise on space spectrum signals. The filter continuum is tuned according to the frequency ξ of the spatial spectrum bin on which it is working. Taking the inverse Z-transform we obtain an expression for the evolution of the spatial spectrum over time, vξ (n) = vξ+ e−jξn + vξ− ejξn (1.76) Taking the inverse discrete time spatial Fourier transform we obtain a pure traveling-wave solution, vm (n) = v + (m − n) + v − (m + n) 1.5.3 (1.77) Discrete Spectral Amplification Factors Just as we did in the continuous time and space domain, we can define the digital spectral amplification factors as ∆ gξ± (T ) = e∓jξ , (1.78) representing the change in the spatial spectrum over one time sample. The magnitude of these factors is one, which means the implementation is lossless; there is no decay in the waveshape as time passes. The Wave Speed The spatial phase shift, % gξ± (T ) = ∓ξ, (1.79) is the number of radians that a given spatial frequency, ξ, will advance in phase after a time interval of one sample. By analogy with the concept of phase advance in the time 21 CHAPTER 1. TRAVELING WAVE WARM-UPS domain, we compute the phase distance which a space wave travels in the time interval as, −% gξ± (T ) ξ = ±1 (1.80) The speed of wave travel is one space sample per time sample. 1.5.4 Von Neumann Analysis In effect, we have just compared the continuous-time spectral amplification factors (which revealed that all spatial frequencies traveled at speed c) with the discrete-time spectral amplification factors (which revealed that spatial frequencies traveled at 1 spatial sample per time sample) to conclude that the difference approximation modeled the behavior of the continuous equation exactly on the sampled grid for the case, c = 1. This approach is known as von Neumann analysis (Strikwerda, 1989); it uses a variety of frequency transforms to compare the evolution over time of the spatial spectrum in the continuous time system to that in the discrete time system. Recall that to solve an ordinary linear differential equation, we may reduce the problem to a polynomial in s by taking the Laplace transform and replacing orders of derivatives with powers of s, then take a spatial transform of a partial differential equation with independent time and space variables to obtain an ordinary differential equation describing the evolution of spatial spectra over time. From here, we can check how the spatial spectrum evolves after a time delay of T seconds. The ratio of the spatial spectrum at time t + T to the spatial spectrum at time t is known as the spectral amplification factor. Also, recall that in the discrete case, to solve a time-indexed difference equation, we may reduce the problem to a polynomial in z −1 by taking the Z-transform and replacing samples of time delay in the index with powers of z −1 . If we have a time- and space-indexed difference scheme approximation to compare with our partial differential equation, we may even perform a similar spectral evolution analysis in multiple dimensions. First, let’s look at the more difficult 1-D situation where c "= 1. 1.6 A More General Difference for c "= 1 The digital waveguide filter structure implements a finite difference scheme where wave speed is c = 1. We consider now the a standard difference for the more general case. 22 CHAPTER 1. TRAVELING WAVE WARM-UPS 1.6.1 Deriving the General Difference The first derivative of a continuous function may be approximated by a first-order forward difference (Strikwerda, 1989), f & (x) ≈ f (x + ∆x) − f (x) ∆x (1.81) A centered second-order difference approximation to the second derivative may be obtained by taking a first-order backward difference of the first-order forward difference, f && (x) ≈ f (x + ∆x) − 2f (x) + f (x − ∆x) f & (x) − f & (x − ∆x) = ∆x ∆x2 (1.82) Now, in making a difference equation approximation to wave equation, 2 ∂2y 2∂ y = c ∂t2 ∂x2 (1.83) we first make a time-space sampling of the continuous time-space solution as follows, ∆ u(n, m) = y(nT, mX) (1.84) where T is the time sampling interval, and X is the space sampling interval. We may then approximate the continuous wave equation with the following partial finite difference equation, where we have chosen a centered difference in space, and a backward difference in time: u(n, m) − 2u(n − 1, m) + u(n − 2, m) = C 2 [u(n − 1, m + 1) − 2u(n − 1, m) + u(n − 1, m − 1)] (1.85) cT X (1.86) where, ∆ C= Here, C is the normalized wave travel speed parameter given in units of spatial samples per time samples. 23 CHAPTER 1. TRAVELING WAVE WARM-UPS 1.6.2 Spectral Analysis of the General Difference We wish to determine how closely this difference equation will simulate the behavior of the differential equation it approximates. There is predictably going to be numerical error introduced simply because of the space and time sampling. But it is less obvious how this approximation error affects the traveling-wave behavior of the system. To begin, we take the discrete Fourier transform on the infinite spatial series of the difference equation 1.85, mapping DF T IS ∆ u(n, m) ←→ uω (n) = ∞ $ u(n, m)e−jωm (1.87) m=−∞ where ω is the spatial frequency variable lying in the range from −π to π, and uω (n) is a discrete time sequence of spatial transforms, giving , uω (n) − 2uω (n − 1) + uω (n − 2) = C 2 uω (n − 1) ejω − 2 + e−jω - (1.88) Gathering terms, , - uω (n) − 2 1 + C 2 cos ω − C 2 uω (n − 1) + uω (n − 2) = 0 (1.89) This is just a second-order difference equation in n of the indexed spatial transforms, which may be solved easily by taking the Z-transform over n (Ludeman, 1986), Z ∆ uω (n) ←→ Uω (z) = ∞ $ uω (n)z −n (1.90) n=0 and applying the shift theorems, Z (1.91) Z (1.92) uω (n − 1) ←→ z −1 Uω (z) + uω (−1) uω (n − 1) ←→ z −2 Uω (z) + z −1 uω (−1) + uω (−2) to obtain , Uω (z) − 2 1 + C 2 cos ω − C 2 * -* + z −1 Uω (z) + uω (−1) (1.93) + (1.94) + z −2 Uω (z) + z −1 uω (−1) + uω (−2) = 0 CHAPTER 1. TRAVELING WAVE WARM-UPS 24 Solving for Uω (z), . / 2 1 + C 2 cos ω − C 2 uω (−1) − uω (−2) − uω (−1)z −1 Uω (z) = 1 − 2 (1 + C 2 cos ω − C 2 ) z −1 + z −2 (1.95) The Second-Order System Equation 1.95 may be viewed as a continuum of second-order digital filters operating on spatial spectrum signals and tuned according to ω, the spatial frequency variable. Factoring the denominator of (1.95) into two poles at gω± = 1 + C 2 cos ω − C 2 ± 0 (1 + C 2 cos ω − C 2 )2 − 1 (1.96) we may make a partial fraction expansion of (1.95) yielding the expression, Uω (z) = u− u+ ω ω + −1 + 1 − gω z 1 − gω− z −1 (1.97) − where u+ ω and uω are some combination of the initial condition spatial spectra uω (−1) and uω (−2). Noting that, Z an ←→ 1 , 1 − az − 1 (1.98) we see the inverse Z-transform of Equation 1.97 leads to a discrete time series of spatial spectra, + n − − n uω (n) = u+ ω (gω ) + uω (gω ) 1.6.3 (1.99) Numerical Instability when c > 1 The gω± , as defined in 1.96, are now the spectral amplification factors for the finite difference equation 1.85. First we may observe by inspection of Equation (1.96) that the magnitude of gω± may exceed 1 for certain values of ω if C is chosen greater than 1. C greater than 1 means that a spatial sampling interval, X, and time step, T , were chosen such that the wave speed, c, in the original partial differential equation corresponded to something greater that one spatial sample per time step. The von Neumann numerical stability analysis method (Strikwerda, 1989) states that if the spectral amplification factors exceed 1 in magnitude (and are not otherwise dependent on the sampling grid size), then the difference equation can be numerically unstable. In fact, it is obvious from (1.99) that if CHAPTER 1. TRAVELING WAVE WARM-UPS 25 Figure 1.7: Magnitude of Spectral Amplification Factor, |gω+ | the magnitudes of either gω+ or gω− are greater than 1, then as n gets large, the magnitude of the spatial spectrum uω (n) is unbounded. Figure 1.7 illustrates how the spectral amplification factor magnitude, |gω+ |, exceeds 1 for some spatial frequencies for wave speeds greater than 1. Courant-Friedrichs-Lewy Stability Condition for Hyperbolic Differences The Courant-Friedrichs-Lewy condition (Courant et al., 1956; Strikwerda, 1989) states that a necessary condition for the convergence of an explicit finite difference scheme is that the domain of dependence of the discrete difference includes the domain of dependence of the differential equation in the limit as the size of the finite difference grid steps shrink to zero. In our finite difference, the domain of dependence is expanding out 1 sample spatially in each direction, per time sample. The domain of dependence of the wave equation with c = 1 is expanding outward at the rate of c in each direction. Defining λ = T /X, where T is the time sampling interval, and X is the spatial sampling interval, this condition states that, for explicit computational schemes for hyperbolic CHAPTER 1. TRAVELING WAVE WARM-UPS 26 difference equations to be numerically stable, it is necessary that |cλ| ≤ 1 (1.100) This condition simply states that a difference scheme cannot possibly propagate waves faster than the domain of dependence expands. Reformulating the standard finite difference equation (1.85) as an explicit computation scheme, that is, a scheme where a given point may be computed in terms of a finite sum of points in the past, u(n, m) = C 2 [u(n − 1, m + 1) − 2u(n − 1, m) + u(n − 1, m − 1)] + 2u(n − 1, m) − u(n − 2, m) (1.101) one can see that u(n, m) is dependent on the three spatial points between u(n − 1, m − 1) and u(n − 1, m + 1) from the previous time step; and that those points are, in turn, dependent on the five spatial points between u(n − 2, m − 2) and u(n − 2, m + 2) at the time step before that; and that, in general, there is a domain of dependence such that a point N time steps in the future can only be affected by grid points not more than N spatial steps away in either direction in the present time step (Courant et al., 1956). Hence, a wave speed greater that one spatial step per time step forces the difference scheme to predict the value at a point without the information it needs from outside its domain of dependence, which leads to numerical instability. 1.6.4 Dispersion Error when c < 1 If we assume C ≤ 1, then the expression 1 + C 2 cos ω − C 2 , which appears twice in (1.96), is always between −1 and 1. As a symbol manipulation convenience, we may define a new ∆ frequency variable ω̃ = ω̃(ω) such that ∆ cos ω̃ = 1 + C 2 cos ω − C 2 (1.102) and make the change of variables in (1.96): gω± = 1 + C 2 cos ω − C 2 ± = cos ω̃ ± # cos2 ω̃ − 1 = cos ω̃ ± j sin ω̃ 0 (1 + C 2 cos ω − C 2 )2 − 1 (1.103) (1.104) (1.105) 27 CHAPTER 1. TRAVELING WAVE WARM-UPS = e±j ω̃ (1.106) In the special case where C = 1, we note that ω̃ = ω and (1.99) may be written, −jωn jωn uω (n) = u+ + u− ωe ωe (1.107) We may perform an inverse discrete time spatial Fourier transform, applying the shift theorem, to obtain a pure traveling-wave expression, u(n, m) = u+ (m − n) + u− (m + n) (1.108) This means that the standard second-order difference approximation of the wave equation ∆ computes an exact traveling-wave solution when C = cT /X = 1, up to the Nyquist frequency band limit imposed by the sampling intervals. Furthermore, values at any points in between on the time-space sampling grid may be reconstructed through band-limited interpolation. When C ≤ 1, there is dispersion error in the computation scheme. In general, the higher spatial frequencies begin to travel a little slower than the lower spatial frequencies. This may be seen through an analysis of the finite difference amplification factors. The spectral amplification factors are gω± = e±j ω̃ (1.109) = e±j arccos( 1+C 2 cos ω−C 2 ) (1.110) The magnitudes are evidently 1, so there is no loss in the system. However there is a spatial phase shift of % , gω± = ∓ arccos 1 + C 2 cos ω − C 2 - (1.111) This is the number of radians that a given spatial frequency, ω, will advance in phase in one time sample. We define the frequency dependent normalized wave speed, C̃(ω), as . arccos 1 + C 2 cos ω − C 2 C̃(ω) = ± wC ∆ / (1.112) Figure 1.8 illustrates the dispersion error of traveling-wave speed for finite difference approximations for C less than 1. 28 CHAPTER 1. TRAVELING WAVE WARM-UPS 1.0 C = 1.0 C = 0.9 C = 0.8 0.9 0.8 C = 0.1 ∼ C(ω) 0.7 0.6 0 π/4 π/2 ω 3π/4 π Figure 1.8: Normalized Frequency-Dependent Traveling-Wave Speed 1.6.5 Digital Waveguide Structure Models Optimal Wave Speed Note that subtracting 2vm (n − 1) from both sides of the difference scheme derived in Section 1.4.4 for the digital waveguide structure, vm (n) + vm (n − 2) = vm−1 (n − 1) + vm−1 (n − 1) (1.113) leads to vm (n) − 2vm (n − 1) + vm (n − 2) = vm−1 (n − 1) − 2vm (n − 1) + vm−1 (n − 1) (1.114) (1.115) This is the standard second-order difference approximation, backward in time, central in space, of the partial differential equation, 2 ∂2y 2∂ y = c ∂t2 ∂x2 (1.116) 29 CHAPTER 1. TRAVELING WAVE WARM-UPS ∆ where the wave speed in the difference equation is C = cT /X = 1, one spatial sample per time sample, as specified by the digital waveguide structure. This demonstrates that the digital waveguide, which actually uses no computation to propagate the traveling waves (aside from updating the delay line pointers), is mathematically equivalent to the optimal finite difference approximation, in the Courant-Friedrichs∆ Lewy sense where C = cT /X = 1, of the ideal one-dimensional wave equation. Further, there is no numerical dispersion error, and the value at any non-integral space-time point may be reconstructed exactly, in a band-limited sense, through proper interpolation of time- and space-sampled digital signals. We will use a similar mathematical approach in Chapters 3 and 4 when analyzing the validity of complex spatial geometries for higher dimensional wave equations. Chapter 2 Inharmonicity, Decay and Coupling 2.1 Effects of Internal Loss and Stiffness on Traveling Waves To this point we have considered only the lossless ideal string. In all real strings there is some loss of energy. This loss may come from a variety of sources, such as viscous drag by the enveloping air or internal frictional loss. There is also loss and phase delay associated with yielding string terminations, which shall be considered separately in a later section. Stiffness in real strings tends to cause a certain inharmonicity in the partials. When a string is stiff, it does not like to be bent into too tight a radius of curvature. High spatial frequency modal shapes on a string have a shorter period wavelength along the string than do lower modes, hence higher frequency shapes must, on average, bend the string into a tighter curvature. The stiffness in the string tends to produce a greater restoring force on the string for higher modes than for lower modes. The result of this is that higher modes tend to travel faster on a stiff string than do low modes, which means that they will travel the length of the loop, up the string and back down the string, in a shorter time. Shorter loop travel time means higher audible frequency. 2.1.1 The Spectral Amplification Factors The introduction of loss and stiffness into the linear string equation modifies the travelingwave solution in two ways: (1) loss introduces an exponential decay into the traveling waves 30 31 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING z-N lossless traveling wave G(z) lumped attenuation H(z) phase correction Figure 2.1: Lumped Implementation of the Lossy Dispersive Traveling Wave in the direction of travel; (2) stiffness introduces a frequency dependence into the wave travel speed. As a result, waveshapes do not remain intact when they travel on a lossy stiff string. The spectral amplification factors for a general string with frequency-dependent loss and wave speed can be written as follows: g± (∆t) = e−∆t/τ (ω) e±jC(ω)∆t (2.1) where the frequency-dependent wave propagation speed is C(ω) and the frequency-dependent “time constant” of decay is τ (ω). 2.1.2 Commuted Summary Filter Implementation In the linear waveguide string model, we may gather the distributed loss over an unobserved section of string and lump it together in a single loss filter. We can do this because of the commutative and associative properties of linear systems (Karjalainen et al., 1993; Smith, 1993). Similarly, wave speed dispersion may be modeled by an appropriate summary allpass filter which corrects for the compound frequency-dependent phase delay in the same section of string (Karplus and Strong, 1983). The frequency-dependent phase response of the allpass filter can simulate the frequency traveling-wave speed, C(ω). In effect, the loop length of the waveguide string model will seem longer or shorter to different frequencies due to phase adjustment; and this is equivalent to making the various frequencies travel faster or slower. Figure 2.1 illustrates the lumping together of loss into a single attenuation filter, G(z), and dispersion effects into an allpass filter, H(z). 32 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 2.2 2.2.1 Stiffness in the Wave Equation The Bar Equation First, the extreme case of a stiff string is when it is so stiff it becomes a solid bar. The standard equation for wave propagation in a bar is given in (Morse and Ingard, 1968), 4 ∂ 2 y(t, x) 2 ∂ y(t, x) = −a ∂t2 ∂x4 (2.2) where we summarize physical stiffness and density factors in a2 . Transforming the Bar Equation Applying Fourier transform, we get the ordinary differential equation, ∂ 2 (yω ) (t) = −a2 (jω)4 yω (t) ∂t2 (2.3) Applying the Laplace transform, leads to s2 Yω (s) − syω (0) − ẏω (0) = −a2 (jω)4 Yω (s) (2.4) Solving for Yω (s) and making a partial fraction expansion, we have Yω (s) = = syω (0) + ẏω (0) s2 + a2 ω 4 yω− yω+ + s + jaω 2 s − jaω 2 (2.5) (2.6) Inverse Laplace transform to get 2 yω (t) = yω+ e−jaω t + yω− ejaω 2t (2.7) with spectral amplification factors ∆ gω± (∆t) = e∓jaω 2 ∆t (2.8) 33 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING Traveling-wave speed on the bar is spatial-frequency-dependent, ∆ C(ω) = − % gω± (∆t) = ∓aω ω∆t (2.9) Allowed Frequencies on a Bar Allowed frequencies on a hinged, vibrating bar of length, L, and spatial-frequency-dependent traveling-wave speed, C(ω) = ±aω, can be computed as follows: Rigid terminations reflect and invert traveling waves, so round-trip traveling-wave length of the bar system is 2L. Supported wave lengths, Tn , of partial frequencies allowed on the terminated string are Tn = 2L/n (2.10) where n = 1, 2, . . . are the partial frequency index numbers. Spatial frequencies associated with the partials would be ωn = 2π nπ = Tn L (2.11) ∆ With C(ωn ) = aω, the allowed partial frequencies, p(n) on the bar are computed as p(n) = C(ωn ) πn2 a ωn na = = Tn 2L 2L2 (2.12) which can be written, p(n) = n2 p(1) (2.13) Allowed frequencies increase as the square of the partial number. 2.2.2 The Stiff String Equation Somewhere between the ideal flexible string and the ideal bar, there is the stiff string, which has elements of both. The standard partial differential equation for wave propagation on a stiff string (Morse and Ingard, 1968) is given as 2 4 ∂2y 2∂ y 2∂ y = c − a ∂t2 ∂x2 ∂x4 (2.14) where we summarize the stiffness term as a2 . Notice this equation just combines the spatial derivative terms from both the flexible string and the bar equations. CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 34 Transforming the Stiff String Equation Applying Fourier transform, we get the ordinary differential equation, ∂ 2 (yω ) (t) = c2 · (jω)2 yω (t) − a2 · (jω)4 yω (t) ∂t2 (2.15) Applying the Laplace transform, leads to s2 Yω (s) − syω (0) − ẏω (0) = c2 · (jω)2 Yω (s) − a2 · (jω)4 Yω (s) (2.16) Solving for Yω (s) and making a partial fraction expansion, we have Yω (s) = = syω (0) + ẏω (0) + ω 2 (c2 + a2 ω 2 ) y− y+ √ω √ω + s − jω c2 + a2 ω 2 s + jω c2 + a2 ω 2 s2 (2.17) (2.18) Inverse Laplace transform to get, √ yω (t) = yω+ e−jωt c2 +a2 ω 2 √ + yω− ejωt c2 +a2 ω 2 (2.19) Spectral amplification factors are, ∆ √ gω± (∆t) = e∓jω∆t c2 +a2 ω 2 (2.20) Traveling-wave speed on the stiff string is spatial-frequency-dependent, ∆ C(ω) = − % gω± (∆t) # 2 = c + a2 ω 2 ω∆t (2.21) Allowed Frequencies on a Stiff String Allowed frequencies on a rigidly terminated vibrating stiff string of length, L, and spatial√ frequency-dependent traveling-wave speed, C(ω) = c2 + a2 ω 2 , can be computed as follows: Rigid terminations reflect and invert traveling waves, so round-trip traveling-wave length of the stiff string system is 2L. Supported wave lengths, Tn , of partial frequencies CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 35 allowed on the terminated string are Tn = 2L/n (2.22) where n = 1, 2, . . . are the partial frequency index numbers. Spatial frequencies associated with the partials would be ωn = 2π nπ = Tn L (2.23) The allowed partial frequencies, p(n) on the stiff string are computed as nc C(ωn ) = p(n) = Tn 2L 1 1+ a2 n2 π 2 c2 L2 (2.24) which can be expanded in a power series as p(n) = C(ωn ) nc = (1 + βn2 + . . .) Tn 2L (2.25) Compare this with the allowed frequencies for the ideal flexible string, nc/(2L). Here, β is a small stiffness factor that stretches the distance between partials as the partial number increases. One function corresponding to the frequency separations between the partials at a certain partial number is the derivative of the hypothetical continuous function through the partial frequency points, c cβ dp(n) = + n + ... dn 2L 4L (2.26) We pick this concept up in a Section 2.3.2. 2.2.3 A Piano String Example Piano strings are well-known to exhibit inharmonicity due to stiffness, especially in the lower octaves. Figure 2.2 shows measured frequency peaks for an A0 piano string (the lowest string on most pianos). The first 50 or so partials are shown as dots. Gaps indicate partials were not present at a high enough amplitude for reliable measurement. Measurements were made from sound recordings in matlab using peak tracking methods similar to those described in (Serra, 1997). The straight line indicates the expected partial CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 36 Figure 2.2: Measured Partials from an A0 Piano String frequencies for all partials as perfect harmonic multiples of the fundamental frequency, 27.5Hz. The bending upward of the sequence of partial frequency points on the graph indicates that the partials are getting further and further apart. Much more detailed analysis and re-synthesis of piano string sounds has been undertaken in (Bensa, 2000). Figure 2.3 shows the frequency difference between adjacent partials. The data is somewhat quantized due to a peculiarity of the analysis technique; however, we can interpolate a line through the data points and note that the rate of increase in distances between the partials is approximately linear. This implies that the partial frequency number curve contains something close to a square term, as expected. Appendix C explores the nature of partial stretching in low piano strings, and describes a novel inharmonic FM-based synthesis method, first published in (Van Duyne, 1992). 2.2.4 The More General Lossless Equation If we wish to derive a general differential equation for a an ideal lossless isotropic string with arbitrary stiffness, or rather, arbitrary wave travel speed, it is convenient to start in the Laplace/Fourier domain defining the spectral amplification factors. We wish the spectral amplification factors to reflect that the medium can support 1-D traveling waves in opposite directions which have a frequency-dependent speed of travel and which are CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 37 Figure 2.3: Measured Frequency Distance Between the A0 Partials symmetric in their speed with respect to direction. The wave travel in this medium may be described with a system, Yω (s), which is characterized by two conjugate poles in the Laplace domain. The two poles correspond to the two traveling-wave directions, and their magnitudes should be 1 corresponding to lossless wave travel, and their phases correspond to wave speeds of the spatial frequency components. Let us assume we have a continuous differentiable function describing the wave propagation speed for each ω as C(ω). Thus we can write the spectral amplification factors for the desired partial differential equation as g± (∆t) = e±jωC(ω)∆t (2.27) Not worrying about the initial conditions for this analysis, this corresponds to the secondorder system, Yω (s) = = α+ α− + s − jωC(ω) s + jωC(ω) A(s) s2 + ω 2 C(ω)2 (2.28) (2.29) Since C(ω) is an even real function with non-negative real values, we can re-write ω 2 C(w)2 38 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING as a function of ω 2 , defining Γ thus, √ ∆ Γ(η) = ηC( η)2 (2.30) and make the substitution, Yω (s) = A(s) A(s) = 2 s2 + ω 2 C(ω)2 s + Γ(ω 2 ) (2.31) or, s2 Yω (s) + Γ(ω 2 )Yω (s) = A(s) (2.32) For now, let us assume Γ to be a well-behaved, continuous and differentiable function. We can then expand it in power series in ω 2 around zero to obtain, Γ(ω 2 ) = ∞ $ cn ω 2n , ∆ cn = n=0 1 dn Γ 22 2 n! dη n η=0 (2.33) We can re-write Γ(ω 2 ) as sums of powers of (jω)2 noting that ω 2n = (−1)n (jω)2n (2.34) and substitute everything back into 2.32 to get, 2 s Yω (s) + 3 ∞ $ n=0 n 2n 4 (−1) (jω) cn Yω (s) = A(s) (2.35) Noting that A(s) was a first-order polynomial in s corresponding to the initial spatial spectral conditions, we can now inverse Laplace transform to the time domain, and inverse Fourier transform to the space dimension to obtain the general differential equation ∞ ∂2y $ ∂ (2n) y n + (−1) c =0 n ∂t2 n=0 ∂x(2n) (2.36) This is an equation whose solutions are a sum of spatial frequency waves which travel in left and right directions at the same rate of speed, and at only one speed for each spatial frequency. The wave speed dispersion comes from the even space derivatives. The CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 39 reason that there may only be even-ordered partial space derivatives is that the frequencydependent decay rates and wave speed functions are even with respect to positive and negative values of ω. This means that phase of the roots of the characteristic polynomial in 2.31 are the same for positive and negative frequencies. Hence, speed of travel and decay rates are the same for left and right going waves. 2.3 Modeling Stiffness in the Digital Waveguide Delay lines do not have stiffness: all the frequencies of a signal travel at exactly the same rate of speed in a delay line, precisely one spatial sample per time sample. But there are filters which can modify the phase delay of a signal in a frequency-dependent way without affecting the signal’s magnitude spectrum. These are known as allpass filters. All frequencies pass through these filters without modification of their magnitudes, however their phases may be modified. Technically, a delay line is a kind of allpass filter: it modifies the phase of the input signal in such a way that all frequencies are delayed by exactly the same number of samples. In order to simulate the behavior of stiff strings, however, we must create the effect of higher frequency modes traveling faster than lower frequency modes. 2.3.1 Introducing Stiffness with Allpass Filters By a fortunate coincidence, a set of cascaded first-order allpass filters will produce the qualitatively correct kind of stiffness effects, and can be controlled by a single parameter. We will show that the effect on inharmonicity of cascaded first-order allpasses embedded in a feedback delay loop is qualitatively similar to the effect of real stiffness on real strings. That is, the general way in which partials of a real stiff string stretch apart and get more and more out of tune as one progresses up the spectrum, is qualitatively similar to the way in which the modes of a delay line loop will stretch apart in the presence of cascaded allpass filters. First-order allpass filters, in their less severe ranges of operation, have long been used for fractional tuning, as was discussed in Chapter 1. The use of allpass filtering to introduce dispersion into feedback delay loops has been known for some time (Jaffe and Smith, 1983). Stiff string sounds have been generated with excellent results, (Paladin and Rocchesso, 1992) on the MARS workstation in real–time using a group delay based CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 40 analysis approach to the stiff string equation, and using one of the allpass filter design methods in the literature such as that proposed by (Yegnanarayana, 1982) to find allpass filter coefficients for a desired group delay response. However, the order of allpass filters found by these methods can become large, requiring a fair amount of computation; and finding the coefficients requires a sophisticated filter design algorithm. A simplified approach to the filter design is described here, first published in (Van Duyne and Smith, 1994). It is based on building up stiffness modeling allpass filters out of firstorder blocks. These filters are designed to be multiply–free when implemented directly in hardware by virtue of choosing a coefficient which may be computed with a binary shift and at most one add. Alternatively, when number of multiplies is not a concern, amount of stiffness in a string model may be controlled in real time by a single filter coefficient. More recently, the idea of cascaded first-order allpass to model stiffness, which is described in the following paragraphs, has been extended in (Rauhala and Välimäki, 2006) by identifying and applying a closed-form expression to determine the filter coefficients based on a tunable dispersion filter design method. In addition, a novel allpass design method is described in (Abel and Smith, 2006) where, to match a given high-order group delay response curve, the frequency axis is broken up into sections containing 2π total area under the desired group delay curve, and a pole–zero allpass pair is assigned to each. 2.3.2 Rate of Stretching in the Partials of Stiff Strings We first consider the the qualitative way in which partials are detuned on a stiff string. In the ideal flexible, i. e., non-stiff, string, the modes are harmonically related. We can say, p(n) = np(1) (2.37) where p(1) is the fundamental frequency of the string, n is the harmonic number, and p(n) is the frequency of the nth harmonic. For the stiff string, however, higher spatial frequencies travel faster than lower spatial frequencies, causing the higher partials to become farther apart than the lower. The partial frequencies may be approximated as, , p(n) ≈ n α + βn2 - (2.38) (Morse and Ingard, 1968), where β is a small inharmonicity factor, and the fundamental frequency is p(1) = α + β. As n gets large, and higher order terms come into play, 41 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING .01 0.01 0.008 0.006 .005 S’(p0) 0.004 0.002 5000 10000 10kHz 15000 p0 20000 20kHz Figure 2.4: Rate of Stretching for Hypothetical A0 this approximation breaks down. From Equation (2.38), we can say that the frequency separation between the partials, S(p0 ), at some point in the spectrum, p0 , is approximately, ∆ S(p0 ) = p(n0 + .5) − p(n0 − .5) ≈ p& (n0 ) (2.39) ∆ where p0 = p(n0 ). We defined p& (n) = dp/dn in an earlier section, however it is a function of partial number, n. In the following analysis we will need the rate of stretching to be a function of the partial frequency, which is a slightly warped version of this function. The rate at which the partial frequency separation changes per unit of spectrum height, i. e., the rate of stretching at a given spectral frequency, p0 , may be defined as the derivative of S with respect to p0 . Using the chain rule, we have, ! "! " dS dS dn0 p&& (n0 ) S (p0 ) = = = & dp0 dn0 dp0 p (n0 ) & (2.40) Figure 2.4 shows a plot of the rate of stretching, S & , for a hypothetical low A0 piano string with a reasonable inharmonicity factor of β = .001 assumed, and partial frequencies defined as, , pA0 (n) = n 27.499 + .001n2 - (2.41) If the value of S & were constant at .01, the separation between adjacent partials would CHAPTER 2. INHARMONICITY, DECAY AND COUPLING + z−N 42 HM Figure 2.5: Dispersive Delay Loop System increase at the rate of 10Hz per kHz of spectrum. At the fundamental, the partials would be about 27.5Hz apart; at 1000Hz they would be about 37.5Hz apart, and so on. Actually, the plot shows that the rate of stretching is not flat. Rather, it ramps up from zero (rate of zero meaning the partials are exactly harmonic), reaches a maximum, and drops slowly as we get higher into the spectrum. It is this qualitative shape of the rate of stretching curve which leads us to model dispersion in stiff strings with cascaded one-pole allpass filters. 2.3.3 Rate of Stretching in the Modes of a Delay Loop with Cascaded One-Pole Allpass Filters A resonant loop consisting of a length N delay line and a block of M cascaded one-pole allpass filters is shown in Figure 2.5. The transfer function one time around the loop is, ∆ L(z) = z −N H(z)M (2.42) We compute the phase response of L to be, ∆ θ(ωT ) = % L(ejωT ) = −N ωT + M φ(ωT ) (2.43) For frequency ωk T to be supported on this loop, θ(ωk T ) must equal −k2π, for some positive integer k. In fact, k = 1 implies ωk T is the fundamental, k = 2 implies ωk T is the second partial, and so forth. Figure 2.6 compares the supported modes for a loop of the form z −(N +M ) with a loop of the form z −N H(z)M , where N = 8, M = 1, and a0 = −0.8. The ωi T are the harmonics of the pure delay loop, and the ω̂i T are the inharmonic partials of the delay plus allpass loop. Comparing the ω̂i T with the ωi T , it seems clear that ω̂1 T is less than ω1 T , that the spacing between ω̂1 T and ω̂2 T is about the same as that between ω1 T and ω2 T , and that 43 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING ^ T ω 1 0 0 ω1T ^ T ω 2 ω2T ^ T ω 3 ω T 3 ^ T ω 4 ω4T π −2π θ(ωΤ) −4π −6π −8π Figure 2.6: Modes on z −N H(z) vs. Modes on z −(N +1) the spacing between ω̂2 T and ω̂3 T is greater than that between ω2 T and ω3 T . This means that the ω̂i T are stretching partials. In general, the choice of a0 negative will produce a stretching in the resonant modes of the loop. The more negative it is, the more the stretching will be, at least in the lower frequency range. We can make a qualitative comparison between the kind of stretching in the delay line loop with that found in stiff strings by computing a rate of stretching function for the digital loop. We derive Sθ (ωk T ) = −2π/θ & (ωk T ) to be the separation between partials on the loop at a particular point in the normalized frequency spectrum, ωk T , where ωk is the kth partial frequency in radians per second. The rate of partial stretching per unit of spectrum on the digital loop is the derivative of Sθ with respect to ωk T , Sθ & (ωk T ) = −2π θ && (ωk T ) θ & (ωk T )2 (2.44) Figure 2.7 shows a plot of Sθ & for the delay line loop system shown in Figure 2.5 with delay line length,N = 8, number of first-order allpass filters, M = 1, and allpass coefficient, a0 = −0.25. Comparing the physical rate of stretching, S & , in Figure 2.4 with the digital loop rate of stretching, Sθ & , one can see a qualitative correspondence: each plot 44 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING .04 0.04 0.03 Sθ’(ωkT) .02 0.02 0.01 0.5 1 1.5 π/2 2 2.5 3 π ωk T Figure 2.7: Stretching of Partials on a Delay Loop ramps up from zero, reaches a maximum, then falls off. If we choose N , M , and a0 well, we can approximate partials of a real stiff string. 2.4 2.4.1 Internal Loss in the Wave Equation Physically Valid Forms of the 1-D Isotropic Wave Equation If we desire to express the general differential equation for a an ideal isotropic string with arbitrary stiffness and loss, it is convenient to start in the Laplace/Fourier domain defining the spectral amplification factors. We wish the spectral amplification factors to reflect the idea that the medium can support 1-D traveling waves in opposite directions which have a frequency-dependent decay time and a frequency-dependent speed of travel, and which are symmetric in their speed and decay rates with respect to directions. The wave travel in this medium may be described with a system, Yω (s), which is characterized by two damped conjugate poles in the Laplace domain. The two poles correspond to the two traveling-wave directions, and their magnitudes and phases correspond to the decay rates and wave speeds of the spatial frequency components. Let us assume we have continuous differentiable functions describing the time constants of decay for each ω as τ (ω) and the wave propagation speed for each ω as C(ω). Thus we 45 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING can write the spectral amplification factors for the desired partial differential equation as g± (∆t) = e−∆t/τ (ω) e±jωC(ω)∆t = e∆t[−1/τ (ω)±jωC(ω)] (2.45) Not worrying about the initial conditions for this analysis, this corresponds to the two pole system, Yω (s) = = α+ s− * s2 + −1 τ (ω) * ++ − jωC(ω) A(s) 2 τ (ω) + s+ * 1 τ (ω)2 s− * α− −1 τ (ω) + ω 2 C(ω)2 + + jωC(ω) + (2.46) (2.47) Since C(ω) and τ (ω) are even functions with non-negative real values, we can define √ ∆ B(η) = 2/τ ( η) √ √ ∆ Γ(η) = 1/τ ( η)2 + ηC( η)2 (2.48) (2.49) and make the substitution, Yω (s) = s2 A(s) + B(ω 2 )s + Γ(ω 2 ) (2.50) or, s2 Yω (s) + B(ω 2 )sYω (s) + Γ(ω 2 )Yω (s) = A(s) (2.51) For now, let us assume B and Γ to be well-behaved, continuous and differentiable functions. We can then expand them in power series in ω 2 around zero to obtain, B(ω 2 ) = Γ(ω 2 ) = ∞ $ n=0 ∞ $ ∆ bn ω 2n , bn = cn ω 2n , cn = ∆ n=0 1 dn B 22 2 n! dη n η=0 1 dn Γ 22 2 n! dη n η=0 (2.52) (2.53) We can re-write B(ω 2 ) and Γ(ω 2 ) as sums of powers of (jω)2 noting that ω 2n = (−1)n (jω)2n (2.54) 46 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING and substitute everything back into 2.51 to get, 2 s Yω (s) + 3 ∞ $ n 2n 4 (−1) (jω) bn sYω (s) + n=0 3 ∞ $ n=0 n 2n 4 (−1) (jω) cn Yω (s) = A(s) (2.55) Noting that A(s) was a first-order polynomial in s corresponding to the initial spatial spectral conditions, we can now inverse Laplace transform to the time domain, and inverse Fourier transform to the space dimension to obtain the general differential equation ∞ ∞ ∂2y $ ∂ (2n) y ∂ (2n+1) y $ n n + (−1) c =0 + (−1) b n n ∂t2 n=0 ∂t∂x(2n) n=0 ∂x(2n) (2.56) This is an equation whose solutions are a sum of spatial frequency waves which travel in left and right directions at the same rate of speed, and at only one speed for each spatial frequency. The wave speed dispersion comes from the even space derivatives, and the damping comes from the mixed first time derivative and even-ordered space derivatives. The reason that there may only be even-ordered partial space derivatives is that the frequency-dependent decay rates and wave speed functions are even with respect to positive and negative values of ω. This means that phase and damping of the roots of the characteristic polynomial in Equation (2.50) are the same for positive and negative frequencies. Hence, speed of travel and decay rates are the same for left and right going waves. It is also essential the there are no higher-order derivatives of s, since, for example, if a third-order time derivative were present, resulting in an s3 term in the denominator of Equation (2.50), then we would have three roots, one of which must be real and, therefore, non-traveling. If there were a fourth-order time derivative in the wave equation (2.56), there would be an s4 term in (2.50) resulting in possibly two pairs of conjugate roots, corresponding to potentially two sets of traveling waves at the same spatial frequency but traveling at different speeds. The differential equation (2.56) is the “anatomically correct” class of wave equations we can model with bidirectional delay lines and allpass filters and low pass filters to model stiffness and loss. 47 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING Understanding Morse’s Lossy String Equation In an earlier section, we presented the stiff string equation taken from (Morse and Ingard, 1968). It contained second and fourth order spatial derivatives. This is consistent with our general wave equation (2.56). However, the lossy string equation provided in (Morse and Ingard, 1968) is puzzling at first: - ∂2y ∂2y ∂y = T 2 − R(ω) 2 ∂t ∂x ∂t (2.57) - is density per unit length, T is tension, and R(ω) represents the effective frictional resistance per unit length. What does it mean to have R(ω) a function in the frequency domain, mixed into the partial differential equation in x and y? In fact, we need to view R(ω) as a differential operator on the first partial time derivative, rather than a function of ω multiplied pointwise by the first time derivative. Thus, ∂y R(ω) −→ Rω ∂x 5 ∂y ∂x 6 ∆ =- ∞ $ n=0 (−1)n bn ∂ (2n+1) y ∂t∂x(2n) (2.58) In other words, Morse’s R(ω) frictional resistance term has to be incorporated into the equation in the frequency domain, and then expanded back out to the time domain. Another minor detail to keep in mind is that the loss profile impacts the coefficients on the stiffness-related partial derivatives as well, as we saw above. 2.4.2 Parameterizing the Wave Equation from Measured Data Till now we have assumed that the decay rate and wave speed functions have been ideal continuous differentiable functions. In practice, we may be able to measure actual data points for decay rate and wave speed at a certain spatial frequency, deduced from string length, pitch of the vibrating string’s partial frequency, and measured rate of decay in audio amplitude. Hence, if we actually know only τ (ωk ) and C(ωk ) for several data points, ωk for k = 1, 2, 3, . . ., then we can compute B(ωk2 ) and Γ(ωk2 ) from Equations (2.48) and (2.49) and then fit a kth order polynomial through the points, reducing the infinite series of high even order spatial derivative terms in Equation (2.56) to a finite set of high-order terms. CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 2.5 2.5.1 48 Loss and Dispersion at the Termination Lumped Impedance Impedance is some measure of how a physical system reacts to stimulus. It is defined as the complex ratio of the force applied to the resultant velocity of a system. It is most sensibly defined in the Laplace frequency domain. ∆ R(s) = F (s)/V (s) (2.59) where F and V are the Laplace transforms of force and velocity, respectively, R(s) is the impedance ratio, and s is the Laplace frequency variable. Replacing s with jω gives the frequency response of the system. The magnitude part of R(jω) tells us the magnitude ratio between force and velocity at some particular frequency ω, and the phase part tells us the phase difference between force and velocity oscillations at that frequency. For example, an oscillating mass and spring system will have a zero impedance when driven at the mass end at its resonant frequency, as it is very content to oscillate at that frequency. When driven at other frequencies, it has a non-zero impedance. On the other hand, a purely damped, non-reactive linear system, such as a dashpot or an electrical resistor, has a constant real impedance (Cruz and Van Valkenburg, 1974), which means force is in phase with velocity (or voltage is in phase with current) and there is no frequency dependence on the ratio of force and velocity magnitudes. 2.5.2 Force Waves, Velocity Waves, and Wave Impedance A variety of physical variables of the string may be expressed as the sum of traveling waves in addition to displacement. We will be particularly interested in force and velocity waves. Transverse velocity waves may be defined by taking the partial derivative of (1.4) with respect to time. ∆ v(t, x) = ∂y ∆ = −cẏ + (x − ct) + cẏ − (x + ct) = v + + v − , ∂t (2.60) where ẏ + and ẏ − are the first derivatives of y + and y − , respectively. Similarly, we may define transverse force waves by noting that the force which the left portion of the string exerts on the right portion across a point on the string is approximated 49 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING Wave Impedance R0 fr fl k Figure 2.8: String Terminated by Simple Spring for small displacements by, ∆ f (t, x) = −K ∂y ∆ = −K ẏ + (x − ct) − K ẏ − (x + ct) = f + + f − ∂x (2.61) Combining (2.60) and (2.61), we find a wave impedance relationship between the traveling components of force and velocity in the string which can be written, f + = R0 v + and ∆ f − = −R0 v − where the wave impedance is defined as R0 = K/c = √ (2.62) K-. This relationship corresponds to the wave impedance relation between pressure and flow in acoustic tubes, or between voltage and current in electrical transmission lines (Magnusson, 1970). 2.5.3 Terminating a String at a Lumped Impedance When a string is terminated perfectly rigidly, traveling waves reflect off the termination and head back the other way without modification, with the exception of possible sign inversion: velocity and displacement waves reflect with sign inversion, while force waves reflect without sign inversion. However, there are many ways to terminate a string. Figure 2.8 shows, for example, the ideal case of a string terminated by a pure lossless spring. The more likely case in the real world is that a string is terminated at some nearly rigid bridge which has some resistive damping, some springiness and some mass. The result is that a given sinusoidal component of a traveling wave is reflected off the yielding termination with some damping and some phase modification. It is useful to formulate lumped 50 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING systems such as a simple linear string termination in terms of their driving point impedance. Impedance is the complex ratio of force and velocity in the Laplace transform frequency domain. At the string termination, we have, ∆ Rb (s) = F (s) , V (s) (2.63) where Rb (s) is the driving point impedance function of the string termination (“b” for “bridge”), and F and V are the Laplace transforms of driving point force and velocity. For example in the spring termination shown in Figure 2.8, Rb (s) = k/s, where k is the spring stiffness constant, and s is the Laplace frequency variable. Using definitions of force and velocity waves on the string, (2.60) and (2.61), and the wave impedance relation, (2.62), we may derive a force wave transfer function at the string termination: F (s) = Rb (s)V (s) F + (s) − F − (s) F + (s) + F − (s) = Rb (s) R0 R (s) − R 0 + b F − (s) = F (s) Rb (s) + R0 (2.64) (2.65) (2.66) The Bilinear Transform To move from the continuous physical system to the discrete digital filter, we use the conformal bilinear transform from the s-plane to the z-plane, s←α 1 − z −1 1 + z −1 (2.67) The bilinear transform maps DC in the continuous system to DC in the digital system, while mapping infinite frequency in the continuous system to half the sampling rate, or the Nyquist frequency, in the digital system (Nehari, 1952). The parameter α is a degree of freedom which may be used to control the frequency warping. It is usual to choose α = 2/T to obtain faithful frequency response at the low end of the frequency range. We apply the bilinear transform to Equation (2.66) to obtain, F − (z) = Hb (z)F + (z) (2.68) 51 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING R0 R0 R0 m1 R0 k1 . k2 k3 . m2 m3 k5 m4 k6 k4 M=2 M=4 M=3 M=1 Figure 2.9: Mass/Spring Chain String Terminations In the spring termination case, Hb (z) = 2.5.4 a0 + z −1 1 + a0 z −1 and a0 = k − αR0 k + αR0 (2.69) Interpreting Stiffness Allpasses as a Termination Impedance In Section 2.3, we introduced cascaded allpass filters into the delay line loop to create the effects of stiffness in the medium, which results in higher spatial frequencies traveling at slightly higher speeds. It is of some interest to “reverse engineer” the process, to find out what equivalent lumped impedance termination fo the string would produce a similar impact on an ideal flexible string. A delay line loop with a one–pole allpass filter in it may be interpreted as an ideal string terminated with an ideal spring, as is shown in Figure 2.9 for the M = 1 case. The loop computes traveling force waves, where the allpass filter is a transfer function from the right–going force wave, F + , to the left–going force wave, F − , at the spring termination. ∆ Given an arbitrary termination impedance, F (s)/V (s) = R(s), the force wave transfer function is, F− R(s) − R0 = + F R(s) + R0 (2.70) CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 52 where R0 is the wave impedance of the string, which is the geometric mean of its tension and mass density. When two transfer functions corresponding to two termination impedances, R1 (s) and R2 (s), are cascaded in the loop, we find, F− = F+ where, ! R1 (s) − R0 R1 (s) + R0 "! R2 (s) − R0 R2 (s) + R0 " = R̃(s) − R0 R̃(s) + R0 R1 (s)R2 (s) + R0 2 F = R̃(s) = V R1 (s) + R2 (s) (2.71) (2.72) Hence, comparing Equations (2.70) and (2.72), we see that the physical termination impedance actually modeled by the two cascaded wave transfer functions is R̃(s). We learned in an earlier section that the wave transfer function for a spring termination corresponded to a first-order allpass function. If we then cascade two equal allpass functions, corresponding to wave transfer functions in the Laplace domain, R1 (s) = R2 (s) = k/s, we can compute the implied termination impedance as R̃(s) = (k/s)2 + R0 2 k/2 R0 = + s 2(k/s) s 2k (2.73) This is just a mass-spring system, where the spring stiffness coefficient is k/2 and the mass is m = R0 /2k. Using a similar analysis procedure, we may derive the physical string termination impedances for the cascaded digital allpass filters, H M , described earlier. H 1 ⇐⇒ k1 /s H 2 ⇐⇒ m1 s + k2 /s H 3 ⇐⇒ (k3 /s).(m2 s + k4 /s) H 4 ⇐⇒ m3 s + ((k5 /s).(m4 s + k6 /s)) (2.74) (2.75) (2.76) (2.77) ∆ where a.b = ab/(a + b) is a parallel connection of two elements, and all the spring stiffness constants, ki , and masses, mi , are dependent on k1 and the string wave impedance, R0 . The physical meanings of these termination impedances are illustrated in Figure 2.9. We conclude that a delay loop with cascaded one–pole allpass filters corresponds to a distributed transmission line string model extended by a non-uniform lumped transmission 53 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING z-N/2 H G T1 T2 G H z-N/2 Figure 2.10: Waveguide String Loop Model Including Loss, Dispersion, and Yielding Terminations line model of chained masses and springs. 2.6 2.6.1 Calibrating the Digital Waveguide String Model The Summarized Loop Model The lossy, stiff string may be modeled as a digital waveguide with termination filters, internal string loss filters and allpass filters modeling dispersion as shown in Figure 2.10. In the Figure, z −N/2 represents the basic delay time in in samples for a wave to travel from one end of the string to the other; H represents the allpass modification to this length correcting for dispersion in wave speed due to stiffness; G is a low pass filter representing total energy loss in the traveling wave as it goes from one end of the string to the other; and T1 and T2 represent digital wave transfer functions corresponding to yielding terminations. These termination filters may contain a loss part due to damping and a phase modifying part due to the reactive elements such as springiness in the terminations. To understand the simplified model, note that a traveling wave, as it makes its way one complete cycle around the loop in Figure 2.10 sees a total closed loop transfer function of, Ltotal (z) = z −N/2 H(z)G(z)T1 (z)z −N/2 H(z)G(z)T2 (z) (2.78) This may be commuted and refactored into a delay part, a loss part represented by a lowpass filter, LP (z) and a phase dispersion part represented by an allpass filter, AP (z). Ltotal (z) = z −N LP (z)AP (z) (2.79) CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 54 z-N LP(z) AP(z) Figure 2.11: Simplified String Loop This simplified formulation is shown in Figure 2.11. The problem of model calibration is now reduced to choosing a delay length, N , and coefficients for the allpass filter AP (z) to tune the string partials, and designing a lowpass filter, LP (z), which gives the correct overall exponential decay rates of each partial per loop period. 2.6.2 Calibration Approach The actual per period rate of attenuation of this simple string model is determined by the magnitude response of of the low pass filter in the delay loop. The more severe the roll-off of the filter over the frequency spectrum, the faster the high frequencies in the loop will decay compared with the low frequencies. Calibration schemes for the delay line loop models of strings are generally based on measuring the decay rates of the individual partials of a real string, and then fitting a filter magnitude response curve through those data points. One approach to calibrating a physics based digital waveguide model is to make the appropriate physical measurements of material properties of the string, namely string tension and mass density per unit length; to estimate loss from viscous drag in the air we must know the diameter; to estimate internal damping we must determine the complex Young’s modulus of the string material; to estimate the wave speed dispersion in a stiff string, we must determine in addition the radius of gyration which is dependent on the strain in the string material as it is distributed over the cross-sectional area of the string. To estimate the termination transfer functions, we must first come up with an impedance function for the terminations, which may be done either by imagining a lumped system mechanism for CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 55 the termination behavior and computing parameters from information about the materials somehow, or by collecting force response data from measurements taken directly from the instrumented terminations, and then performing system identification on the data to obtain a lumped impedance model which can then be mapped to the digital domain and converted into wave transfer functions. This is too hard, and fraught with opportunity for error. For our modeling purposes, we ultimately only care about what it sounds like, so we can use a simpler more direct calibration approach. The goal of this present work is, not so much to study the details of the physics of musical instruments, but instead to develop an efficient audio synthesis model which produces sounds which are psychoacoustically indistinguishable from the real thing. To this end, a simplified model is proposed which may be directly calibrated from recorded sound data, without concern about where exactly the system loss and dispersion is coming from, only what the net effect of all the physical considerations is. Presentation of techniques and theory for this system identification problem can be found here and there in the literature. System identification techniques applied to the bowed string are found in (Smith, 1983). Methods for loop estimation in plucked string and guitar sounds are described in (Karjalainen et al., 1993). Calibration of the coupling filter in coupled piano strings is addressed in (Van Duyne and Smith, 1995b). A calibration method for stiffness in strings is published in (Van Duyne and Smith, 1994). A method to calculate the coupling filter from measured decay rates for a wave-decomposed coupled oscillator system is described in (Van Duyne, 1997). Some clues to the inner workings of the Korg OASYS synthesizer calibration methods were brought to light during presentation of (Leary, 1996) and Staccato Systems revealed some of their physical model calibration techniques while demonstrating (Porcaro et al., 1996). 2.6.3 Obtaining the Data Directly from an Audio Recording For our modeling purposes, we require the exact frequencies of the resonant modes on the string to design the delay loop length and the allpass filter coefficients; and we require the exponential decay rates of each of the partials in order to design the lowpass loop gain filter. We can obtain data in this form from a recorded string sound using short time Fourier analysis and a peak tracking algorithm. Essentially, we may take a representative clip of the recorded string sound and break it up into sequential time frames separated by M seconds. We may then perform a peak extraction procedure to identify the frequency CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 56 and magnitude of the partials present in each frame. In general, for a simple linear string we should expect the partial frequencies in each frame to be the same, or very close. These partial frequencies may be called, p(n), where n is the partial number, p(1) being the fundamental frequency, p(2) being the first overtone, i. e., second partial, and so on. Further, we may track the magnitude evolution of these partial frequencies across the frames in order to obtain amplitude trajectory envelopes for each of the partials, in the form An (mM ), where n refers to the nth partial frequency, m is the mth analysis frame index, mM is the time index of the mth frame in seconds, and An (mM ) is the measured amplitude of the nth partial at time mM . In this way, we obtain a set of partial frequencies on the string, p(n) and their amplitude decay trajectories over time, An (mM ). Fundamental work in this field is reported in (Serra, 1997). We can fully identify the salient audible parameters needed for calibrating a simple stiff string model, without resorting to any physical measurements, or calculations. 2.6.4 Calibrating Loop Stiffness from Recorded Data As noted earlier, new methods of modeling and calibrating dispersion in piano strings have been described in (Bensa, 2000; Rauhala and Välimäki, 2006; Abel and Smith, 2006). We turn now to the present task of parameterizing the cascaded allpass model of string stiffness presented in Section 2.3. To design a resonant loop of the form z −N H M , we must find a good a0 , M , and N . We present two parameter optimizing methods. First Optimization Method This first method is appropriate for implementation in hardware where multiply operations are costly to implement in silicon. We reduce the field of search by requiring that the filter coefficient, a0 , be a power of 2, or 1 minus a power of 2, so that the multiply may be implemented efficiently in hardware as a binary shift plus at most one addition. Coefficients closer to zero provide the most even stretching of partials, but the number of allpasses needed will be greater; whereas, coefficients closer to −1 will necessitate less filters in the loop, but the effect will be biased in favor of stretching at the lower frequencies. We can eliminate N as a variable by requiring that one of the partial frequencies on the 57 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 1 nθ(n) - n 0.75 0.5 0.25 5 15 10 20 -0.25 -0.5 -0.75 M=0 M=1 M=2 M=3 M=4 M=5 -1 n Figure 2.12: First Allpass Parameterization Optimization Method loop be held constant. The necessary value for N may be computed as, N= 2πn0 + M φ(2πp(n0 )T ) 2πp(n0 )T (2.80) Choosing n0 = 1 holds the fundamental fixed. In the case of missing data, or in the case of very low piano strings, where the perceived pitch is more a function of the partials an octave or two above the fundamental, it may be desirable to hold some other partial fixed. Assume that we have a set of partial frequency measurements, pi = p(ni ), for a set of partial indices, ni . Given a0 , we can compute the apparent partial number, nθ (ni ), on the delay line loop for each of the measured partial frequencies, p(ni ), nθ (ni ) = θ(2πp(ni )T )/(−2π) (2.81) and compare it to the actual partial number for that frequency, ni . If the digital loop is a perfect match for the data, then nθ (ni ) will equal ni . If not, we can nonetheless minimize a least sum of squares error function, ε(M ) = $ i (nθ (ni ) − ni )2 (2.82) 58 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING Figure 2.13: Parallel Computation Structure for Cascaded Allpasses As an example, we measured the first 22 partial frequencies of a recorded E2 piano tone. Choosing a0 = −.75, we obtained the best fit parameters, M = 2 and N = 255. Figure 2.12 plots the difference between the apparent partial index on the digital loop, nθ (ni ), and the actual partial index for each of the measured partial frequencies, ni , for values of M from 0 (no allpass filters) to 5 (five allpass filters). It is fairly clear from the figure that M = 2 is a good choice. That is, we need only two allpass filters, with coefficient a0 = −.75. Note that M = 1 would be a good choice if we only cared about the accuracy of the first 10 or 15 modes. This becomes a psychoacoustical level of detail trade-off problem. If we choose a more relaxed allpass coefficient, a0 = −.5, and perform a similar analysis, we arrive at an optimal combination of N = 221 and M = 16. For practical purposes, using the a0 = −0.75, M = 2 choice will be a lot less computation. On the other hand, if implementation in silicon is planned, the 16 allpass filters can be arranged in parallel . bucket–brigade alternation by reformulating z −221 H 16 as z −205 z −1 H /16 , thereby double buffering the allpass filters as shown in Figure 2.13. This means all the filters can be computed in parallel. Second Optimization Method In an implementation where multiplies are not costly to compute, such as on a standard DSP for example, but, on the other hand, where the number of allpass filters used, M , is limited by available program memory and computational speed requirements, we may modify the optimization procedure accordingly: In this case, we may let M be constant (chosen as large as possible within the hardware constraints) and choose the optimal a0 and N to fit the partial frequency data. It is most efficient to investigate the error in the modeled partials resulting form various CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 59 choices of N (delay line length), when, for each N we choose a corresponding a0 which fixes some desired partial (usually the fundamental) to be exactly in tune. We can then obtain a least squares error function dependent on N instead of M , where nθ is dependent on a0 which depends on N : ε(N ) = $ i (nθ (ni ) − ni )2 (2.83) Given a constant M , and a choice of N , the correct a0 which holds the kth partial fixed in tune on the loop is: a0 (N ) = −κ − srqt(κ2 + 1) sin2 2πp(n0 )T κ cos 2πp(n0 )T − sin 2πp(n0 )T (2.84) N 2πp(n0 )T − k2π M (2.85) where, ∆ κ = tan Choosing the Right N A practical approach in determining the best value of N, delay line length, is to choose a first guess as N = IntegerP art(samplingRate/theoreticalF undamental) − M ; (2.86) This is the natural delay line length, assuming M allpass filters, each representing a delay of at least 1 sample. For this value of n, find the best a0 . Then decrement N and iterate. Stop decrementing N when the sum of squares partial frequency match up error is at a minimum. A similar algorithm can be used to sort through non-integer values of N inserting an allpass fractional delay interpolator into the loop. 2.6.5 Calibrating Loop Loss From Recorded Data Recall, An (tm ) represents the amplitude of the nth partial at time tm , as analyzed from recorded data. Define Ãn (tm ) = An (tm ) An (0) (2.87) CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 60 where tm = mM is the time in seconds of the mth data frame, and Ãn (tm ) is the amplitude trajectory of the nth partial, normalized so that Ãn (0) = 1. Since we are assuming a linear system, we expect an exponential decay of the form, Ãn (tm ) ≈ e−rn tm (2.88) where rn is some decay rate for the nth partial between 0 and 1. Taking the natural log of both sides, we see that, log Ãn (tm ) ≈ −rn tm (2.89) This reduces, therefore, to the task of fitting the log scale amplitude data to a straight line of some slope, −rn . To find an rn for the measured data, we may use an error criterion based on the sum of squared differences, ε(rn ) = $, log Ãn (tm ) + rn tm m -2 (2.90) Minimizing this error function over rn , we obtain a decay rate for the nth partial. In designing the loop loss filter, LP (z), we desire that this filter provide sufficient frequency-dependent loss to account for the attenuation through one full cycle of the string loop. Since the essential loop time is N samples, or, N T seconds, where T is the digital sampling interval, and since the attenuation of the nth partial in N T seconds is e−rn N T , we may design LP (z) by fitting it to a magnitude spectrum based on the loop attenuation of the partials, |LP (ej2πp(n)T )| = e−rn N T (2.91) As an example, Figure 2.14 shows (above) measured decay rates of a piano note C5 (one octave above middle-C). The lower plot shows the decay rates in units of dB per string loop period. To model this string, we need to design a loop loss filter which has this dB magnitude response. Fitting the data in the log domain is psychoacoustically sensible in view of the ear’s quasi-logarithmic perception of loudness, log |LP (ej2πp(n)T )| = −rn N T (2.92) CHAPTER 2. INHARMONICITY, DECAY AND COUPLING Figure 2.14: Measured Decay Rates in C5 Piano Tone 61 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 62 A Practical matlab Loop Estimation Trick Many design algorithms are more effective if they have a magnitude as well as a phase to design to. Mathwork’s matlab invfreqz iteratively finds a discrete-time transfer function that corresponds to a given complex frequency response (Smith and Little, 1994). From a filter design perspective, invfreqz can be used to convert magnitude and phase data into transfer functions. The invfreqz algorithm is based on (Levi, 1959). The desired magnitude spectrum is known, but the natural phase response is unknown and not really important. The author has found that a practical approach is to set the phase initially to 0 everywhere, then to take the phase of the transfer function the invfreqz finds and to replace the phase of the desired magnitude with this new phase; then, iterate the process. In this way, the natural phase of the desired magnitude response gets closer and closer to optimum, and the fits provided by invfreqz improve iteratively as the complex response gets easier for the algorithm to fit. Another natural approach, which may reduce the number of iterations required to converge to a result, is to compute the minimum-phase response for the given magnitude response and use that as the starting phase response. Group Delay vs. Phase Delay In tuning the delay line length for pitch and stiffness, it was correct to use phase delay to compute the allowed frequencies in the loop. However, when computing the desired loop loss filter, while in the presence of significant stiffness effects from cascaded allpass filters, using phase delay may not be sufficiently accurate. The author has found that group delay is the correct phase measure to use when computing the decay rates from the measured data. While the tuning of resonant frequencies in a loop is dependent on exact multiples of 2π in phase delay through the loop, the decay rates of the modes only depend on the actual time it takes for the modal frequency band to travel one cycle through the loop. Hence, the decay rate per period for each measured modal frequency must take into account a group delay correction associated with the bank of M allpass cascaded allpass filters before a summary loop loss filter is designed. CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 63 Figure 2.15: Modes of Two Identical Strings Coupled Together by a Bridge: Reactive Coupling (left graph) and Resistive Coupling (right graph). Adapted from (Fletcher and Rossing, 1991). 2.7 2.7.1 Coupled Strings Two-Stage Decay Rate Figure 2.15 compares the behavior of modes of identical strings coupled at a purely reactive (e.g., springy) bridge and a purely resistive bridge. The parameters ω1 and ω2 are the unperturbed frequencies of the string modes; Ω+ and Ω− are the frequencies of the combined coupled system. The solid crisscross lines, one horizontal, one at 45◦ , represent the string frequencies without coupling. In the left-hand graph, the modes of the system coupled at a reactive bridge repel each other, as shown by the thinner solid lines. In the right-hand graph, the modes of the system coupled at a resistive bridge are drawn together and become the same frequency when the unperturbed mode frequencies are close enough, as shown by the thinner solid lines. These modes, although they are drawn together to the same frequency in the resistive bridge case, may develop different exponential decay rates, creating the effect of two-stage decay. A very important quality to the piano sound is the characteristic two-stage decay rate. The first portion of the note decays quickly corresponding to energy being lost into the soundboard, and subsequently into the air, giving the piano tone loudness. Then as the 64 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING Single String Decay vs. Three String Decay Piano Note: G4 dB -10 -20 -30 -40 0.5 1 1.5 2 2.5 3 3.5 seconds Figure 2.16: Decay Trajectories Measured on Piano G4 Tone: Single String vs. Three String multiple strings get out of phase, energy is lost into the air more slowly giving the tone persistence. Behavior of coupled piano strings has been studied in detail in (Weinreich, 1977). The nearly tuned resonating modes typically relocate themselves from two or more detuned pitches at the same decay rate, into essentially one pitch, with two decay rates. Excellent insight into this pole migration using root-locus analysis techniques is given in (Stilson, 1997; Stilson, 2006). The solid line in Figure 2.16 shows the measured amplitude decay of a G4 piano tone (G above middle-C) when all three strings are struck and decay together. Note the first-stage decay where the amplitude drops at the rate of 22 dB per second in the first second, followed by a second-stage decay where the amplitude only drops 1 or 2 dB over the next second. The dashed line is an instrumented measurement where two of the strings were stopped with a rubber wedge. Note that the decay rate during the first 2.5 seconds appears to be single stage, are a rate of approximately 13 dB per second. The musical benefit of two-stage decay is that the impression of a louder attack sound can be generated with the initial excitation peak. This delivers a lot of energy into the soundboard (hence loss in the string) in the first stage, then a longer sustained sound is provided during the second stage (Martin, 1947; Schuck and Young, 1943). Using the method of coupled string synthesis as described in (Smith, 1993), we may model the several strings of a piano note coupled at some bridge impedance. Details of CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 65 Figure 2.17: G4 Decay Trajectories Measured on Synthesized G4 Piano Tone: Tuned Exactly vs. Slight Detuning the piano string model are addressed in a later section. If these multiple strings are tuned exactly equal in our synthesis model, no two-stage decay occurs (see the dashed line in Figure 2.17). If these strings are tuned to pitches more that 1 or 2 Hz apart, they sound simply out of tune and decay separately (not shown). In order to obtain two-stage decay rate in the piano model output, one must set the tuning of the coupled waveguide strings to some small fraction of a Hz apart (Kirk, 1959). For example, to properly tune the twostage decay in a middle C string, one might most simply couple 3 (or 2) waveguide loops at a loaded scattering junction and tune one loop 0.4 Hz different than the second loop (shown are the solid line in Figure 2.17). This synthesized piano model was implemented in a synthesis modeling tool called SynthBuilder (Porcaro et al., 1998). To obtain fractional Hz tunings like this, one may use the allpass interpolation method described earlier and in (Jaffe and Smith, 1983). A linear interpolation method will probably introduce too much unwanted loss in the string loops. But the allpass method is very easy to control and very slight pitch modifications are possible. 66 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING R0 v1+ v2+ v1- v2- R0 Rb Figure 2.18: Two Strings Coupled at a Lumped Impedance Una Corda If using the coupled string method described herein below, then the proper excitation method is to drive all waveguide string loops which are coupled with the hammer excitation equally. This models the hammer hitting all three (or two) strings simultaneously. On the piano there is a middle pedal, or una corda pedal, which traditionally is thought to make the piano tone softer. In reality, on grand pianos it slides the hammers a little to one side so that only 1 of the 2 or 3 strings is struck, while the remaining string or strings for each note is not struck. The effect of this is not so much to make the sound softer, but to introduce the second stage of two-stage decay right at the beginning. This happens since, through coupling, the strings almost instantly enter into an out of phase mode of oscillation. In order to model this effect, one may simply load the excitation signal into only one string loop of a two strings-coupled model, while leaving the second string loop to take its energy entirely through the coupling filter, and not through a direct hammer excitation. This results in the desired simple “second” stage decay occurring right away. 2.7.2 The Loaded Scattering Junction The loaded scattering junction math is derived in (Smith, 1993) and we review it here. Refer to Figure 2.18 to see the identified forces and velocities in a coupled strings system. First we decompose the transverse force and velocity at the junction between the strings into traveling waves on the string: ∆ Fi = Fi+ + Fi− (2.93) CHAPTER 2. INHARMONICITY, DECAY AND COUPLING ∆ Vi = Vi+ + Vi− 67 (2.94) We also have the wave impedance relation: Fi± = ±R0 Vi± (2.95) The impedance of the bridge is ∆ FJ = Rb VJ (2.96) The strings are joined at a series junction so that all the velocities are all equal at the junction: ∆ V1 = V2 = · · · = V N = VJ (2.97) The force on the bridge is the sum of all the component string forces: FJ = = = = $ Fi (2.98) $, Fi+ + Fi− $, $* - (2.99) R0 Vi+ − R0 Vi− - (2.100) + R0 Vi+ − R0 (VJ − Vi+ ) = −N R0 VJ + 2 $ R0 Vi+ (2.101) (2.102) ∆ Using the bridge impedance relation, FJ = Rb VJ , we may solve for VJ in terms of the input velocity waves, Vi+ : 7 7 2 R0 Vi+ 2 Vi+ VJ = = N R 0 + Rb N + Rb /R0 (2.103) We can now integrate this scattering model into a full model of piano strings. 2.7.3 The Coupled String Model Figure 2.19 illustrates a coupled piano string model for one note of the piano. The coupling filter represents the loss at the yielding bridge termination, and controls the coupling of energy between and among the three strings. Each of the three string loops shown contains two delay elements, the first corresponding to the delay path from the hammer strike point to the agraffe and back, the second corresponding to the delay path from the hammer strike 68 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING E3 – Stiffness Filters + Delay Tuning Filter Delay * C3 + E2 + Delay – Stiffness Filters Tuning Filter Delay * C2 + E1 Delay – + Stiffness Filters Tuning Filter Delay C1 + * + Coupling Filter Output Figure 2.19: Three Piano Strings Coupled at a Bridge Termination CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 69 point to the bridge and back. The relative delay length ratio for most strings is about 1 to 8, although the relative delay lengths may be set to model any particular piano string strike position. The input signals E1 , E2 , and E3 are taken from the output of the hammer filter, which has been driven, in turn, by a soundboard impulse response, or a nonlinearly filtered noise excitation synthesis. Note that the input signals are introduced into the string loops at two points, in positive and negative form: this models the spectral combing effect of the relative strike position of the hammer on the string. The signals C1 , C2 , and C3 should be set to 1.0 during the sustain portion of the piano sound, and should be ramped to some appropriate loop attenuation factor, such as .95, at key release time. Alternatively, some more elaborate release sound model might be used. Note that, for una corda pedal effects, one or more of the signals E1 , E2 , or E3 , should be set to zero at key strike time. This causes the coupled string system to move quickly into its second-stage decay rate, just as is found in real piano sounds when the una corda pedal is depressed. In this coupled string model, the delay lengths are fine-tuned such that the effective pitch of each of the three string loops is very nearly equal, but not exactly equal. This is the mechanism by which two-stage decay is synthesized in the commuted piano synthesis model. The stiffness filters, as shown in Figure 2.19, are intended to be an allpass filter structure which modifies the phase response of the loop so as to create the effect of the natural inharmonicity of the piano string partials. We recommend a bank of one-pole allpass filters as described earlier in this chapter and in (Van Duyne and Smith, 1994). 2.8 Calibrating the Coupling Filter Calibrating the coupling filter in the coupled piano string model can be difficult as it apparently requires knowing the actual impedance function of the bridge and the actual wave impedance of the strings, or else making good guesses at them. In order to avoid this task, we have formulated two alternative methods to find the coupling filter coefficients directly from recorded data. The first method requires instrumenting the double or triple strings so that only one string resonates and then to record and measure the decay rates of each of the partials. The second method requires only to record and measure the decay rates of the partials on the natural first-stage decay of the full two or three coupled strings system. In each case we deduce the bridge impedance and compute the coupling filter. 70 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 2.8.1 First Method: Deducing Rb from Single-String Decay Rates Ideally, from a physical perspective, we would like to measure empirically the bridge impedance, Rb , and the string impedance, R0 ; and then from these measurements compute the desired coupling filter. However, following the spirit of the simplified string loop model presented above, let us say we have already calibrated a single string system and know LP (z), a lowpass filter modeling the per period attenuation of the tone, and AP (z), an allpass filter summarizing the dispersion in the string due to stiffness. We have presumably done this by measuring the partial frequencies and corresponding decay rates of a single piano string. This may be accomplished by physically damping two of the three piano strings in a piano note group with felt, rubber, or some such means, and then recording the sound of the remaining undamped string decaying after it is struck. The decay rate of this single string should not contain very much two-stage decay interference (Weinreich, 1977) from the other damped strings, but should, instead, produce a reasonable single stage decay from which data about the partial frequencies and their individual decay rates may be extracted. Loss in a string-bridge system comes almost entirely from the yielding bridge termination itself. That is, the loss from viscous air drag and internal friction is very small compared to termination loss. Therefore, let us simply say that LP (z) ≈ Tf (z) is the force wave transfer function at the bridge, that the string is rigidly terminated at the other end so that the force wave transfer function there is unity, and that the dispersion, AP (z), is entirely due to stiffness in the string, and not due to any significant reactive qualities in the bridge. We may therefore write, ∆ LP = Tf = and solve for Rb in terms of L, Rb = R0 Rb − R0 Rb + R0 (2.104) 1 + LP 1 − LP (2.105) The coupling filter for N strings coupled at an impedance Rb is ∆ Hb = 2 = N + Rb /R0 2 2(1 − LP ) = 1 + LP (1 + N ) + (1 − N )LP N+ 1 − LP N =3 −→ 1 − LP 2 − LP (2.106) In summary of this calibration approach, we have measured the sound of a single string 71 CHAPTER 2. INHARMONICITY, DECAY AND COUPLING decaying, derived the loop loss filter from this data, then re-interpreted this to be the force wave transfer function at the bridge (assuming that almost all of the loss is due to the yielding bridge); from this point, we derive the bridge impedance and thence the N-string coupling filter. In the model shown in Figure 2.19, we have three strings coupled, N = 3. However, several minus signs have been commuted around in that figure and the Coupling Filter is actually represented by −Hb . To complete the model, the Tuning Filters should be tweaked by a good piano tuner to achieve a fine, full-bodied two-stage decay rate (around 0.4–1.7 Hz detuning between strings) (Kirk, 1959). 2.8.2 Second Method: Deducing Rb from First-Stage Decay Rates A much more convenient approach is to deduce the coupling filter directly from a recording of the piano in its normal mode of operation. We will derive a method to compute the coupling filter from recorded data from the first-stage decay of the target piano string. For the purpose of working through the math, let’s assume there is known single-string decay data summarized in a loop filter, LP (z). Then, per the results of the last section, this corresponds to a three-strings-coupled coupling filter of Hb = 1 − LP 2 − LP (2.107) This again is assuming all the loss is at the bridge, and we then deduce the bridge impedance and compute the coupling filter according to the scattering junction equations. Now, hypothesize that all three coupled strings start off in phase after struck, and say they are all identical loops exactly in tune, then, referring to Figure 2.19, we can fold the three strings loops on top of themselves and reduce the system to a single loop with the coupling filter operating on 3 times the input, ! 1 − LP (3) 2 − LP " (2.108) and the signal fed back into each loop being expressible as the coupling filter minus the (single) input signal ! 1 − LP (3) 2 − LP " −1= 2LP − 1 2 − LP (2.109) This means that if we have measured data for single-string decay rates per period, LP , CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 72 Figure 2.20: G4 Piano Tone: Single- and Triple-String Decay Rates ∆ we can deduce the first-stage triple-string decay rates as LP3 = (2LP − 1)/(2 − LP ). By inverting this expression, solving for the single-string decay rate, LP , we can the compute the single-string decay rates form measured three-string decay rates as LP = 2LP3 + 1 2 + LP3 (2.110) By way of empirical verification, Figure 2.20, shows measured and computed decay rates of partial frequencies from a real G4 piano tone. The two solid lines running through x’s are measured data. The dashed lines running through data plotted as circles are computed data. The upper line of x’s are decay rates measured form a single G4 piano string, when the other two strings are stopped with a rubber wedge. The lower solid line runs through measured partial decay rates form the first-stage decay when all three G4 strings are struck. The points plotted as circles connected by a dashed line are triple-string first-stage decay rates derived from the measured single-string decay rates. The lower set CHAPTER 2. INHARMONICITY, DECAY AND COUPLING 73 of data plotted as circles connected by a dashed/dotted line are triple-string first-stage decay rates derived from the measured single-string decay rates. Note that the measured and deduced single-string decay rate curves are in alignment. Similarly, the measured and computed triple-string decay rate curves are in alignment with each other. Another way of looking at this problem is as follows. If we say the strings have wave impedance or R0 and the bridge has termination impedance of Rb , then the force wave transfer function at the bridge should be, ∆ T 1f = Rb − R0 Rb + R0 (2.111) As a thought experiment, if we think of the three strings as acting on the bridge all together in phase, in fact, as though they are fused together, then the mass density has in effect tripled; but the wave speed, c = # K/-, is the same, so we can see the tension has also tripled. Therefore, the effective wave impedance on our three fused strings must # ∆ √ be (3K)(3-) or 3R0 , were R0 = K- is the wave impedance of the single-string. Hence, the force wave transfer function for the triple fused strings would be computed as T 3f = Rb − 3R0 Rb + 3R0 (2.112) From these two equations, it is easy to show that T 3f = 2T 1f − 1 2 − T 1f which is equivalent to the expression we derived in Equation 2.109. (2.113) Chapter 3 The Waveguide Mesh An extremely efficient method for modeling wave propagation in a membrane is provided by the multi-dimensional extension of the digital waveguide. The 2-D digital waveguide mesh is constructed out of bi-directional delay units and scattering junctions. We show that it coincides with a standard finite difference approximation scheme for the 2-D wave equation, and we derive the dispersion error. Since its first publication in (Van Duyne and Smith, 1993a; Van Duyne and Smith, 1993b) and in (Van Duyne and Smith, 1995c), additional applications have been found in physical models of drums (Fontana and Rocchesso, 1998), cymbals and gongs (Pierce and Van Duyne, 1997a; Van Duyne et al., 1994; Serafin et al., 2001), soundboards and body resonators (Huang et al., 2000; Fontana and Serefin, 2003), and room acoustics modeling (Savioja et al., 1994; Savioja et al., 1995; Murphy et al., 2001; Kelloniemi et al., 2005; Kelloniemi et al., 2006) including improved methods for implementing boundary conditions (Kelloniemi, 2006). Although finite element (Kindel and Wang, 1987) and difference scheme approximation methods are known which can help with the numerical solution of the 2-D wave equation, these methods have two drawbacks: (1) their heavy computational time is orders of magnitude beyond desired levels for musical instrument sound synthesis, and (2) traditional problem formulations fit poorly into the physical model arena of linear systems, filters, and network interactions. On the other hand, the 2-D digital waveguide mesh formulation described in this chapter and the next, while corresponding exactly with a standard difference scheme approximation, may be implemented in a fully parallel, multiply-free formulation; the energy preserving, digitally exact round-off method eliminates numerical problems; the mesh extends simply to 3- or N-dimensions; and, finally, the algorithm is a 74 75 CHAPTER 3. THE WAVEGUIDE MESH linear network which connects up easily to other physical models. 3.1 Traveling-Wave Solution to the Ideal Membrane Equation The two-dimensional wave equation for displacement of an ideal membrane may be written as follows, 3 2 ∂2u ∂2u 2 ∂ u = c + ∂t2 ∂x2 ∂y 2 4 (3.1) where t is time, x and y are spatial coordinates on the membrane, u(t, x, y) is transverse displacement of the membrane as a function of time and spatial position(Morse and Ingard, 1968). In the one-dimensional string case, we could solve and implement the wave equation as two bi-directional traveling waves. In the 2-D membrane case, the traveling-wave solution involves the integral sum of an infinite number of arbitrary plane waves traveling in all directions, u(t, x, y) = % α gα (xcosα + ysinα − ct)dα (3.2) where gα is the waveshape traveling in the direction α at speed c. In the 1-D case we were able to assign one delay line to each of two traveling waves. Since assigning one waveguide to each of the infinite plane waves is not feasible, we need an alternative approach to model the 2-D wave equation efficiently. 3.2 The Membrane Equation in the Frequency Domain We can solve the 2-D wave equation, just as we did the 1-D wave equation in Chapter 1, only this time using the 2-D spatial Fourier transform and a Laplace transform in time. A brief digression on the 2-D Fourier transform will prove helpful in interpreting the derived amplification factors in later analysis. 76 CHAPTER 3. THE WAVEGUIDE MESH 3.2.1 Polar Coordinate View of the 2-D Fourier Transform The 2-dimensional Fourier transform of a continuous function u(x, y) may be written as a double integral over the infinite x, y plane: F ∆ u(x, y) ←→ uωx ,ωy = %% u(x, y)e−jωx x e−jωy y dxdy (3.3) where ωx and ωy are the spatial frequency variables in the x and y directions, respectively. Since the kernel of this transform is e−jωx x e−jωy y , the particular value uωx ,ωy may be understood in a polar coordinates interpretation as indicating how much (and at what phase) there is present in u(x, y) of the plane wave oriented in angular direction α and spatial frequency ωα , where ∆ tan α = ωy /ωx ∆ ωα = 0 ωx2 + ωy2 (3.4) (3.5) It is trivial that the period of the complex plane wave e−jωx x , traveling in the x direction is 2π/ωx . However, we derive the period rigorously by solving for the contour lines, ejωx x = 1 ωx x = k2π, (3.6) k = 1, 2, . . . x = k2π/ωx (3.7) (3.8) Applying this same technique in a less trivial case, we may derive for the period of the complex plane wave e−jωx x e−jωy y in a similar fashion: ejωx x ejωy y = 1 ωx x + ωy y = k2π k2π ωx − x y = ωy ωy (3.9) (3.10) (3.11) These are parallel lines of slope −ωx /ωy = −1/ tan α. Hence, these periodic contour lines are perpendicular to the radial direction α, which corresponds to a plane wave traveling in the direction α. To see that the spatial frequency of this complex sinusoidal plane wave 77 CHAPTER 3. THE WAVEGUIDE MESH is ωα , we note that the formula for the perpendicular distance between two parallel lines, y1 = mx + b1 and y2 = mx + b2 , both of slope m and with y–intercepts b1 and b2 , is as follows: |b2 − b1 | d= √ 1 + m2 (3.12) Therefore, the period of the plane wave is: 0 2π/ωy 1 + (ωx /ωy )2 = 2π/ωα (3.13) which corresponds to a spatial frequency of ωα . 3.2.2 Solving the Wave Equation Returning to the membrane equation, ∂2u = c2 ∂t2 ( ∂2u ∂2u + 2 ∂x2 ∂y ) , (3.14) defining uωx ,ωy (t) as the 2-D spatial Fourier transform, and Uωx ,ωy (s) as the Laplace transform of uωx ,ωy (t) in time, we have , - uωx ,ωy (t) = c2 (jωx )2 uωx ,ωy (t) + (jωy )2 uωx ,ωy (t) . (3.15) / s2 Uωx ,ωy (s) − su0 − u̇0 = c2 (jωx2 ) Uωx ,ωy (s) + Uωx ,ωy (s) where (3.16) ∆ (3.17) ∆ (3.18) u0 = uωx ,ωy (0) u̇0 = u̇ωx ,ωy (0) Gathering terms and making a partial fraction expansion we get, Uωx ,ωy (s) = su0 + u̇0 s2 , + c2 ωx2 + ωy2 - (3.19) 78 CHAPTER 3. THE WAVEGUIDE MESH = u+ ωx ,ωy s + jcωα + u− ωx ,ωy s − jcωα (3.20) where u± represent initial wave decomposed spatial spectra ∆ u+ ωx ,ωy = u− ωx ,ωy = ∆ ∆ ωα = ! 1 u0 − 2 ! 1 u0 + 2 0 " u̇0 jcωα " u̇0 jcωα ωx2 + ωy2 (3.21) (3.22) (3.23) The spatial frequency variable ωα represents a plane wave traveling in direction α = arctan ωy /ωx of spatial frequency get 0 ωx2 + ωy2 . Taking the inverse Laplace transform, we −jcωα t jcωα t uωx ,ωy (t) = u+ + u− ωx ,ωy e ωx ,ωy e (3.24) − Letting u+ ωx ,ωy and uωx ,ωy be 0 in turn, we can see the spectral amplification factors as time goes from t to t + ∆t are ∆ g± (∆t) = uωx ,ωy (t + ∆t) = e∓jcωα ∆t uωx ,ωy (t) (3.25) These spectral amplification factors correspond to a phase advance of % g± = ±cωα ∆t in ∆t seconds for the plane wave in direction α. The phase delay, or more correctly, the phase distance is % g± (∆t) = ±c, ωα ∆t (3.26) This means plane waves of any spatial frequency or in any direction propagate at speed c. 3.3 The 2-D Digital Waveguide Mesh We propose here a numerical solution of the 2-dimensional wave equation in terms of a network of bi-directional delay elements and 4-port scattering junctions. This structure can be viewed as a layer of parallel vertical waveguides superimposed on a layer of parallel horizontal waveguides intersecting each other at 4-port scattering junctions between each 79 CHAPTER 3. THE WAVEGUIDE MESH S S S S S S S S S S S S S S S S S S S S S S S S S Figure 3.1: The 2-D Digital Waveguide Mesh bi-directional delay unit. Figure 3.1 shows such a mesh. In the canonical case, the scattering junctions are taken to be equal impedance lossless junctions and the interconnecting waveguides are of unit length. If we view the mesh as a lattice of interconnected vibrating strings, the displacement velocities at the four ports of each junction must be equal, and the forces at each junction must sum to zero; in this case, we have series scattering junctions with force or velocity waves traveling in the two-port, bi-directional, delay units. Alternatively, if we view the mesh as a lattice of interconnected acoustic tubes, the pressures at each junction must be equal, and the flows into each junction must sum to zero; these are parallel scattering junctions with pressure or volume velocity waves traveling through the delay units. 80 CHAPTER 3. THE WAVEGUIDE MESH Z2 Z1 S Z3 Z4 Figure 3.2: Four-Way Scattering Junction 3.3.1 The Lossless Scattering Junction It is useful to be able to interconnect waveguides of possibly varying wave impedance at junctions which may be lossless, or which may be loaded with impedances of their own, or be driven by external forces. For example, driving a violin string with a pulsed noise signal representing the bow requires a scattering junction on the string where the bow divides it (Chafe, 1990). Tone holes in wind instrument models may take advantage of scattering junctions. Strings may be coupled together at a bridge via scattering junctions (Smith, 1993). Scattering junctions may be used to build up acoustic tubes of varying diameter by joining segments of cylindrical tubes (Cook, 1990). A reverberation algorithm which depends on interconnecting any number of varying length and varying impedance waveguides into an arbitrarily elaborate network has been described in (Smith, 1987). The membrane model presented in this paper may be viewed as a canonical form of this reverberation structure. Figure 3.2 shows a schematic representation of four waveguides intersecting in a lossless scattering junction. The line segments with opposing arrows on them represent the bidirectional delay lines of the digital waveguide with their associated wave impedances, Zi . The circumscribed S represents the junction. When four strings intersect at a single point, or junction, without loss of energy, we have a series junction and require two conditions: (1) that the velocities of all the strings 81 CHAPTER 3. THE WAVEGUIDE MESH at the junction be equal since they are all moving together at that point, v1 = v2 = v3 = v4 (3.27) and (2) that the forces exerted by all the strings must balance each other at that point, i.e., they must sum to zero, f1 + f2 + f3 + f4 = 0 (3.28) Combining the two series junction constraints for strings with the wave variable definitions, vi = vi+ + vi− (3.29) fi = fi+ + fi− (3.30) and with the wave impedance relations, fi+ = Zi vi+ (3.31) fi− = −Zi vi− (3.32) we can derive the lossless scattering equations for the interconnection of several strings, vJ = vi− = 2 74 + i=1 Zi vi 74 i=1 Zi vJ − vi+ (3.33) (3.34) vJ represents the junction velocity, the vi+ are the incoming waves at the junction, and the vi− are the outgoing waves at the junction. These equations say that, as a wave is coming into a junction along a string, some portion of the wave reflects off the junction and travels back where it came from, while the rest of it travels into the junction and is divided among the outgoing waves along the other strings. The relative proportions of this scattering effect are dependent only on the relative impedances, Zi , of the strings and not on their lengths. In the case of the 4-port isotropic waveguide mesh, we take the wave impedances of all the strings to be equal, and the equations reduce to, 1, + vJ = v1 + v2+ + v3+ + v4+ 2 vi− = vJ − vi+ (3.35) (3.36) CHAPTER 3. THE WAVEGUIDE MESH 3.3.2 82 The Birth of Traveling Plane Waves The idea of interconnecting many waveguides together to produce a complex model of waves traveling through space has long been known (Smith, 1987). In fact, the waveguide mesh can be viewed as a model of just so many very short strings or air columns in a crisscross of interconnections supporting many bidirectional waves scattering at many junctions. However, something much more amazing occurs when the interconnected strings are arranged in regular shapes and are pulled taut into regular canonical forms: Superposed 2-D plane waves arise, represented in the junction velocity values, traveling in all 360◦ directions on the surface. This is a non-trivial step, from the interconnectivity and scattering of many 1-D waveguides to the 2-D and 3-D wavefronts traveling on a membrane or in space. The mathematical analysis will be presented later in this chapter. First we will consider some practical concerns such as how to terminate the mesh, empirical evaluations of its performance, and implementation features that make it efficient. 3.3.3 Terminating the Mesh As a practical concern, we must terminate the mesh in some way. Terminating the mesh waveguide ends with perfect reflections, that is multiplying the arriving traveling wave by −1 before sending it back into the mesh, models a membrane clamped rigidly at the edges, such as a drum head. Figure 3.3 shows this structure. A membrane stretched taut but floating in space unterminated (or terminated at frictionless guide rods) could be modeled with a non-reflecting termination, that is multiply by 1 at the terminations. Alternatively, the rim junctions could be replaced by 3-port and 2-port junctions as shown in Figure 3.4. More generally, the termination filter could be arbitrary, as shown in Figure 3.5 where the f’s represent arbitrary wave transfer functions at the terminations. In practical situations, these filters can be used to introduce summarized loss into the mesh and modify the apparent wave speed of the modes to simulate stiffness. 3.4 Implementation Features The digital waveguide mesh may be computed in parallel, and without multiplies. In addition, numerical round-off loss may be redistributed back into the mesh to create a zero-loss system. 83 CHAPTER 3. THE WAVEGUIDE MESH -1 -1 -1 -1 -1 -1 S S S S S -1 -1 S S S S S -1 -1 S S S S S -1 -1 S S S S S -1 -1 S S S S S -1 -1 -1 -1 -1 -1 Figure 3.3: Rigidly Terminated Membrane 84 CHAPTER 3. THE WAVEGUIDE MESH S S S S S S S S S S S S S S S S S S S S S S S S S Figure 3.4: Open Termination of the Mesh 85 CHAPTER 3. THE WAVEGUIDE MESH f f f f f f S S S S S f f S S S S S f f S S S S S f f S S S S S f f S S S S S f f f f f f Figure 3.5: Mesh Terminated with Arbitrary Wave Transfer Functions CHAPTER 3. THE WAVEGUIDE MESH 86 Two-Pass Parallel Computation The network elements in the 2-D digital waveguide mesh are of two types: 4-port scattering junctions and 2-port bi-directional unit delays. If the unit delays are double buffered, so that each delay has its own input and output buffers, the computation of all the elements in the mesh can be segregated and computed in any arbitrary order or in parallel, according to the following two-pass computation scheme: (1) The scattering junction outputs are computed from their known inputs and placed at the junction outputs. This constitutes the scattering pass. (2) The outputs from each scattering junction are placed at the inputs of the adjacent scattering junctions, thereby implementing the bi-directional delay units. This constitutes the delay pass. Due to the possibility of arbitrary ordering of the scattering computations, implementation on a parallel computing architecture with local four-sided connectivity between processors is ideal for the mesh algorithm. In this implementation, the junction equations are computed in the processors; and then the data transfer cycle is used to transfer data from the outputs of each processor to the appropriate inputs of the adjacent processors. Since the equal impedance 4-port lossless scattering junction is multiply-free, as pointed out in Section 4.2, a VLSI implementation may be constructed with a handful of gates with no need for hardware multipliers. Since the junctions may be computed in parallel, the whole mesh may be computed in the time it takes to do 7 adds (i.e., 3 adds and 4 subtracts) and one shift. In fact, the four subtracts may be performed in parallel. Energy Preserving Junctions When performing the multiply-free junction computation, one divide by two is required. If a simple sign-preserving right shift and truncation is used for this operation, the junction value is rounded toward zero in the case of positive numbers and rounded away from zero in the case of negative numbers. This is a round down in both cases, which could introduce a negative offset into the values of the mesh which may eventually lead to numerical instability or reduced dynamic range, if there is no loss in the system somewhere else. The usual solution to such a problem would be to make a conservative rounding toward zero in both the positive and negative cases. This way no energy and no DC drift will be introduced into the system. This method is known to work quite well in one-dimensional feedback loops. Unfortunately, in the two-dimensional mesh case, there are so many CHAPTER 3. THE WAVEGUIDE MESH 87 junctions that the cumulative losses in all the junctions add up to a noticeable amount. An energy preserving method of junction computation may be constructed as follows. When shifting a binary number to the right, there are exactly two cases: (1) the low-order bit which is shifted off the end of the word is zero, and the computation is exact, or (2) the low-order bit is one, and the error is exactly 0.5. When the junction inputs are subtracted off vJ in computing the scattering junction outputs, this error is magnified by a factor of 4 and the 0.5 error propagates into the four output signals equally. Note that the error is in the same direction in all four cases so the total error is 4 × 0.5 = 2 full bits. To preserve energy in the mesh, round two output signals down (i.e., just truncate) and round the other two output signals up (i.e., add the low-order bit back in after truncating). This re-distribution of the error produces a numerically exact lossless scattering junction. In effect, the slight numerical error has been converted into a slight scattering dispersion error. Whereas the numerical error was problematic, the dispersion adjustment is vanishingly small. 3.4.1 Empirical Evaluation of the Mesh It is evident that, given an initial excitation at some point on the digital waveguide mesh, that energy from that excitation will tend to spread out from the excitation point more and more as the traveling waves scatter through the junctions. It is not, however, easy to see that the wave propagation on the mesh converges to that on the ideal membrane. Animation of the Mesh A visual verification of the waveguide mesh algorithm can be seen in Figure 3.6, which shows three separate time frames of an animation computed directly from the algorithm. The top frame shows the initial deflection loaded into the mesh. Each intersecting grid point represents a scattering junction. The next two frames show the circular propagation outward of the initial excitation in a way consistent with wave propagation on the ideal membrane. Sounds from the Mesh As another check of the mesh algorithm, we can compare the expected modal frequencies on an ideal membrane with those generated from the mesh model. The allowed frequencies CHAPTER 3. THE WAVEGUIDE MESH Figure 3.6: Wave Propagation on the Mesh 88 89 CHAPTER 3. THE WAVEGUIDE MESH Figure 3.7: Comparison of Theoretical Modes on a Square Membrane (shown above) and Measured Modes on a 10 × 10 Waveguide Mesh (shown below) in a theoretical ideal square membrane with clamped edges are proportional to √ m2 + n 2 , for m = 1, 2, . . ., and n = 1, 2, . . . (Morse and Ingard, 1968). These modes may be labeled (m, n) for any given m and n. In Table 3.4.1 is computed a list of the normalized frequencies of the first few of these modes given as multiples of the lowest allowed frequency. (1,1)→1.00 (1,2)→1.58 (2,2)→2.00 (1,3)→2.24 (2,3)→2.55 (1,4)→2.92 (3,3)→3.00 (2,4)→3.16 (3,4)→3.54 (1,5)→3.60 (2,5)→3.80 (4,4)→4.00 (3,5)→4.12 (1,6)→4.30 (2,6)→4.47 (4,5)→4.50 (3,6)→4.74 (5,5)→5.00 Table 3.1: Normalized Mode Frequencies on an Ideal Square Membrane Figure 3.7 shows a comparison of ideal modal frequencies on a square membrane to frequencies generated by a 10 × 10 square digital waveguide mesh. The lines across the top half of the figure represent the first 17 modes listed in Table 3.1. The bottom half of the figure is a magnitude spectrum plot of a sound generated by the mesh. The figures have been scaled horizontally to line up their lowest frequency. A careful inspection of the figure will reveal that the theoretical modal frequencies listed in Table 3.1 are generally present and accounted for in the sound generated by the model. This would indicate that the mesh is doing the right thing. Error in the correspondence of ideal and computed modes can be attributed to the extreme coarseness of the mesh used. CHAPTER 3. THE WAVEGUIDE MESH 3.4.2 90 Mirroring of the Spectrum Observe the four spectral plots in Figure 3.8. The top plot is an magnitude spectrum analysis of the output of a square 10x10 mesh running at 22050Hz, horizontal scale marked in kHz. The spectrum mirrors around one quarter of the sampling rate. This symmetry, which also occurs in the one dimensional waveguide case, is a result of the fact that, when the waveguide system is reflectively terminated, all the unit delays on the upper rail can be commuted down to the lower rail making the system a function of z −2 , in effect, over-sampling the system by a factor of two. When the unit bi-directional delays are replaced with longer waveguides, the mirroring replicates. For example, the second plot in Figure 3.8 shows the magnitude spectrum when bi-directional delay lines of length 2 are used between the scattering junctions: the entire mirrored spectrum is compressed by half, and, itself, mirrored around π/4. The third and fourth plots show the cases where the bi-directional delay lines are length 4 and 8, respectively. What this means is you can reduce the number of junctions needed to compute lower frequency meshes at a given sampling rate by adding more delay between the junctions. However, you still get the same number of accurate lower modes as when one delay unit is used, and you get mirrored copies of the base spectrum filling the upper spectrum. 3.5 Dispersion in Plates A detailed treatment of allpass modeling of dispersion in the two-dimensional case is not possible here. However, much as in stiff strings, the higher frequencies in stiff membranes travel faster than lower frequencies, causing a “stretching” of the modes. Figure 3.9 illustrates the spectral effect of terminating a 10×10 2-D digital waveguide mesh with single allpass filters around the rim. The six plots in the figure have been scaled horizontally to align the de-tuned fundamental mode in each case so that the mode stretching effect for various choices of allpass coefficient, a0 , is clarified. Since the 2-D mesh is designed for parallel multiply-free hardware implementation, our simplified multiply-free allpass approach is ideally suited to it. CHAPTER 3. THE WAVEGUIDE MESH Figure 3.8: Spectrum Reflecting Around π/4 91 92 CHAPTER 3. THE WAVEGUIDE MESH 0 π/4 π/2 3π/4 π a0 = 0 a0 = −.125 a0 = −.25 a0 = −.5 a0 = −.75 a0 = −.875 0 π/4 π/2 3π/4 Figure 3.9: Stretching Modes on the Mesh ωT π CHAPTER 3. THE WAVEGUIDE MESH 93 Figure 3.10: Detail View of the 4-Port Rectilinear Waveguide Mesh 3.6 Why the Thing Works Using the tool set we developed in Chapter 1 in the 1-D waveguide case, we now study the waveguide mesh equivalence to a finite partial difference, and compare wave propagation in the mesh difference to the wave propagation in the ideal isotropic membrane and the 2-D wave equation. CHAPTER 3. THE WAVEGUIDE MESH 3.6.1 94 Finite Difference Scheme Equivalence Interpreting the 2-D Mesh as a Finite Difference Figure 3.10 shows a detail of the 2-D mesh, labeling all the signals in the mesh. We use the “bridge table” convention of North, South East and West to label the four ports of each scattering junction and apply N, S, E, and W as superscripts to the traveling-wave signals J (n) of the junction at position l, m at time n, as appropriate. The junction velocity, vl,m N+ S+ E+ may be written as one half the sum of its four input velocity waves, vl,m (n), vl,m (n), vl,m (n), W+ and vl,m (n) from the north, south, east, and west direction respectively: J vl,m (n) = + 1 * N+ S+ E+ W+ vl,m (n) + vl,m (n) + vl,m (n) + vl,m (n) 2 (3.37) N− S− E− W− The four output waves, vl,m (n), vl,m (n), vl,m (n), and vl,m (n) may be computed as the junction velocity minus the input wave from the same direction: J N+ N− (n) (n) = vl,m (n) − vl,m vl,m S− S+ J vl,m (n) = vl,m (n) − vl,m (n) E− E+ J vl,m (n) = vl,m (n) − vl,m (n) J W+ W− (n) (n) = vl,m (n) − vl,m vl,m (3.38) (3.39) (3.40) (3.41) Further, we may observe that the input to one junction is the output from the adjacent junction delayed by one time sample: S− N+ (n − 1) (n) = vl,m+1 vl,m S+ N− vl,m (n) = vl,m−1 (n − 1) W− E+ (n − 1) (n) = vl+1,m vl,m E− W+ (n) = vl−1,m (n − 1) vl,m (3.42) (3.43) (3.44) (3.45) Using these relationships we may conclude that, S− N+ (n) = vl,m+1 (n − 1) vl,m S+ J (n − 1) (n − 1) − vl,m+1 = vl,m+1 N− J (n − 2) (n − 1) − vl,m = vl,m+1 (3.46) (3.47) (3.48) 95 CHAPTER 3. THE WAVEGUIDE MESH * + (3.49) * + (3.50) * + (3.52) N+ J J = vl,m+1 (n − 1) − vl,m (n − 2) − vl,m (n − 2) Similarly, we may see that, S+ S+ J J vl,m (n) = vl,m−1 (n − 1) − vl,m (n − 2) − vl,m (n − 2) * + E+ J J E+ vl,m (n) = vl+1,m (n − 1) − vl,m (n − 2) − vl,m (n − 2) (3.51) W+ W+ J J vl,m (n) = vl−1,m (n − 1) − vl,m (n − 2) − vl,m (n − 2) Returning to the definition of the junction velocity as a sum of the input velocity waves, we may substitute in these new expressions to find a relation among junction velocities of adjacent junctions: J vl,m (n) = = + 1 * N+ S+ E+ W+ vl,m (n) + vl,m (n) + vl,m (n) + vl,m (n) 25 + * 1 J J N+ (n − 2) vl,m+1 (n − 1) − vl,m (n − 2) − vl,m 2 * (3.53) + S+ J J + vl,m−1 (n − 1) − vl,m (n − 2) − vl,m (n − 2) * + E+ J J (n − 2) + vl+1,m (n − 1) − vl,m (n − 2) − vl,m + J vl−1,m (n − 1) − * J vl,m (n − 2) − W+ (n vl,m +6 − 2) (3.54) Noting that W+ E+ S+ N+ J (n − 2) = 2vl,m (n − 2) + vl,m (n − 2) (n − 2) + vl,m (n − 2) + vl,m vl,m (3.55) Gathering terms, we see J J vl,m (n) + vl,m (n − 2) = 5 + 1 * J J vl+1,m (n − 1) + vl−1,m (n − 1) 2 * +6 J J + vl,m+1 (n − 1) + vl,m−1 (n − 1) 3.6.2 (3.56) The Difference as a Standard 2-D Scheme Dropping the J superscript for now, n−2 n = + vl,m vl,m (3.57) 96 CHAPTER 3. THE WAVEGUIDE MESH 3 1 n−1 n−1 n−1 n−1 v + vl−1,m + vl,m+1 + vl,m−1 2 l+1,m 4 (3.58) n−1 we can subtract 2vl,m from both sides to obtain n−1 n−2 n vl,m − 2vl,m + vl,m = (3.59) 3 1 n−1 n−1 n−1 v − 2vl,m + vl−1,m 2 l+1,m n−1 + vl,m+1 − n−1 2vl,m + n−1 vl,m−1 (3.60) 4 (3.61) This is in fact a standard finite difference approximation of the 2-D wave equation, applying a second-order backward difference in time, and centered second-order differences in both space dimensions. By analogy with the 2-D wave equation, c2 corresponds to 1/2, so the apparent wave speed, c that this difference should be approximating is 3.6.3 # 1/2 Converging to the 2-D Wave Equation As we did with the 1-D waveguide difference, we will be able to replace the discrete time and space variables with continuous time and space variables, and replace the unit spatial and time sample shifts in the finite difference with an ε. We can then apply a multidimensional Taylor’s series expansion around an arbitrary point in all directions, and let ε converge to 0. Making the Waveguide Mesh Difference a Continuous Function If we imagine a continuous function (with continuous derivatives) running through the discrete points of the difference, we can re-write the waveguide difference as follows, u(t, x, y) + u(t − 2ε, x, y) = 1 [u(t − ε, x + ε, y) + u(t − ε, x − ε, y) 2 + u(t − ε, x, y + ε) + u(t − ε, x, y − ε)] Taylor’s Series Expansion Taylor’s Series in three variables is defined as follows, (3.62) (3.63) 97 CHAPTER 3. THE WAVEGUIDE MESH ∆ u(t + ∆t, x + ∆x, y + ∆y) = ∞ $ ∞ $ ∞ $ u(nt ,nx ,ny ) (t, x, y)∆tnt ∆xnx ∆y ny nt nx ny nt !nx !ny ! (3.64) We can replace each term with a full Taylor’s expansion around the point (t, x, y). The symbol manipulation is tedious and is omitted here. In any case, the use of a symbolic mathematics processing tool such as Mathematica (Wolfram, 1999) is recommended. After replacing each term with a Taylor’s series expansion, canceling and gathering terms, everything reduces to ε2 u(2,0,0) = + ε2 * (0,2,0) u + u(0,0,2) + O{ε3 } 2 (3.65) Letting Grid Size Shrink Dividing through by ε2 , and taking the limit as ε −→ 0, we arrive at the standard 2-D isotropic wave equation, , u(2,0,0) = c2 u(0,2,0) + u(0,0,2) where, the wave speed c = # 1/2. - (3.66) Not So Obvious in Non-rectilinear Cases This technique is fairly heavy handed to determine something which is reasonably obvious from the difference equation itself, that the wave speed is c = # 1/2. Now that it has been applied to the 1-D waveguide difference and the 2-D mesh difference, it should be getting more comfortable. In the next chapter we will apply this technique on mesh structures which are non-rectilinear, to compute wave speeds simply and efficiently. Determining wave speed in the hexagonal and tetrahedral mesh structures is not obvious from the resultant mesh differences. Some Intuition on the Traveling-Wave Speed The 4-port rectilinear mesh appears to implement a wave propagation speed of spatial sample per time sample. # # 1/2 1/2 is one-half unit diagonal distance between grid points per time sample. Why should the plane waves in the mesh travel slower than the 1-D waves traveling in each of the individual waveguides between the scattering junctions? 98 CHAPTER 3. THE WAVEGUIDE MESH Recall that the wave speed derived for the physical wave equation is proportional to # K/ε, or the square root of tension over density (Morse and Ingard, 1968). Imagine a layer of parallel waveguide strings, and a “plane wave” traveling down parallel strings together. The speed of this wave would of course be one space sample per time sample, because that is the speed in each of the parallel waveguides. Intuitively, when creating the 4-port mesh, we have superimposed one layer of parallel wave guide strings over a second layer of parallel waveguide strings, at right angles, and soldered them together at the junctions to form the mesh. In effect, we have doubled the number of waveguide strings in the same plane area, which therefore doubled the density of the material. If we doubled the mass # density per unit area, and the wave speed is proportional to K/ε, then we should expect √ the traveling-wave speed to be reduced by a factor or 1/ 2, which is in fact the case. The Courant-Friedrichs-Lewy Condition for 2-D Hyperbolic Difference Schemes Defining λ = T /X, where T is the time sampling interval, and X is the spatial sampling interval, the Courant-Friedrichs-Lewy stability condition states that, for explicit computational schemes for hyperbolic difference equations to be numerically stable, it is necessary that, for a difference scheme to track the solution of a hyperbolic equation with two space dimensions, the cone of dependence for each point of the continuous wave equation solution must lie within the discrete pyramid of dependence for each point of the difference scheme solution (Courant et al., 1956; Strikwerda, 1989). The waveguide mesh difference equivalent clearly expands at the rate of one half grid diagonal per time step, which corresponds to the relation, |cλ| ≤ 8 1 2 (3.67) Since the Courant-Friedrichs-Lewy condition is satisfied in the equality, the lowest possible dissipation and dispersion error for this particular scheme is obtained. The numerical approximation schemes for initial value problems involving secondorder hyperbolic partial difference equations usually require a multi-step time scheme which retains values for at least two previous time frames. This is to cope with the second partial time derivative in the equation. The waveguide mesh structure reduces this time dependence to a novel one-step time scheme where each new time frame may be computed wholly from the previous time frame. This is made possible by the use of the bi-directional traveling-wave components in place of physical wave variables. In a sense, 99 CHAPTER 3. THE WAVEGUIDE MESH the bi-directional traveling-wave structure contains the past history of the traveling waves right in the delay line contents. 3.7 Von Neumann Error Analysis in 2-D By applying a von Neumann-style analysis as described in Chapter 1 to both the partial differential membrane equation and the partial difference approximation scheme, we may study the dissipation and dispersion error in the model. Analysis of 2-D systems will require the use of both continuous and discrete 2-D transforms to compare the evolution over time of the spatial spectra. We begin by solving the difference in the frequency domain. 3.7.1 Solving the Difference Directly in the Frequency Domain We have already shown that the 2-D digital waveguide mesh is equivalent to the following difference scheme, vl,m (n) + vl,m (n − 2) = 5 1 [vl+1,m (n − 1) + vl−1,m (n − 1)] 2 + [vl,m+1 (n − 1) + vl,m−1 (n − 1)] 6 (3.68) In the case of the finite difference scheme, a two-dimensional discrete-space Fourier transform may be performed over the spatial grid to yield, vξ1 ,ξ2 (n + 1) + vξ1 ,ξ2 (n − 1) = where ∆ b=− 1 vξ ,ξ (n)(ejξ1 + e−jξ1 + ejξ2 + e−jξ2 ) 2 1 2 (3.69) vξ1 ,ξ2 (n + 1) + bvξ1 ,ξ2 (n) + vξ1 ,ξ2 (n − 1) = 0 (3.70) 1 , jξ1 e + e−jξ1 + ejξ2 + e−jξ2 = − cos ξ1 − cos ξ2 2 (3.71) This is just a second-order recursion equation in n, with a solution easily obtainable via the Z-transform in the time dimension. We delay the system one time sample to make the difference causal, and make the 100 CHAPTER 3. THE WAVEGUIDE MESH mathematics more convenient, vξ1 ,ξ2 (n) + bvξ1 ,ξ2 (n − 1) + vξ1 ,ξ2 (n − 2) = 0 (3.72) Applying the Z-transform in the time dimension, and using the shift theorem which maps y(n − 1) ←→ z −1 Y (z) + y(−1) Z (3.73) y(n − 2) ←→ z −2 Y (z) + z −1 y(−1) + y(−2) Z (3.74) we get, , - Vξ1 ,ξ2 (z) + b z −1 Vξ1 ,ξ2 (z) + vξ1 ,ξ2 (−1) + , (3.75) - z −2 Vξ1 ,ξ2 (z) + z −1 vξ1 ,ξ2 (−1) + vξ1 ,ξ2 (−2) = 0 (3.76) where vξ1 ,ξ2 (−1) and vξ1 ,ξ2 (−2) are the initial spatial spectra at times −1 and −2. Gath- ering terms and solving for Vξ1 ,ξ2 (z), we have Vξ1 ,ξ2 (z) = −(b + 1)vξ1 ,ξ2 (−1) − vξ1 ,ξ2 (−2) 1 + bz −1 + z −2 (3.77) Performing a partial fraction expansion and noting that, 1 Z ←→ pn −1 1 − pz (3.78) Vξ1 ,ξ2 (n) = Aξ1 ,ξ2 (p+ )n + Bξ1 ,ξ2 (p− )n (3.79) we then arrive at where Aξ1 ,ξ2 and Bξ1 ,ξ2 are simple combinations of the initial spatial spectra at time samples −1 and −2 and where ± p = −b ± √ 2 b2 − 4 √ −b ± j 4 − b2 = 2 (3.80) These are the discrete-time spectral amplification factors for the 2-D 4-port digital waveguide mesh. 101 CHAPTER 3. THE WAVEGUIDE MESH c′(ξ1, ξ2) c 1.01 0.9 0.9 π 2 Pi -2 0.8 0.8 0.7 0.7 0 0 −π 2 -Pi --2 -Pi --−π 2 2 0 0 π 2 Pi -2 ξ1T ξ2T Figure 3.11: Frequency-Dependent Dispersion in the 4-Port Rectilinear Mesh. Vertical axis is fraction of full speed for that spatial frequency. 3.7.2 Evaluation of the Error There is evidently no magnitude dissipation loss in the finite difference scheme, just as there is none in the ideal membrane, since, 9 ) :! "2 ( √ 2 2 2 ±2 : 4 − b b ; 2p 2 = =1 + 2 2 (3.81) This is as expected, since all the junctions in the mesh are lossless and energy is conserved. On the other hand, there is some phase dispersion error in the high frequencies. Recalling c = # 1/2 in the model, we see the ratio of actual wave propagation speed in the mesh to desired speed is, √ √ c& (ξ1 , ξ2 ) 2 4 − b2 = arctan c ξ −b (3.82) with b defined as above, b = − cos ξ1 − cos ξ2 . Figure 3.11 shows the relative speed of travel of a plane wave with spatial frequency ∆ ξT = 0 ∆ ξ12 + ξ22 T , aligned in the direction α = arctan ξ2 /ξ1 . Comprehending the meaning CHAPTER 3. THE WAVEGUIDE MESH 102 of this plot is difficult at first. Please note that there is no dispersion error in the wave travel in the diagonal directions (that is, when |ξ1 | = |ξ2 |, and the direction angle α points in one of the four diagonal directions). However, there is some loss of speed in the higher spatial frequencies traveling along the mesh axes (when one of the component frequencies is zero). The data points near the center of the plot represent the near full speed of travel for plane waves of low (large period) spatial frequency, and the data points further out from the center of the plot indicate the fractions of full speed that the plane waves of higher spatial frequency travel at in their particular directions of travel. In a terminated mesh, speed distortion results in a mistuning of resonant modes. This distortion can be reduced by allpass filtering and/or warping of the membrane boundary in a compensating manner. We note that the high-frequency modes of a membrane become so dense that, in audio contexts, this error may not be important. Figure 3.12 shows the same dispersion information on a contour plot, with 1% contour lines, which we shall adopt as our standard presentation form factor for dispersion data. We also show only up to one-quarter the spatial sampling rate, as beyond this frequency, the output spectrum is not physically valid as it is mirrored around π/2 as the entire system is a multiple of z −2 . Comparing Figures 3.11 and 3.12 may be helpful. In another view, we can see dispersion in time/space domain in Figure 3.13. The effect of dispersion in the higher spatial frequencies is visible as the wavefront smoothes out as it travels along the axes. On the other hand, if you look closely, you can see it remains sharp as it travels along the diagonal directions of the mesh (showing no dispersion in wave speeds), that is, the wave shape remains coherent while traveling in the diagonal directions. What is happening in the wave front as it is traveling in the directions of the axes, is that the low spatial frequencies are rolling out ahead of the high spatial frequencies, and the wavefront smoothes out, while the high spatial frequencies traveling the direction of the axes lag behind and cause the rippling in the center of the membrane as the wavefront moves out. 103 CHAPTER 3. THE WAVEGUIDE MESH 1.5 1 0.5 0 -0.5 -1 -1.5 -1.5 -1 -0.5 0 0.5 1 1.5 Figure 3.12: Frequency-Dependent Dispersion in the 4-Port Rectilinear Mesh. Contour lines are shown at 1% intervals. CHAPTER 3. THE WAVEGUIDE MESH Figure 3.13: Time-Domain View of Dispersion in the 4-Port Rectilinear Mesh. 104 Chapter 4 Other Mesh Structures 4.1 Meshes Constructed of N-Port Scattering Junctions In this chapter we study several alternative 2-D mesh structures, and then derive a 4-port multiply-free solution for 3-D acoustical space modeling. A body of follow-on work has been done in the area of difference and scattering modeling of membranes and plates; most notable is the thorough exploration of the field found in (Bilbao, 2001; Bilbao, 2004) and numerous papers by the same author. We also note here some early work in the 3-D mesh (Savioja et al., 1994; Savioja et al., 1995), and in alternative mesh structures in (Fontana and Rocchesso, 1998). The tetrahedral mesh work presented later in this chapter was first published in (Van Duyne and Smith, 1996; Van Duyne and Smith, 1995a) and (Van Duyne and Smith, 1997). We first derive the general relationships in structures constructed from N-port lossless scattering junctions. 4.1.1 Lossless N-Port Scattering Junctions Referring to Figure 4.1, let N be the number of strings connected together at a single junction in a series manner. Let F and V represent the force and velocity at the junction and F γ and V γ the transverse force and velocity of the N strings where they interconnect, taking γ = 1, 2, 3, . . . , N . Then we define the wave variable relationships for each string, F γ = F γ+ + F γ− V γ = V γ+ + V γ− 105 (4.1) 106 CHAPTER 4. OTHER MESH STRUCTURES 1+ V 1– V 2+ V 2– V … Ν+ V Ν– V Lossless N-Port Scattering Junction Figure 4.1: The Lossless N-Port Scattering Junction where F γ+ and V γ+ are the incoming waves on each string, and F γ− and V γ− are the outgoing wave on each string at the point where they connect at the junction. Now, taking the wave impedance of the all the interconnecting strings to be uniform, R0 , we have the wave impedance relations: F γ+ = R0 V γ+ F γ− = −R0 V γ− (4.2) The series junction constraints say that the transverse string velocities at the junction are all equal, and they equal the junction velocity (because they are all moving together at the point where they are connected). The force constraint is that all the transverse forces on the strings at the junction balance each other so that the junction force, which is the sum of the string forces, is 0. V =Vγ γ = 1, 2, . . . , N N $ Fγ = 0 (4.3) γ=1 Combining the wave variable definition, the wave impedance relationships, and the series junctions constraints, we can derive the general scattering equations for the N-port losses scattering junction (Smith, 1987; Smith, 1993): V = 4.1.2 N 2 $ V γ+ N γ=1 V γ− = V − V γ+ (4.4) Connecting Two Junctions with a Bidirectional Unit Delay Consider two scattering junctions, A and B, interconnected by bi-directional unit delay as in Figure 4.2. Let the transverse velocity at junction A be VA and at junction B, VB . These junction velocities are equal to the endpoint velocities of the string represented 107 CHAPTER 4. OTHER MESH STRUCTURES VAB– VBA+ z-1 Scattering Junction A Scattering Junction B z-1 VAB+ VBA– Figure 4.2: Scattering Junctions Connected by a Bidirectional Unit Delay by the bidirectional unit delay. We will call the transverse velocity on the string which connects from junction A to junction B, measured at A , VAB . Similarly, we define VBA to be the transverse velocity on the string which connects from junction B to junction A, measured at B. Thus we have the wave variable decompositions, ∆ (4.5) ∆ (4.6) VA = VAB = VAB+ + VAB− VB = VBA = VBA+ + VBA− So, VAB+ is the incoming wave from B to A as it arrives at A, and VAB− is the outgoing wave from A to B as it leaves A. The time-domain equations of the bidirectional delay are B+ A− vA (n) = vB (n − 1) A+ B− vB (n) = vA (n − 1) (4.7) VBA+ = z −1 VAB− (4.8) or, in the Z-transform domain, VAB+ = z −1 VBA− Using these relationships, we can derive an expression for the incoming wave at junction A from junction B in terms of the junction velocities of A and B only: VAB+ = z −1 VBA− , = z −1 VB − VBA+ (4.9) - (4.10) 108 CHAPTER 4. OTHER MESH STRUCTURES * , = z −1 VB − z −1 VA − VAB+ Solving for VAB+ , VAB+ 4.1.3 = ( z −1 1 − z −2 ) , VB − z −1 VA -+ - (4.11) (4.12) The General Finite Difference Scheme Remember that these are N-port junctions, so that we can express the junction velocity at A in terms the sum of its input waves from the N surrounding junctions, VA = J + where VA γ N 2 $ J + VA γ N γ=1 (4.13) represents the incoming wave from junction J as it arrives at A. Generalizing Equation (4.12), we can write the N wave input velocities at the central junction, VAJγ+ , in terms of the central junction velocity, VA , and the surrounding N junction velocities, VJγ , J + VA γ = ( z −1 1 − z −2 ) , VJγ − z −1 VA - (4.14) Plugging (4.14) into (4.13) we can eliminate the wave input variables, and write an expression for the junction velocity at A in terms of only the velocities at the N surrounding junctions: 2 VA = N ( z −1 1 + z −2 ) N $ VJ γ (4.15) γ=1 Apply the inverse Z-transform to arrive at the time-domain finite difference equation for a waveguide mesh built of symmetrical N-port junctions. vA (n) + vA (n − 2) = N 2 $ vJ (n − 1) N γ=1 γ (4.16) These equations apply to the cases N = 4, which was the subject of the last chapter. It can also be applied to the 2-D case N = 6, and N = 8 which we show next. It also applies to the 3-D rectilinear mesh case, when N = 6. The 2-D N = 3 triangular case is problematic, since the symmetry at the junction-to-junction level alternates. A similar CHAPTER 4. OTHER MESH STRUCTURES 109 problem arises in the 3-D N = 4 tetrahedral case, which we will address later in the chapter. 4.1.4 Generalized Amplification Factors In Equation (4.16), the vJγ are the junction velocities at the N spatial points, Jγ . These points can lie in a plane, or in 3-D space around the central junction, vA . Let’s assume 3-D, just to be more general. Taking the points Jγ to be (xγ , yγ , zγ ), we can state the 3-D shift theorem in the Fourier domain as DFT IS vk+xγ ,l+yγ ,m+zγ ←→ ejωk xγ ejωl yγ ejωm zγ vωk ,ωl ,ωm (4.17) Re-stating the general mesh difference relationship, vA (n) + vA (n − 2) = N 2 $ vJ (n − 1) N γ=1 γ (4.18) we apply the Z-transform in the time domain, and the discrete-time Fourier transform on the infinite 3-D spatial series, to obtain: 1 + bz −1 + z −2 = 0 (4.19) N 2 $ ejωk xγ ejωl yγ ejωm zγ N γ=1 (4.20) where, b=− The general spatial amplification factor is √ −b ± j 4 − b2 G= 2 (4.21) with plane wave propagation speed calculated as % G C(ωk , ωl , ωm ) = 0 2 ωk2 + ωl2 + ωm (4.22) 110 CHAPTER 4. OTHER MESH STRUCTURES S S S S S S S S S S S S S S S S S S S S S S S S S Figure 4.3: 8-Port Rectilinear Mesh CHAPTER 4. OTHER MESH STRUCTURES 111 Figure 4.4: Dispersion in the 8-Port Rectilinear Mesh 4.2 The 8-Port 2-D Multiply-Free Mesh Some effort has been expended in developing mesh structures that meet the “multiplyfree” definition, and in general, this has been an important consideration. At the time this research was done, in the mid 1990’s, cost of silicon multiplies was high, in cycles as well as in custom silicon. To some extent computation costs are less critical today, however, to the extent that custom silicon may still be an option for certain applications, the multiply-free constraint may yet be relevant. The 8-port mesh is another case of no-multiply junction computation. The 2/N term with N = 8 can be implemented with two right shifts. The structure is the only one we discuss where waveguide bidirectional unit delays actually cross over each other on the diagonals, as shown in Figure 4.3. Letting N = 8, and plugging into the general waveguide mesh difference equation 4.16, we have, vA (n) + vA (n − 2) = N 1$ vJ (n − 1) 4 γ=1 γ (4.23) Taking the limit as the sampling intervals approach 0, we find that this difference 112 CHAPTER 4. OTHER MESH STRUCTURES S S S S S S S S S S S S S S S S S S S S Figure 4.5: 6-Port Triangular Mesh converges to the partial differential equation, 3 (uxx + uyy ) 4 utt = Hence, the ideal wave speed, c = 4.3 (4.24) # 3/4. The 6-Port 2-D Mesh The 6-way 2-D mesh turns out to be one of the best implementations in terms of dispersion error. This mesh operates on a grid where the 6 surrounding spatial points are located √ √ √ √ at: (−1, 0), (−1/2, 3/2), (1/2, 3/2), (1, 0), (1/2, − 3/2), (−1/2, − 3/2), As before, we can show that the difference scheme converges to the differential equation 2 (uxx + uyy ) 3 utt = with the wave propagation speed, c = (4.25) # 2/3. Computing wave propagation speed for the 6-port triangular mesh (see Equation (4.22)), we find the dispersion is quite uniform in all directions and small compared to other formations, as shown in Figure 4.6. 113 CHAPTER 4. OTHER MESH STRUCTURES Figure 4.6: Dispersion in the 6-Port 2-D Mesh 4.3.1 The 6-Port 2-D Multiply-Free Non-Isotropic Mesh As a quick example of variations that can be applied to reduce number of multiplies in the mesh computation, Figure 4.7 illustrates a situation where 2 of the 6 wave impedances are taken to be double the other directions. In this case, the junction equations are multiply-free: 3 4 3 1 1 V = V 1+ + V 2+ + V 3+ + V 4+ + V 5+ + V 6+ 4 2 A little math reveals the spatial sampling is compressed by isotropic behavior. 4.4 4 (4.26) # 3/5 in X direction to obtain The 6-Port 3-D Rectilinear Mesh Rectilinear meshes compute an approximation of the lossless 3-D wave equation as well (Savioja et al., 1995; Van Duyne and Smith, 1993b). Figure 4.9 shows a representation of the 6-port 3-D mesh structure. Each junction computes standard 6-port scattering. 114 CHAPTER 4. OTHER MESH STRUCTURES Z2 S Z2 Z2 S Z2 Z2 S Z2 S S Z2 S Z2 Z2 S Z2 S S Z2 S Z2 Z2 S Z2 S S Z2 S Z2 Z2 S Z2 S S Z2 S Z2 Z2 S Z2 Z2 S Figure 4.7: 6-Port Mesh with Non-Isotropic Wave Impedance Figure 4.8: Dispersion in the Non-Isotropic 6-Port Mesh Z2 CHAPTER 4. OTHER MESH STRUCTURES 115 Figure 4.9: Structure of the 6-Port Rectilinear 3-D Mesh 4.4.1 Animating the 6-Port 3-D Mesh Tim Stilson implemented a full 3-D mesh bent cylindrical tube simulation (Stilson, 1994), first published in (Van Duyne and Smith, 1996). Figure 4.10 shows the 3-D wave front making its way around the turn of a U-shaped tube. This structure was used to study room acoustics modeling in (Savioja et al., 1995). 4.4.2 Dispersion Error We show dispersion plots for the 6-port rectilinear 3-D waveguide mesh with the same 1% contour line settings. Figure 4.11 shows a horizontal slice through the origin, and Figure 4.12 shows a diagonal slice through ωx = ωz . Figure 4.13, again, shows the response on the hemispherical surface, |ω| = π/2. Sidelight: The 6-way 3-D Multiply-Free Non-Isotropic Rectilinear Mesh For potential full-silicon implementations, a no-multiply solution for the rectilinear mesh is available by setting the wave impedances in one direction equal to twice the wave CHAPTER 4. OTHER MESH STRUCTURES 116 Figure 4.10: Animation of the 3-D Rectilinear Mesh Modeling Compression Wave Through a Tube 117 CHAPTER 4. OTHER MESH STRUCTURES 1.5 1 0.5 0 -0.5 -1 ωy -1.5 -1.5 -1 -0.5 0 0.5 1 1.5 ωx Figure 4.11: Rectilinear Dispersion: ωz = 0 1.5 1 0.5 0 -0.5 ωy -1 -1.5 -1 -0.5 0 0.5 1 ωx,ωz Figure 4.12: Rectilinear Dispersion: ωz = ωx 118 CHAPTER 4. OTHER MESH STRUCTURES 1.5 1 0.5 0 -0.5 -1 ωy -1.5 -1 -1.5 -0.5 0 0.5 1 1.5 ωx Figure 4.13: Rectilinear Dispersion: |ω| = π/2 impedances in the other directions, and making the necessary adjustments to grid size in that direction. 4.5 The 3-Port 2-D Mesh Figure 4.14 shows a hexagonal mesh built out of three-port junctions. Note that the orientation of the junctions alternates. Referring to the detail Figure 4.15 we see that the central junction A has one port directly to the left, and two ports to the right, 60◦ up and 60◦ down. Junctions B, C and D all are just the opposite orientation: one port directly to the right, and two ports to the left, 60◦ up and 60◦ down. This makes the analysis a little trickier, since we cannot treat every junction as identical, and we must somehow represent the alternating pattern of junction orientations in the convergence analysis as well as the dispersion analysis. CHAPTER 4. OTHER MESH STRUCTURES Figure 4.14: The 3-Port 2-D Hexagonal Mesh 119 120 CHAPTER 4. OTHER MESH STRUCTURES 1/2 1 6 D B 2 C 3 √3 2 A 5 4 Figure 4.15: Close-up Showing Alternating Symmetry 4.5.1 Alternating Symmetry: Two Time Steps Needed To address the alternating symmetry of the junctions and simplify the math, we expand the analysis by one more time step. Note that the positions of the junctions around Junction A two steps out, Junctions 1,2,3,4,5 and 6, are actually symmetrical no matter which junction we put at the center. In this way we can get a general computation of dispersion in the difference: VA = = 2 3 ( z −1 1 + z −2 3 ( 4 VA = 9 2 3 ( )( VB + VC + VD ) )42 6 $ 3VA + Vγ −2 z −1 1+z z −2 1 + (2/3)z −2 + z −4 (4.27) (4.28) γ=1 ) 6 $ γ=1 Vγ (4.29) 121 CHAPTER 4. OTHER MESH STRUCTURES 4.5.2 Computing the Finite Difference n vl,m 6 2 n−2 4$ n−4 + vl,m + vl,m = v n−2 3 9 γ=1 l+xγ ,m+yγ (4.30) with surrounding junctions located two time steps out at (x1 , y1 ) = (0, √ (x2 , y2 ) = (3/2, (x3 , y3 ) = (x4 , y4 ) = (x5 , y5 ) = (x6 , y6 ) = 4.5.3 3) √ (4.31) 3/2) √ (3/2, − 3/2) √ (0, − 3) √ (−3/2, − 3/2) √ (−3/2, 3/2) (4.32) (4.33) (4.34) (4.35) (4.36) Verifying the FDA Converges to the PDE Define the continuous function: F(x, y, t, ε) = (4.37) 2 u(x, y, t) + u(x, y, t − 2ε) + u(x, y, t − 4ε) 3 6 4$ − u(x + xγ ε, y + yγ ε, t − 2ε) 9 γ=1 (4.38) (4.39) Plugging in the 3-D Taylor’s Series Expansion, we compute the limit as grid size shrinks: ( F 1 lim = utt − uxx + uyy ε→∞ (2ε)2 2 4.5.4 ) (4.40) Dispersion Results Dispersion for the three-port mesh is fairly uniform, as shown in Figure 4.16. 4.5.5 Animating the 3-Port 2-D Mesh Figure 4.17 illustrates a computed animation of the mesh in a sequence of time-domain snapshots. CHAPTER 4. OTHER MESH STRUCTURES 122 Figure 4.16: Three-Port Dispersion 4.6 4.6.1 The 4-Port 3-D Tetrahedral Mesh Motivation for the Tetrahedral Mesh The 2-D digital waveguide mesh (Van Duyne and Smith, 1993a; Van Duyne and Smith, 1993b) has proven to be effective and efficient in the modeling of musical membranes and plates, particularly in combination with recent simplifications in modeling stiffness (Van Duyne and Smith, 1994), nonlinearities (Van Duyne et al., 1994), and felt mallet excitations (Van Duyne et al., 1994). The rectilinear 3-D extension to the mesh had been suggested (Van Duyne and Smith, 1993b), and has been applied to the case of room acoustics (Savioja et al., 1995). However, it requires the use of 6-port scattering junctions, which make a multiply-free implementation impossible in the isotropic case. The 4-port scattering junctions of the 2-D mesh required only an internal divide by 2, which could be implemented as a right shift in binary arithmetic. However, the 6-port junction requires a divide by 3. The multiply-free cases occur for N -port junctions in which N is a power of two (Smith, 1987). We propose here a tetrahedral distribution of multiply-free 4-port scattering junctions, with junction port placement analogous to the 4-bond carbon atom shown in Figure 4.18. CHAPTER 4. OTHER MESH STRUCTURES Figure 4.17: The Animated 3-way 2-D Hexagonal Mesh 123 CHAPTER 4. OTHER MESH STRUCTURES 124 Figure 4.18: Methane: Tetrahedral Bonds on the Carbon Atom These four-port junctions may fill space tetrahedrally analogous to the molecular structure of the diamond crystal shown in Figure 4.19, where the placement of the scattering junctions corresponds to the placement of the carbon nuclei, and the bi-directional delay units correspond to the four tetrahedrally-spaced single bonds between each pair of nuclei. We show that the tetrahedral mesh is mathematically equivalent to a finite difference scheme which approximates the 3-D lossless wave equation. We further compute the frequencyand direction-dependent plane wave propagation speed dispersion error. 4.6.2 The Tetrahedral Difference Figure 4.20 shows a small chunk of the tetrahedral mesh. We take the distance between adjacent junctions to be 1, and the junction point marked A to lie at the origin √ of an (x, y, z) cartesian coordinate system. We arrange the junctions B(0, 2 2/3, 1/3), √ √ # # C( 2/3, − 2/3, 1/3), D(0, 0, −1), and E(− 2/3, − 2/3, 1/3) tetrahedrally about point A(0, 0, 0). The line segments between these junction points represent bi-directional delay units of the form shown in Figure 4.21. The equations describing the computation of the lossless 4-port scattering junctions are (Smith, 1987; Van Duyne and Smith, 1993a; Van Duyne and Smith, 1993b), VA = 1 $ Γ+ V 2 Γ A VAΓ− = VA − VAΓ+ (4.41) (4.42) CHAPTER 4. OTHER MESH STRUCTURES -2 0 -2 2 Figure 4.19: Diamond: The Tetrahedral Carbon Mesh 125 126 CHAPTER 4. OTHER MESH STRUCTURES 2 3 1 B 9 8 7 C 4 E A 5 6 D 12 10 11 Figure 4.20: 3-D Tetrahedral Mesh Structure VAB– Scattering Junction A VAB+ z-1 z-1 VBA+ Scattering Junction B VBA– Figure 4.21: Bi-Directional Delay Unit 127 CHAPTER 4. OTHER MESH STRUCTURES where Γ ranges over the four junction points surrounding A, namely Γ ∈ {B, C, D, E}. VA represents the junction velocity at junction A. VAΓ+ and VAΓ− represent the input and output signals, respectively, of junction A in the direction of junction Γ. Since the junctions are interconnected with bi-directional delay units, the input to junction A from the direction of Γ is equal to the output from Γ delayed by one sample. In the Z-transform domain we my write this relationships as, VAΓ+ = z −1 VΓA− (4.43) Using (4.42) and (4.43), we obtain an expression for the input signal to junction A from the Γ direction in terms of the junction velocities A and Γ only, , VAΓ+ = z −1 VΓA− = z −1 VΓ − VΓA+ * , = z −1 VΓ − z −1 VA − VAΓ+ which implies, VAΓ+ = ( z −1 1 − z −2 ) , -+ VΓ − z −1 VA - - (4.44) (4.45) (4.46) We substitute (4.46) into (4.41) to get an expression for the junction velocity VA in terms of the four surrounding junction velocities VΓ , 1 VA = 2 ( z −1 1 + z −2 ) $ VΓ (4.47) Γ Unfortunately, the orientations of the tetrahedra vary from point to point. Notice in Figure 4.20 that the tetrahedron around point A and that around point B are in vertically opposite orientations. However, consider the relationship between the center point A and the twelve equally-spaced junctions marked 1 through 12, which are all equidistant from A, and which are two time steps away from A. With some imagination, one can see that the directional relationships between point A and the outer twelve points repeats itself around every point in the mesh, regardless of orientation of the inner four points, B, C, D, and E. Therefore, we take note of the following relationships, which may be derived in a 128 CHAPTER 4. OTHER MESH STRUCTURES manner similar to (4.47), 1 VΓ = 2 ( z −1 1 + z −2 ) $ VA + Vγ Γ (4.48) γΓ where Γ ∈ {B, C, D, E} and γB ∈ {2, 8, 9}, γC ∈ {3, 4, 5}, γD ∈ {10, 11, 12} and γE ∈ {1, 6, 7}. Plugging (4.48) back into (4.47), we get an expression for VA in terms of the junction velocities of the twelve junctions, Vi : 1 VA = 4 ( z −2 −2 1 + z + z −4 ) 12 $ Vi (4.49) i=1 To see that this partial difference equation approximates the continuous time wave equation, we first multiply through by the denominator in (4.49), inverse Z-transform, and gather all the terms onto the left-hand side. Then, we view the equation as a continuous time and space expression of the form F(t, p) = 0, where F(t, p) is, 2 $ k=0 v(t − 2kε, p) − 12 1$ v(t − 2ε, p + P i ε) 4 i=1 (4.50) and p is now the arbitrary spatial position of junction A, and the P i represent the twelve directional vectors from point A to the junction points marked 1 through 12 in Figure 4.20, respectively. The unit time and space steps are taken to be ε. 4.6.3 Converging to the PDE We may expand (4.50) in a four dimensional Taylor series about the point p = (0, 0, 0) at time t = 0, replacing each term of (4.50) with something of the form, (nt ,nx ,ny ,nz ) nt nx ny nz t x y z ∞ $ ∞ $ ∞ $ ∞ v $ 0 nt nx ny nz nt !nx !ny !nz ! (4.51) Collecting terms and computing the limit reveals that F 1 = utt − [uxx + uyy + uzz ] 2 ε→0 (2ε) 3 lim (4.52) 129 CHAPTER 4. OTHER MESH STRUCTURES 1.5 1 0.5 0 -0.5 -1 ωz -1.5 -1 -1.5 -0.5 0 0.5 1 1.5 ωy Figure 4.22: Tetrahedral Dispersion: ωx = 0 Evidently, the tetrahedral waveguide mesh is equivalent to an FDS approximating the continuous wave equation. The apparent wave speed is c = # 1/3, which is the numerically optimal speed in the Courant-Friedrichs-Lewy sense (Courant et al., 1956; Strikwerda, 1989). (Incidentally, we found it convenient to use the symbol manipulating feature of the mathematics processing language Mathematica to verify the algebra.) 4.6.4 Dispersion Analysis To quantify dispersion error in the tetrahedral mesh, we apply a von Neumann analysis directly on the FDS (Strikwerda, 1989; Van Duyne and Smith, 1993a). Essentially, we transform the FDS into the frequency domain in both time and space, replacing spatial shifts with their corresponding spatial linear phase terms. Then we observe how the spatial spectrum updates after one time sample. With this information, we can determine how fast the various plane waves travel in the mesh at each frequency. There can be no attenuation since the mesh is constructed from lossless scattering junctions. Therefore, the only departure from ideal behavior, aside from round-off error, is traveling-wave dispersion. 130 CHAPTER 4. OTHER MESH STRUCTURES 1.5 1 0.5 0 -0.5 -1 ωz -1.5 -1.5 -1 -0.5 0 0.5 1 1.5 ωx Figure 4.23: Tetrahedral Dispersion: ωy = 0 1.5 1 0.5 0 -0.5 -1 ωy -1.5 -1.5 -1 -0.5 0 0.5 1 1.5 ωx Figure 4.24: Tetrahedral Dispersion: ωz = 0 131 CHAPTER 4. OTHER MESH STRUCTURES 1.5 1 0.5 0 -0.5 ωy -1 -1.5 -1 -1.5 -0.5 0 0.5 1 1.5 ωx Figure 4.25: Tetrahedral Dispersion: |ω| = π/2 In order to avoid the difficulty of defining a discrete Fourier transform over a tetrahedrally sampled space, we consider the discrete-time/discrete-space difference scheme to be in continuous space by replacing the sample points in space by their corresponding generalized impulse functions, filling the regions in between them with zeros. In this formulation, the tetrahedral difference scheme applies to all points in space continuously; however, since there shall only be initial conditions at the tetrahedral mesh sampling points, the zero regions will remain at zero as the difference scheme progresses through time. We may now take the spatial Fourier transform of (4.49) and replace the spatial positions of the twelve outer junction points with their corresponding linear phase terms, T Vi ←→ V (ω)ejP i ·ω , where ω is the three-dimensional spatial frequency vector, to obtain the following quadratic expression in z −2 : 1 + bz −2 + z −4 = 0, ∆ b=1− 12 T 1$ ejP i ·ω 4 i=1 (4.53) where z −2 represents two time samples of delay. Due to the symmetrical orientation of 132 CHAPTER 4. OTHER MESH STRUCTURES vectors P i , as indicated in Figure 4.20, it may be shown, rather remarkably, that the value of b remains a real number between −2 and 2 for all values of ω. Hence, we may define b G (ω) = − ± j 2 2 ∆ √ 4 − b2 2 (4.54) where G is the spectral amplification factor of the spatial spectrum after one time sample. It is easy to show that |G| ≡ 1, hence plane waves propagate losslessly. We note that the phase of G corresponds to the spatial phase shift of a plane wave in the direction of travel in one time sample, where % √ 1 ± 4 − b2 G = arctan 2 b (4.55) Hence, the phase distance traveled in one time sample by a spatial plane wave of frequency |ω| and direction ω is c& (ω) = % G/|ω|, where c& (ω) is the frequency dependent speed of plane wave travel measured in space samples per time sample. (Phase distance corresponds to phase advance in time domain language.) Dispersion Results Figures 4.22, 4.23 and 4.24 show contour plot slices along the planes ωx = 0, ωy = 0, and ωz = 0, respectively, of the normalized plane wave speed c& (ω)/c in the tetrahedral mesh. The innermost contour line is drawn at 99% of full speed and subsequent lines are drawn at 1% intervals. Because of the spatial sampling interval, there is a Nyquist limit on the spatial frequencies which may be supported on the mesh, namely |ω| < π. In addition, all transfer functions definable at any one junction, and the denominators of all transfer functions definable between any pair of junctions, are functions of z −2 , as may be seen from Figure 4.21. Therefore, frequencies above π/2 are not independent, and are constrained to be a copy of the frequencies below π/2. We have superimposed a circle marking this limit in the contour plots. The central area of each plot corresponds to lower spatial frequencies, and the outer regions correspond to higher spatial frequency. The angular position of a point on each plot indicates the direction of the wave travel in the planar slice being shown. Figure 4.25 shows the response on the hemispherical surface, |ω| = π/2, where ωz = 0 (π/2)2 − ωx2 − ωy2 . CHAPTER 4. OTHER MESH STRUCTURES 133 Both the rectilinear and the tetrahedral mesh have reasonable dispersion characteristics. And both model a wave speed of c = 4.6.5 # 1/3 space samples per time sample. Benefits of the Tetrahedral Mesh Over the Rectilinear Mesh Practical benefits of using the tetrahedral 4-port mesh over using the rectilinear 6-port 3-D mesh can be summarized as follows: The tetrahedral mesh uses 35% fewer junctions than the rectilinear mesh per unit volume. It also uses 57% less delay memory. The rectilinear mesh uses 1 multiply per junction, whereas the tetrahedral mesh is multiply-free. The rectilinear mesh uses 11 adds per junction, whereas the tetrahedral mesh uses 7 adds per junction. Although the bookkeeping required to develop code or silicon to implement the tetrahedral mesh requires some clever indexing, overall the extra effort may be worth the trouble in large systems. Chapter 5 The Passive Nonlinear Filter 5.1 Nonlinearity in Musical Instruments: Spectral Energy Spreading Among the various approaches to the digital synthesis of musical sounds, some involve the production and excitation of linear resonances which are characteristic of a musical instrument. The Karplus-Strong plucked-string algorithm (Karplus and Strong, 1983; Jaffe and Smith, 1983) models the vibrating string as a delay line loop. This is a special case of the physics-based digital waveguide modeling technique (Smith, 1992) which is applicable to many kinds of synthesis from strings to acoustic tubes (Smith, 1987; Cook, 1990; Hirschman, 1991; Välimäki, 1995). The vibrating membrane and other two- and three-dimensional musical structures have been physically modeled using the 2-D digital waveguide mesh (Van Duyne and Smith, 1993b) and are described in earlier chapters. It is in the context of these kinds of wave-decomposed digital modeling schemes that the present passive nonlinear filter most naturally resides. While properly excited resonances of linear systems can closely approximate the tones of some instruments, nonlinearity plays an essential part in the sound of other instruments. Fletcher and Rossing (Fletcher and Rossing, 1991) observe that after striking cymbals, Chinese gongs or tam-tams, the spectra become brighter with time. The higher portions of the spectra rise in comparison with the lower portions. The relative rise in higher frequencies, which is essential to the timbre of the sound, comes about because nonlinearities transfer vibrational energy from lower frequency to higher frequency modes. 134 CHAPTER 5. THE PASSIVE NONLINEAR FILTER 135 Beyond this, Lagge and Fletcher (Lagge and Fletcher, 1984) have shown that small nonlinearities in the compliance of a bridge supporting one end of a vibrating string can cause the transfer of energy among modes of vibration. Thus, nonlinearities may have a smaller but nonetheless important effect on the tones of some stringed instruments. We have found that the addition of passive nonlinearities to an otherwise linear digital synthesis algorithm can cause the transfer of energy among modes, and can lead to large and interesting alterations and evolutionary changes in timbre. In physical instruments nonlinearities are necessarily passive because physical nonlinearities cannot cause an increase in total energy, but can only transfer energy among modes. The use of nonlinearities that are inherently passive in digital sound synthesis is important because other ways of adding nonlinearity can result in instability or oscillation. If our passive nonlinearity is also lossless, we can avoid unwanted, or unpredictable loss in our system as well. The means we have used for adding nonlinearities is to incorporate a “circuit element” that is necessarily passive. The circuit element we have used is a spring that is stiffer for deflection in one direction than in the other, or a capacitance that has a different value for positive than for negative voltages. Such an element stores no energy at zero deflection (spring) or at zero voltage (capacitor). Any energy that is stored by an increase or decrease in deflection or voltage will be given up as the voltage goes to zero. The element can store and release energy, but it cannot produce energy. We have found that the use or addition of this simple element is economical in computation and effective in causing energy transfer among otherwise linear modes. It can lead to a substantial and pleasing alteration in the sound produced. Our addition of passive nonlinearities is different from the use of nonlinearities to excite or maintain oscillations of blown or bowed instruments (Smith, 1987). The purpose of the passive nonlinearities we have used is not to initiate or maintain oscillation, but to modify the spectrum naturally over time by transferring energy among modes. The research presented in this chapter was developed in collaboration with John R. Pierce, and was first published in (Pierce and Van Duyne, 1997a; Van Duyne et al., 1994) and (Pierce and Van Duyne, 1997b). 136 CHAPTER 5. THE PASSIVE NONLINEAR FILTER + delay line * ε + 1−ε lowpass filter Figure 5.1: Delay Loop with Square Law Nonlinearity 5.2 Memoryless Nonlinearities While many spectral modifications can be achieved by memoryless nonlinearities (Rodet, 1994), energy conservation is difficult to control without additional amplitude tracking and/or scaling elsewhere in the loop. For example, Figure 5.1 illustrates a simple resonant delay line loop with a lowpass attenuation filter, much like the Karplus-Strong pluckedstring algorithm (Karplus and Strong, 1983), which has been modified to include a square law nonlinearity within the feedback loop. The ε and 1 − ε scalings allow some control over how much nonlinearity shall be present in the loop. For small ε, a pleasant spectral brightening may occur over time. We note that, interpreted physically, this kind of memoryless nonlinearity corresponds to a string terminated with a dashpot whose coefficient varies with the force applied to it, or to an oscillating transmission line terminated with a resistor whose coefficient depends on the voltage drop across it. In Figure 5.1, the choice of scaling coefficients will guarantee passivity of the system, however, as we increase ε, thereby increasing the amount of nonlinearity in the system, the nonlinear dashpot becomes more and more lossy. Yet, for gongs and cymbals, a large nonlinear effect is required. We might adjust the scaling factors to allow more nonlinearity without as much loss, but this could correspond to physical systems where the terminating dashpot has a negative, non-passive, coefficient for certain forces and we risk instability without a careful monitoring of the overall loop gain. To resolve this dilemma, we have approached the problem through physical modeling of a passive nonlinear system with internal state. We have derived a nonlinear filter based on a real physical system constructed from passive, lossless elements only, namely two CHAPTER 5. THE PASSIVE NONLINEAR FILTER 137 springs of differing stiffness. 5.3 5.3.1 Passive Nonlinearity: The Physical Concept First Attempt: The Bent Spring Termination The first attempt was to develop a model of a string terminated with a bent springy bridge (Pierce, 1993a). Figure 5.2 shows an artist’s rendering of this above, and a gong viewed as a bent plate below. The idea is that the essential functional aspect of the gong is the presence of many bends in the plate which function in a manner similar to the bent termination of the string. John R. Pierce actually constructed a physical monochord made of wood and metal with a single string with such a termination and was able to demonstrate, by plucking the string, the energy in the fundamental was being transferred nonlinearly into the second mode an octave above. We can understand the mechanism of this transfer as follows: As the string vibrates in its pure first mode up and down at frequency f0 , it pulls on the springy termination twice per period (once at the upper extremity of its excursion, and once at the lower extremity. Because the springy termination is at a 45◦ angle, as it gets pulled in twice per period, it also bends up and down twice per period, thus driving the string at transverse frequency 2f0 . While this model provided excellent intuition, it proved difficult to find a mathematically efficient digital filtering model of the physics. The following nonlinear mass-spring circuit offered more opportunities to the wave-theoretic physical modeling techniques. 5.3.2 Second Attempt: The Mass-Spring System with Alternating k Consider a passive nonlinear physical mass/spring oscillator as shown in Figure 5.3. In this system, the springs are taken to be at rest when the mass is at displacement zero, touching both springs, but feeling no force from either spring. When the mass is at a positive displacement, it is feeling force from the upper spring with stiffness constant k1 ; when it is at negative displacement, it is feeling force from the lower spring with stiffness constant k2 . Note that the resultant oscillation is clearly periodic, but that the upper half of the cycle is at a different frequency and has a different maximum displacement than the lower CHAPTER 5. THE PASSIVE NONLINEAR FILTER 138 Figure 5.2: String with Bent Springy Termination and Gong Viewed as Bent Plate 139 CHAPTER 5. THE PASSIVE NONLINEAR FILTER lower frequency greater maximum displacement k1 k1 k1 m m m k2 k2 k1 m m k2 k1 k2 k2 smaller maximum displacement higher frequency time Figure 5.3: Passive Nonlinear Mass/Spring Oscillator half of the cycle. When k1 and k2 are nearly equal, but different, this nonlinear oscillator has an essentially sinusoidal response, but with a rolling–off set of harmonic overtones due to the slight discontinuity at displacement zero–crossings. + v – i C= { C1, v ≥ 0 C2, v < 0 Figure 5.4: Equivalent Electrical Capacitance Circuit 140 CHAPTER 5. THE PASSIVE NONLINEAR FILTER + v i L= – { L1, L2, i≥0 i<0 Figure 5.5: Equivalent Electrical Inductance Circuit 5.3.3 The Equivalent Electrical Circuit: Nonlinear Inductor or Capacitor This nonlinear spring circuit can be viewed in the electrical domain as shown in Figure 5.4: The nonlinear spring is mathematically equivalent to a nonlinear capacitor whose capacitance value depends on the sign of the voltage across it (Pierce, 1993b). Voltage, v, replaces mechanical force, f ; and current, i, replaces mechanical displacement velocity, v. Figure 5.5 shows the dual circuit with voltage and current interchanged. In this case, the inductance value depends on the direction of the current flow through the circuit. Examples of electrically equivalent circuits of physical impedances found in musical instruments can be found in (Fletcher and Rossing, 1991). More on linear electrical circuits can be found in (Cruz and Van Valkenburg, 1974). 5.3.4 String Terminated with a Nonlinear Spring Consider a string terminated by a double spring apparatus as shown in Figure 5.6. Three states of the system are shown in the figure: First, the lower spring is compressed, while the upper spring is at rest; second, both springs are at rest; and, third, the upper spring is compressed, while the lower spring is at rest. In effect, the spring termination apparatus is equivalent to a single nonlinear spring whose stiffness constant is k1 when the displacement is positive and k2 when the displacement is negative. Now consider what is happening to the energy in the system. When the lower spring is compressed, some energy from the string is converted to potential energy stored in the spring. When the lower spring returns to its rest state, the stored spring energy is entirely returned to the string, and the spring contains no stored energy. When the upper spring is then compressed, exactly the same kind of energy exchange occurs. This ideal system 141 CHAPTER 5. THE PASSIVE NONLINEAR FILTER at rest k1 compressed k2 at rest k1 at rest k2 compressed k1 at rest k2 Figure 5.6: String Terminated with Double Spring 142 CHAPTER 5. THE PASSIVE NONLINEAR FILTER + i + R0 – Transmission line or other resonant system v C= – { C1, v ≥ 0 C2, v < 0 Passive Non-Linear Capacitor Figure 5.7: Nonlinearly Terminated Transmission Line is physically passive and lossless since energy is neither created nor destroyed. If the spring stiffness constant had changed while stored potential energy was still in the spring, i. e., when one of the springs was still compressed, the stored energy would be scaled by the new relative stiffness of the spring. In this case, the stored energy before the stiffness change would be different from the stored energy after the stiffness change, leading to the creation or loss of energy, possibly resulting in a non-passive system. In our model of this physical system, we must be careful to change the spring stiffness coefficient at the right time, to preserve passivity and losslessness. Passivity is the requirement that no energy be created by the system. When energy is created in a feedback loop, stability problems may ensue. We have specifically tried to discover a nonlinear system which is passive, and which is lossless, so the system loss may be decoupled from the nonlinear effect, and designed separately. Figure 5.7 shows a transmission line (Kock, 1937; Magnusson, 1970) terminated with a nonlinear capacitance circuit. This is an electrically equivalent circuit to the string terminated by nonlinear spring shown in Figure 5.6. Here, the electrical characteristic impedance of the transmission line corresponds to the mechanical wave impedance of the string, R0 . 5.4 Nonlinear Filter Derivation We will first derive the linear spring equations, then terminate a string with a linear spring. From there we determine how to vary the spring stiffness appropriately, and investigate the way in which energy spreads through the modes. CHAPTER 5. THE PASSIVE NONLINEAR FILTER 143 k f x Figure 5.8: Simple Linear Spring System 5.4.1 The Simple Linear Spring The force equation for the ideal linear spring shown in Figure 5.8 is, f (t) = kx(t) =⇒ df (t)/dt = kv(t) (5.1) where f (t) is the force applied on the spring, x(t) is the compression distance of the spring, v(t) is the velocity of compression, and k is the spring stiffness constant. Taking the Laplace transform, and assuming no initial force on the spring, we get, F (s) = (k/s)V (s) (5.2) Here, k/s is the lumped impedance of the spring. Setting s = jω will give the frequency response of this system. 5.4.2 Terminating a String with a Spring Figure 5.9 shows a string terminated by a spring. The physical force at the string termination is the sum of the transverse force waves on the string at that point, f = fr + fl , while the physical velocity at the termination is the difference between the force waves scaled by 1/R0 , v = (1/R0 )(fr − fl ). We may, therefore, re-formulate Equation (5.2) as a transfer function from Fr to Fl , F (s) = (k/s)V (s) Fr (s) − Fl (s) Fr (s) + Fl (s) = (k/s) R0 (5.3) (5.4) 144 CHAPTER 5. THE PASSIVE NONLINEAR FILTER Wave Impedance R0 fr fl k Figure 5.9: String Terminated by Simple Spring Fl (s) = k/s − R0 Fr (s) k/s + R0 (5.5) The force wave transfer function is stable and allpass since its pole is at s = −k/R0 and its zero is s = k/R0 , where k and R0 are defined to be positive real numbers. 5.4.3 Bilinear Transform from s-Plane to z-Plane To move from the continuous physical system to the discrete digital filter, we use the conformal bilinear transform from the s-plane to the z-plane (Nehari, 1952), s←α 1 − z −1 1 + z −1 (5.6) The bilinear transform maps DC in the continuous system to DC in the digital system, while mapping infinite frequency in the continuous system to half the sampling rate, or the Nyquist frequency, in the digital system. α is a degree of freedom which may be used to control the frequency warping. It is usual to choose α = 2/T to obtain faithful frequency response at the low end of the frequency range. We apply the bilinear transform to Equation (5.5) to obtain, Fl (z) = H(z)Fr (z) where, H(z) = a0 + z −1 1 + a0 z −1 and a0 = (5.7) k − αR0 k + αR0 (5.8) 145 CHAPTER 5. THE PASSIVE NONLINEAR FILTER z-1 fr(n) + a0 u(n) − + fl(n) z-1 Figure 5.10: The Allpass Spring Termination a0 ranges from −1 to 1 as k ranges from 0 to ∞. α is a degree of freedom in the bilinear transform allowing some control over the nature of the frequency warping in moving from continuous time to discrete time. By a similar derivation, we may obtain the equivalent velocity wave transfer function, Vl (z) = −H(z)Vr (z) (5.9) Figure 5.10 shows a system diagram of the spring termination, H(z), using the force wave construction given in Equations (5.7) and (5.8). 5.4.4 Making the Spring Nonlinear Since the filter coefficient, a0 , represents the spring stiffness, we need only change a0 to effect a change in the stiffness of the spring termination. We must, however, effect the change just at the point where the spring is at rest to preserve physical and digital passivity and losslessness. 5.4.5 Finding the Digitally Correct Coefficient Gating Signal Referring to Figure 5.10, consider the case where the input signal to the filter is always ∆ zero, fr (n) ≡ 0, but where there is some internal state value, namely, let u(−1) = u0 . Since, we see from the system diagram, u(n) = −a0 u(n − 1) = (−a0 )n+1 u0 (5.10) (5.11) CHAPTER 5. THE PASSIVE NONLINEAR FILTER 146 we can, then, write the filter output signal, due only to the internal filter energy state ringing out, as, fl (n) = a0 u(n) + u(n − 1) = a0 [−a0 u(n − 1)] + u(n − 1) = (1 − a0 2 )u(n − 1) = (1 − a0 2 )(−a0 )n u0 (5.12) (5.13) (5.14) (5.15) If we change the filter coefficient, a0 , it is clear that the internal state energy will ring out of the filter with a different decay rate than if the coefficient had not been changed. Such coefficient changes, if made arbitrarily, may lead to instability in a feedback loop. However, if u0 is zero or near zero, we change the coefficient with relative impunity, since the resultant discontinuity in the state energy will be minimal or zero. Therefore, we choose to gate the filter coefficient change on the sign of u(n), to maintain passivity in the nonlinear allpass filter. As noted, there may necessarily be some small state energy in the filter at the time that the coefficient changes. In nonlinear string modeling for the purposes of musical instrument sound synthesis, there is generally a frequency-dependent summary loss filter in the loop making the small energy variation insignificant. However, there are a number of things that can be done to mitigate this small error further. One simple thing would be to compute the allpass filter one sample ahead with the first coefficient to see if the state will change signs. If it does change signs, then re-compute the filter with an intermediate interpolated filter coefficient for just one sample before switching to the second coefficient (Abel and Van Duyne, 2007). In addition, ways to eliminate allpass transients have been described in (Välimäki et al., 1995). Why u(n) is the Physically Correct Gating Signal From the allpass filter implementation in Figure 5.10, we may observe that, fl (n) = a0 u(n) + u(n − 1) (5.16) CHAPTER 5. THE PASSIVE NONLINEAR FILTER 147 Also we have, u(n) = fr (n) − a0 u(n − 1) =⇒ fr (n) = u(n) + a0 u(n − 1) (5.17) Since, the actual physical force applied to the spring termination is equal to the sum of the input and output force waves, we may derive an expression of the actual force on the spring, f (n), from (5.16) and (5.17), ∆ (5.18) = [u(n) + a0 u(n − 1)] + [a0 u(n) + u(n − 1)] (5.19) = (1 + a0 )[u(n) + u(n − 1)] (5.20) f (n) = fr (n) + fl (n) Equation (5.20) says that the actual physical force on the spring is proportional to a linearly interpolated value of signal u at time n − 0.5. From Equation (6.22), displacement of the spring termination is zero when force is zero, and f (n) is zero when u(n)+u(n−1) is zero. Therefore, when u changes sign between times n − 1 and n, the spring displacement is closest to zero. This is the physically correct time to let the spring stiffness coefficient change for the nonlinear spring termination system given in Figure 5.6. Digital Interpretation The internal filter state signal, u(n), represents the energy stored in the filter. Assuming no input signal, i. e., fr (n) ≡ 0, and some internal state value at time n = −1, namely, ∆ u(−1) = u0 , we may then compute the output of the filter caused only by this internal energy state value as, fl (n) = (1 − a0 2 )(−a0 )n u0 (5.21) This method of gating the coefficient change is both physically correct and digitally correct. 5.4.6 Implementation Figure 5.11 shows a digital system diagram for the nonlinear string/spring system of Figure 5.6. Note that, for convenience, we use a look–up table notation to show how u(n) gates the coefficient change; but, in general, this would be implemented in simple conditional logic. Note that the rate of spreading, and the spectral region where it is most 148 CHAPTER 5. THE PASSIVE NONLINEAR FILTER excitation + N samples of delay fr(n) u(n) + − a2 a1 z-1 output Loss De-tuning fl(n) ∗ z-1 + Figure 5.11: Nonlinear String/Spring System active, may be controlled by the choice of a1 and a2 . 5.5 Why It Works from a Phase Modulation Perspective The time–varying allpass termination filter shown in Figure 5.11 is essentially lossless and passive. However, for it to be useful it must behave in the desired manner. Energy in existing resonant modes of the main system must be caused to spread locally in the spectrum to nearby modes of the system, as is observed in real musical instruments (Fletcher and Rossing, 1991). Empirically, this seems to happen, as seen in Figures 5.17 through 5.20. However, this filter is difficult to analyze strictly, due to its signal dependent time–variation and due to its inclusion in a feedback loop system. Nonetheless, we may obtain an intuitive understanding of its operation by considering a simpler, but non-passive, form. The termination filter in Figure 5.11 is essentially a one–pole allpass filter with a time– varying coefficient. We may study the effects of this filter in a feedback loop by studying the effects of coefficient–variation on a one–pole allpass filter. We, first, consider how the phase response of such a filter depends on its coefficient, then, how sinusoidal variation of that coefficient generates sidebands in the output signal. From there, we will see how the sort of time–variation defined in this filter structure will generate desirable energy spreading in a feedback loop. 149 CHAPTER 5. THE PASSIVE NONLINEAR FILTER 3 2 ∠H(ejω) 1 ω 0.5 1 1.5 2 2.5 3 a0 = .8 -1 a0 = -.8 -2 -3 Figure 5.12: Phase Response of the One–Pole Allpass Filter 5.5.1 Phase Response of the One–Pole Allpass Filter Consider the force wave transfer function given in Equation (5.8). This is a one–pole allpass filter. Its gain is unity and, in general, its phase response, % H(ejω ), decreases monotonically from 0 to −π/2 as ω goes from 0 (DC) to π (Nyquist frequency). Figure 5.12 shows several overlaid phase response plots for this filter with different coefficient values, a0 ranging from −0.8 to 0.8. Now, consider two allpass filters, H1 (z) and H2 (z) which have two different coefficients, a1 and a2 , respectively. Let a1 = acenter + ∆a/2 and a2 = acenter − ∆a/2, where acenter is the center of variation (acenter = (a1 + a2 )/2), and ∆a is the maximum deviation (∆a = a2 − a1 ). Figure 5.13 shows the difference in phase responses of the two filters, % H1 (ejω ) − % H2 (ejω ), for a series of coefficient pairs generated by letting acenter range from −0.8 to 0.8, and holding ∆a constant at 0.3. What the plot shows is that acenter determines which region of the spectrum has the greatest phase response variation for a given ∆a. Figure 5.14 shows the phase response difference for a series of coefficient pairs generated by holding acenter constant at −0.5 and letting ∆a range from 0.1 to 0.6. This plot shows 150 CHAPTER 5. THE PASSIVE NONLINEAR FILTER 3 2 1 ∠H1(ejω) – ∠H2(ejω) ω 0.5 1 1.5 2 2.5 3 -1 -2 a1,2 = -.8 ± .15 a1,2 = .8 ± .15 -3 Figure 5.13: Effect of Varying acenter how ∆a determines the amount of phase response variation for a given acenter . 5.5.2 Sinusoidal Variation of the Coefficient If we drive the one–pole allpass filter, H(z), with a sinusoid of frequency f1 , and vary the coefficient, a0 , sinusoidally at frequency f2 around some center value, acenter , with deviation ∆a, we should expect the filter to apply a quasi–sinusoidal phase modulation to the input signal due to the phase response variation predicted in the preceding paragraphs. The resultant output signal of the filter should contain sidebands around the driving frequency, f1 , separated by the coefficient modulating frequency, f2 . Furthermore, the deviation, ∆a, should determine the “index” of modulation, in the FM sense, and thus, the amount of energy in the sidebands. Figure 5.15 shows the magnitude response on a dB scale of H(z), with sinusoidally varying coefficient, a0 (n) = −0.7 − cos(2πf2 nT ), driven by an input sinusoid, cos(2πf1 nT ), where f1 = 8000 Hz, f2 = 2000 Hz, and the sampling interval, T = 1/44100 seconds. Figure 5.15 verifies that the filter output is very near to the predicted phase modulation, containing a set of sidebands of the form, cos(2πf1 T ± k2πf2 T ). 151 CHAPTER 5. THE PASSIVE NONLINEAR FILTER 3 2 ∠H1(ejω) – ∠H2(ejω) 1 a1,2 = -.5 ± .05 1 0.5 1.5 2 ω 2.5 3 -1 a1,2 = -.5 ± .3 -2 -3 Figure 5.14: Effect of Varying ∆a 75 50 25 5000 10000 15000 20000 -25 -50 -75 Figure 5.15: Output Spectrum from Sinusoidally Driven, Sinusoidally-Modulated Allpass Filter CHAPTER 5. THE PASSIVE NONLINEAR FILTER 152 Figure 5.16: Evolving Spectrum of String/PNF System 5.5.3 Step Variation of the Coefficient In general, if we flip the coefficient of a one–pole allpass filter between two values periodically, the coefficient signal, a0 (n), is then a square wave with a spectrum containing rolling–off odd harmonics. The output signal spectrum produced by this kind of coefficient modulation will contain greater emphasis in the odd sidebands than a simple sinusoidallymodulated filter, due to the odd harmonics in the coefficient modulation signal. For coupling to occur in the resonant system, the sidebands produced by the modulated allpass filter must fall on supported modes of the system. When a sideband coincides with a supported mode, that mode will be driven by the energy in the appropriate sideband. Energy from sidebands which do not fall on supported modes will not drive any particular mode and will simply be absorbed back into the system. In the passive nonlinear filter structure, we choose to gate the coefficient alternations on the state signal u(n) as shown in Figure 5.11. Since the coefficient signal will have the same effective fundamental as the driving input signal, we can expect the resultant sidebands to fall on multiples of the effective fundamental of the input signal, thereby driving at least some supported modes of the system. The sidebands are, therefore, tuned well for energy spreading to occur into nearby system modes on a string. Figure 5.16 shows the gradual spreading out of spectral energy of a waveguide string system terminated with the passive nonlinear filter. 153 CHAPTER 5. THE PASSIVE NONLINEAR FILTER kHz 4 3 2 1 0 0 2.5 5.0 7.5 10.0 sec Figure 5.17: Harmonic Loop with Lowpass Filter kHz 4 3 2 1 0 0 2.5 5.0 7.5 10.0 sec Figure 5.18: Harmonic Loop with Lowpass Filter and Passive Nonlinear Filter 154 CHAPTER 5. THE PASSIVE NONLINEAR FILTER kHz 4 3 2 1 0 0 5.0 10.0 15.0 20.0 sec Figure 5.19: Inharmonic Loop with Lowpass Filter kHz 4 3 2 1 0 0 5.0 10.0 15.0 20.0 sec Figure 5.20: Inharmonic Loop with Lowpass Filter and Passive Nonlinear Filter 5.6 Simple Models of Spectrally Active Sounds We tested the passive nonlinear filter in a variety of musical situations. Shown here are comparisons of the spectral evolution, with and without nonlinearity, of two sounds generated by essentially the model in Figure 5.11. In the first example, Figure 5.17 shows the spectral evolution of a simple delay line plus lowpass filter loop excited in such a way that the third harmonic is highly attenuated, and in which the nonlinear filter is de-activated. We see a natural exponential decay with higher frequency modes decaying faster than low frequency modes. In Figure 5.18, the passive nonlinear filter has been activated with the result that the spectrum brightens over time; in particular, the initially missing third harmonic builds up energy, as do several higher harmonics. After a few seconds, the effect of the lowpass filter in the loop takes over and the loop decays out. CHAPTER 5. THE PASSIVE NONLINEAR FILTER 155 In the second example, the same system is used with the addition of an allpass filter in the loop to detune the modes slightly giving it a more bell-like tone. Figure 5.19 shows the spectral evolution when the nonlinear filter is de-activated. Figure 5.20 shows the result when the nonlinear filter is operating. Note that the modes exchange energy among themselves in a more dynamic manner in this inharmonic case. In addition to these simple loop cases, we have produced promising gong sounds by incorporating passive nonlinearities into the 2-D digital waveguide mesh membrane model (Van Duyne and Smith, 1993b; Van Duyne et al., 1994). Figure 6.14 in the next chapter shows the structure of the waveguide mesh gong model, with passive nonlinear filters terminating the sides. 5.7 Summary The passive nonlinear filter structure has many musically useful features: 1. It is not a look–up table, nor is it a memoryless combination of two or more separate signals. Rather, it has an internal state: Its effect is dependent not only on the current input sample, but also on previous input and output samples. 2. The coefficient variation is specialized: we change the coefficient only when the stored energy in the internal state is crossing zero. When the energy state is building up or dissipating, we hold the coefficient constant. Therefore, there is neither creation nor loss of energy. The result is that we may introduce a filter of this type into a feedback loop with no worries about system stability; and the nonlinear effect is completely decoupled from system loss considerations. 3. The coefficient variation is independent of the overall evolution of the musical tone. This means that multiple attack transients may be introduced into the system while it is still running without having to reset the parameters. The variation control parameters are constant for a given physical model. 4. The nonlinear filter is actually a correct physical model of a real passive nonlinear physical system. It may, therefore, be connected into any physical model in a physically intuitive way. CHAPTER 5. THE PASSIVE NONLINEAR FILTER 156 5. It spreads energy smoothly and locally in the spectrum in a manner qualitatively equivalent to nonlinear energy spreading observed in real musical instruments, such as the cymbal and the Chinese gong. The nature of the energy spreading is controllable in the following ways: (a) The rate of spreading may be adjusted continuously from very slow to very fast with one parameter. (b) The region of the spectrum affected by the nonlinearity may be tuned, so that energy in modes of a particular region of the spectrum will spread more quickly than energy in other regions. (c) Combining these control parameters, one may construct a group of cascaded, or individually attached filters tuned to particular regions of the spectrum, and given specific spreading–rate parameters, thereby, shape the way in which energy will spread through the various regions of the spectrum over time. 6. We have been able to create gong-like sounds, easily and intuitively, using a tuned set of nonlinear filters attached to the boundary terminations of a 2–D Digital Waveguide Mesh. The addition of the nonlinear filters changed the mesh sound from that of a spoon hitting a tin plate, to that of a smoothly evolving large cymbal crash. 7. The structure can be generalized. We use a one–pole allpass formulation here, because it is easy to understand; it is efficient; and it works well enough for our immediate purposes. However, the passivity–preserving method of coefficient variation we use may be applied to any filter with an internal feedback state. Chapter 6 The Wave-Decomposed Mass-Spring 6.1 Lumped Systems and Distributed Systems We wish to distinguish between two general kinds of physical systems: lumped systems and distributed systems. Lumped systems include such physical elements as masses, springs, and dashpots, or such electrical elements as inductors, capacitors and resistors. Lumped systems are generally characterized by their having no pure time delay in them. That is, when something acts on them, the reaction is instantaneous. Distributed systems include vibrating strings (Kock, 1937), acoustic tubes (Hirschman, 1991; Cook, 1990; Berners, 1999; Scavone, 1997), and electrical transmission lines (Magnusson, 1970). Distributed systems are characterized by the presence of time delay in their response. As a comparison of a lumped system and a distributed system, consider an ideal spring attached to a wall. When you push on the end of it the reaction is instantaneous: the spring is compressed to a distance proportional to how hard you push on it, and the compression velocity is proportional to the rate of change of force applied. This is a lumped system. On the other hand, consider a very long spring attached to a wall, which has mass and springiness distributed along its length. In this case, when a force pulse is applied at the end, a spring compression wave travels down the spring until it reaches the wall and then bounces off the wall, returning to the driving point. In this distributed case, you feel a resistive impedance at first, then later, after a time delay associated with the round trip travel time of the compression wave, you feel the end of the spring push back at you. 157 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING + 158 z-1 – H Figure 6.1: The Tuned One-Pole Allpass Filter Feedback Loop Thus far we have worked with the digital waveguide modeling of distributed systems, using delay lines to model the time delay in the system, and we have converted lumped impedances at string terminations into traveling wave transfer functions. In this chapter, we will re-interpret lumped systems as distributed systems a through change of variables. This will allow us to combine lumped systems in modular ways, and to access specialized internal state signals within the wave-decomposed lumped impedances. In the first part of the chapter, we will study a small tunable feedback loop, and re-interpret it as a wave-decomposed model of a mass-spring oscillator. We will then couple several of these mass-spring systems together in a wave-decomposed manner at a scattering junction. This work was first published in (Van Duyne, 1997; Van Duyne, 1998). In the remainder of the chapter, we will use these basic concepts and re-derive a nonlinear mass-spring system as a piano hammer or felt mallet and couple it to a string or a membrane. The piano hammer work was first published in (Van Duyne et al., 1994; Van Duyne and Smith, 1995d) 6.2 The Tuned One-Pole Allpass Feedback Loop Figure 6.1 shows a simple feedback loop containing one delay unit, one first-order allpass filter and a sign inversion. A first-order allpass filter has a monotonic phase response and the coefficient can be chosen such that the phase delay resulting from the sample delay unit is compensated for at some particular frequency θ by the phase advance caused by CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 159 the allpass filter. This will result in a delay loop that oscillates at that frequency. That is, we want, H(ejθT ) = ejθT (6.1) If we choose H(z) to be of the standard form, H(z) = a0 + z −1 , 1 + a0 z −1 (6.2) there is in fact no solution for a0 given arbitrary θ. This should be obvious since the phase response of a one-pole allpass is a phase delay, not an advance, ranging from 0 to −π. Hence, we put a sign inversion in the loop, as in Figure 6.1 to introduce a phase shift of π which makes the equation solvable in the following form, H(ejθT ) = −ejθT is solved by a0 = − cos θ, or, H(z) = − cos θ + z −1 1 − cos θz −1 (6.3) (6.4) Note that H may be implemented in a one-multiply form, and that the frequency of oscillation can be controlled by one parameter. 6.2.1 The Wave-Decomposed Mass-Spring Oscillator An alternative view of this loop is shown in Figure 6.2. It can be viewed as a waveguide of half-sample length, terminated on one end reflectively and on the other end by an allpass filter representing some purely reactive mass- or spring-like termination. Since the feedback loop in Figure 6.2 is a waveguide, and therefore a traveling wave structure of some kind, and since it only oscillates at one frequency, it is natural to imagine that it may be some kind of a traveling wave decomposition of a second-order mass-spring (inductor-capacitor) oscillator. If we open up the loop in Figure 6.2 into the form shown in Figure 6.3, and assign traveling velocity wave variables to it, we may write, V − = z −1 HV + (6.5) If we interpret the input and output signals to be a velocity wave decomposition, then we CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING z-1/2 –1 H z-1/2 Figure 6.2: The Very Short Waveguide v+(n) z-1 v–(n) H Figure 6.3: The Wave-Decomposed Second-Order Oscillator 160 161 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 1 + ejθTH z-plane 1 2 1 – ejθT H Figure 6.4: Geometric Computation of Impedance Phase Response may define the physical velocity to be, V =V++V− (6.6) Similarly, we may choose an arbitrary reference impedance, R0 , and form the following force wave relation, F = F+ + F− (6.7) where F + = R0V + , and F − = −R0 V − . Defining the impedance of this system to be R(z) = F/V , we obtain, F+ + F− V++V− V+−V− = R0 + V +V− 1 − z −1 H = R0 1 + z −1 H R(z) = (6.8) (6.9) (6.10) Using a geometric argument, it can be seen from Figure 6.4 that the numerator and denominator of R(ejθT ) lie on a diameter of a unit radius circle with center z = 1. By the CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 162 k f m v Figure 6.5: Impedance of This System is F (s)/V (s) = ks/(s2 + k/m) basic geometrical theorem, the numerator and denominator vectors form a right angle at the origin, and their phase difference is therefore −π/2. R(ejθT ) must be purely imaginary, i.e., it represents a purely reactive mass-spring-like system. Making the bilinear transformation to the s-plane, z −1 −→ α−s α+s , - we obtain, R(s) = 2R0α (1−a0) s2 + α2 , (6.11) s 1+a0 1−a0 - (6.12) Noting that the impedance function of the mass-spring system in Figure 6.5 system can be described as F (s)/V (s) = ks/(s2 + k/m), we see that a convenient interpretation of Equation 6.12 is to take 2R0 α , 1 − a0 (6.13) 2R0 . α(1 + a0 ) (6.14) 2R0 α , 1 + cos θ (6.15) 2R0 . α(1 − cos θ) (6.16) k= and, m= Recalling that a0 = − cos θ, we have, k= and, m= 163 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING m4 m1 m2 k1 m3 k2 k4 k3 kL Figure 6.6: Mass-Spring Oscillators Coupled at a Spring-Loaded Junction As θ approaches DC, m becomes larger and larger. And as θ approaches π, or the Nyquist frequency (which maps onto infinite frequency in the s-plane), k becomes stiffer and stiffer. This is consistent with real mass and spring systems. 6.2.2 Coupling the Oscillators with a Scattering Junction Now that we have the mass-spring oscillator in a wave decomposed form, we can couple them together via the standard sort of scattering junctions used in digital waveguide modeling or transmission line theory. Figure 6.6 shows a set of N mass-spring oscillators (in this case N = 4) joined together at a massless rigid rod which is in turn connected to a coupling impedance, in this case a stiff spring with stiffness coefficient, kL . We can see that this is a series junction since the velocity of the individual mass-spring systems, measured at the spring end of the system, are constrained to equal junction velocity, VJ . Further, the sum of the mass-spring forces balance the junction force, FJ . We have the equations, Vi = VJ , i = 1, 2, . . . , N (6.17) 164 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING Hi Vi+ ~ Σ – z–1 Vi– Σ VJ 2 Σ Ri Vi+ 1 RL + Σ Ri −Σ Ri + FJ Figure 6.7: Digital Implementation of Second-Order Oscillators Coupled at a Loaded Junction and, N $ Fi = FJ (6.18) i=1 Note that this system is equivalent to a set of parallel LC-circuit oscillators connected in series and terminated with a capacitor load, also in series. For the sake of understanding the load element, if the mass-spring system is terminated with a very stiff spring, that is kL is very large, then the system behaves much as if the four spring oscillators were just nailed to the floor. There would be very slight coupling and the modes of the coupled system would be essentially the same as the modes of the independent oscillators. In the electrical domain, this would be equivalent to terminating the loop with a very small capacitance, which would be much like opening up the circuit. Now the modes of interest in such systems are the poles of the impedance function. These poles are at frequencies where a driving force produces a zero velocity. Or, saying it the other way, these are the natural frequencies in the force signal felt at the driving point when the driving point is constrained to very slight motion (or held fixed in position). 165 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING Figure 6.7 shows a digital implementation of this mildly coupled system. Since the VJ signal is so close to zero in the very stiff spring junction loading case (in which we are interested), it is therefore a useless output signal. Instead, FJ may be easily computed as shown. The multi-dimensional signal on the left is just a set of one-multiply oscillators as described earlier (which may be implemented in parallel if desired). The summation element without a tilde computes the values, vi− = vJ − vi+ . The summation element with the tilde computes a scaled sum as shown in the diagram. If the number of mass-springs in the system, N , is chosen as some power of 2, and the arbitrary reference impedances of the wave-decomposed mass-spring systems are all taken to be equal to one over the number of mass-springs (so that 7 Ri = 1), then the number of multiplies can be reduced to one per mode plus possibly two more for the first-order junction filter, 1/(RL + 6.2.3 7 Ri ). Calibrating the Coupling Filter While it is easy to tune the oscillating loop, it is a little tricky to see what to do with the coupling filter. However, it seems that an approach such as that described in Chapter 2 for coupled strings, previously published in (Van Duyne and Smith, 1995b), can be applied here, since the coupling of wave-decomposed mass-spring systems and the coupling of waveguide string systems are anatomically identical from the scattering junction perspective. This calibration approach was first published in (Van Duyne, 1997). A theoretical single mode loop filter, L(z), may be found whose magnitude response at the various targeted modal frequencies is equal to the per sample attenuation rate of the respective modes; then, by manipulating the loaded scattering junction equations, it can be seen that the coupling filter, 1/(RL + L(z) as follows: CouplingF ilter = 7 Ri ), may be expressed as a function of 2 (1 − L(z)) 1 + N + (1 − N )L(z) (6.19) where N is the number of modes in the coupled mode system. Note that the order of the coupling filters is the same as the order of L(z). Metal vs. Wood Since the frequency-dependent decay rate profile of the coupled mode filter is localized in one coupling filter, it is easy to make qualitative modifications to the sound color. It is usual in most materials that high frequencies tend to die out more quickly, than CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 166 lower frequencies. Therefore, the theoretical loop filter L(z) described in the preceding paragraph, which represents the frequency dependent decay rate profile, is lowpass in nature. Since high frequencies in metal tend to resonate a little longer than they do in wood, it is also straightforward to control the metallic vs. wood-like quality of the sound generated by this coupled mode model with a single slider which adjusts the amount of lowpass characteristic in the L(z) filter. Calibrated examples of this were presented in (Porcaro et al., 1996). 6.3 Mass-Spring Oscillator vs. Mass-Spring Hammer The allpass/delay loop application just discussed is intended to resonate (make sound) at a predetermined frequency. The allpass filter is linear (fixed coefficients), and it is tuned to a predetermined desired modal frequency of the musical sound being modeled. The allpass/delay loop can be attached to a coupling filter adapted to attenuate signals at frequency, f, by a predetermined factor using a calibration method similar to that described in Chapter 2. In this way, the resonating tones decay away at a rate simulating the musical sound being modeled. On the other hand, as will be studied for the remainder of the chapter, the allpass/delay loop can also be used to simulate a felt piano hammer coming into contact with the string, squishing in a nonlinear way, un-squishing, and leaving the string. The allpass filter coefficient is not fixed: it is time varying and dependent on the state of the system in such a way as to vary resonant frequency of the allpass/delay loop from DC (0 Hz), up to some frequency determined by how much the hammer gets squished at maximum, and then back to DC, all within half a period of a wave form. The signal generated is a “hump”, in effect, just the first half of a sine wave period, smoothed out by the continuous frequency variation. The implementation of a nonlinear felt hammer model based on the traveling-wave decomposition of the lumped hammer system may be a useful development for string and mesh models which extends their usefulness: a physical model for a piano hammer. CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 6.4 167 Motivation for the Hammer Since the development of the 2-D digital waveguide mesh to model wave propagation in membranes and plates (Van Duyne and Smith, 1993a), it has been evident that an efficient and physically accurate excitation means was necessary to make the models more useful as sound synthesis algorithms. The musical effect of a struck string or drum is greatly determined by the nature of the hammer or mallet which strikes it. The attack transient of a struck instrument can be approximated by the injection of an appropriate, pre-computed excitation signal into the resonant system. However, this excitation method is not sufficient to cope with the complexities of certain real musical situations. For example, when a mallet strikes an ideal membrane, it sinks down into it, feeling a pure resistive impedance. The depression induces a circular traveling wave outward. If the membrane were infinite, the waves would never return, and the mallet would come to rest, losing all its energy into the membrane. If the membrane is bounded, however, reflected waves return to the strike point to throw the mallet away from the membrane. The first reflected wave to reach the mallet may not be sufficiently powerful to throw the mallet all the way clear, or may only slow down its motion; and later reflected waves may finally provide the energy to finish the job. This complex mallet–membrane interaction can have very different and difficult to predict acoustical effects, particularly when a second or third strike occurs while the membrane is still in motion, such as in a drum roll. Recent work in the piano hammer area has been informative in the development of our hammer/mallet model. Boutillon used finite difference schemes to model a non-dispersive piano string interacting with a felt hammer with an exponential felt compression function which took the effect of hysteresis into account (Boutillon, 1988). Suzuki modeled the piano string with lumped elements tuned to partial frequencies using a nonlinear hammer model with a fourth-order polynomial felt compression law (Suzuki, 1987). Chaigne and Askenfelt formulated a numerically stable finite difference scheme which accounted for loss and dispersion in the string. The hammer force follows an exponential felt compression law and is distributed over a small spatial window on the string (Chaigne and Askenfelt, 1994a). While these methods are extremely interesting and effective analytically, they are less efficient than the digital waveguide approach to string or membrane simulations for the 168 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING HAMMER m, k, µ WAVEGUIDE STRING delay v0δ(n) Rh(n) velocity waves A1(z) L2(z) R0 −1 delay SCATTERING JUNCTION L1(z) initial hammer velocity delay R0 −1 A2(z) delay Figure 6.8: The Digital Waveguide String/Hammer System purpose of real-time sound synthesis. We have therefore sought to find an efficient and natural wave theoretic model of the piano hammer, or felt mallet, which may be attached to the digital waveguide string model and to the 2-D digital waveguide mesh membrane model. 6.5 The Hammer Model We view the piano hammer, or felt mallet, as a nonlinear mass and spring system, the spring representing the felt portion of the hammer or mallet. Since the felt is very compliant when the hammer is just barely touching the string, yet very stiff when fully compressed, we must use a nonlinear spring in the model, whose stiffness “constant” varies with felt compression. In deriving the wave digital hammer filter, we first make a wave decomposition of the linear mass and spring system, then attach it to a waveguide string or membrane model via a scattering junction. Next we find a method to vary felt stiffness with compression, and finally account for hysteresis loss in the felt. 6.5.1 Overview of the Digital Waveguide String and Hammer Model The hammer system is decomposed into wave variables to simplify computation and to expedite interconnection with the traveling wave string model. The hammer felt is viewed CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 169 vk f m v k vm Figure 6.9: Mass and Spring Force Diagram as a spring with time–varying stiffness dependent on compression, f (t) = k (x(t)) x(t). The stiffness function, k(x), is exactly zero when the hammer is not in contact with the string, and increases smoothly as compression increases. In addition, we will allow for nonlinear loss in the spring, µ(x, v), which may be dependent on both compression and compression velocity of the felt. While both k(x) and µ(x, v) may be arbitrary, as long as both are sufficiently smooth, we have found a useful family of stiffness and loss functions which allow easy real-time computation. Figure 6.8 shows a general implementation of the string/hammer model. The string is represented as bi-directional traveling velocity waves, and the hammer system is attached via a series scattering junction. The L1 and L2 filters in the string loop are frequency dependent summary loss filters for the string segment in which they function, and the A1 and A2 filters are allpass filters correcting the phase dispersion in the respective string halves. These filters are placed at the inputs to the scattering junction so that the hammer system will see the physically correct velocity wave values. 6.5.2 The Mass and Spring System First we consider a linear mass and spring system, as shown in Figure 6.9. We wish to define the equations of motion for a mass and spring system driven at the spring end by an external force, where the mass has an initial velocity at time zero. Since the mass and spring are in parallel, we may observe that the driving point force applied to the left side CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 170 of the spring, f , is equally applied to the spring compression and to the mass, f = fk = fm (6.20) Also, the driving point velocity, v, is equal to the sum of the spring compression velocity and the mass velocity, v = vk + vm (6.21) The force equation for the spring alone is, f (t) = kx(t) =⇒ df (t)/dt = kv(t) (6.22) where f (t) is the force applied on the spring, x(t) is the compression distance of the spring, v(t) is the velocity of compression, and k is the spring stiffness constant. Taking the Laplace transform of (6.22), we can find an expression for Vk (s), Vk (s) = (s/k)Fk (s) (6.23) Similarly, taking the Laplace transform of, fm (t) = m dvm (t) − mv0 δ(t) dt (6.24) where mv0 δ(t) represents an initial momentum impulse setting the mass in motion at velocity v0 , we may find an expression for Vm (s), Vm (s) = Fk (s)/ms + v0 /s (6.25) Combining Equations (6.20), (6.21), (6.23) (6.25), we compute the driving point admittance relation for the mass and spring system in Figure 6.9, V (s) = Vk (s) + Vm (s) s 1 v0 = Fk (s) + Fm (s) + k ms s ) ( 2 v0 s + k/m F (s) + = ks s (6.26) (6.27) (6.28) 171 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING f(t) s2 + k/m ks v(t) v0δ(t) 1/s Figure 6.10: The Continuous-Time Mass-Spring System with Initial Velocity The admittance function, (s2 + k/m)/ks, is the steady state response of this second# order system. Note the admittance zeros are at ±j k/m, and the system oscillates at that frequency. The v0 /s term represents the transient effect of the time zero momentum impulse on the mass. Figure 6.10 interprets Equation (6.28) as a system with one output, V (s), and two inputs, F (s) and ∆(s): F (s) drives the steady state part of the system, while ∆(s) drives the transient part. 6.5.3 Traveling Wave Decomposition of the Lumped System Earlier in the chapter, we applied a more intuitive approach to deriving the wave variable decomposition for a mass and spring oscillator. Here, we apply more rigor, in order to carry forward the physical variables, and apply a momentum pulse excitation, and to model the nonlinear hammer/string interactions. We begin by defining wave variables for the lumped impedance in a manner analogous to distributed systems (Kuo, 1966; Fettweis, 1986). We may define F = Fin + Fout , where Fin is viewed as a force wave traveling into the impedance, and Fout is viewed as a force wave traveling out of the impedance. Similarly, we may define V = Vin + Vout . In the distributed case, waves actually travel a distance over time; and there is a wave impedance relation between the force and velocity waves traveling in the same direction determined by the parameters of the medium in which the waves are traveling. In the lumped case, the waves may only be understood to be traveling instantaneously; and the waves are CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 172 not traveling in any particular medium. However, we may still apply distributed system analysis methods to the system to obtain a wave-decomposed interpretation of the lumped impedance. Defining an Arbitrary Wave Impedance We may define an arbitrary reference impedance, Rh , and obtain a wave impedance relation between force and velocity waves, Fin = Rh Vin Fout = −Rh Vout (6.29) Note that Rh is truly arbitrary, aside from being a positive real number. We will make good use of this fact later on. Making the change of variables from F and V to Vin and Vout , we obtain a velocity wave transfer function from Equation (6.28), Vout (s) = s2 − (k/Rh )s + k/m Vin (s) s2 + (k/Rh )s + k/m v0 k/Rh + 2 s + (k/Rh )s + k/m (6.30) Moving to the Digital Domain To move from the continuous physical system to the discrete digital filter, we again use the bilinear transform from the s-plane to the z-plane, s←α 1 − z −1 1 + z −1 (6.31) taking α = 2/T , where T is the sampling interval, to obtain best frequency response at the low end of the frequency range. Band Limiting the Momentum Impulse Converting a continuous time system to the digital domain often involves excitation impulses, which are infinite bandwidth in the continuous domain. The internal force or velocity wave signals within the digital system, after a band-limited conversion using the bilinear transform will be inherently band limited since they will be coming from some other well-defined digital system. However, the impulse signal which drives the transient 173 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING portion of the system response had been defined in continuous time. ∆(s) (defined as the Laplace transform of the continuous impulse function) has infinite frequency bandwidth, but a digital impulse may only have bandwidth up to half the sampling rate, π/T , where T is the sampling interval. To make a proper conversion from the continuous time impulse to the discrete time impulse, we must first band limit the continuous time impulse to π/T and then sample it at T . δ(t) F −→ Band Limit ∆ ∆(jω) = ∞ δ(t)e−jωt dt ≡ 1, ∀ω −∞ ∆ −→ ∆T (jω) = F −1 ∆ −→ % δT (t) = = ∆(jω) = 1, 0, 1 2π % ∞ |ω| ≤ π/T |ω| > π/T iωt ∆T (jω)e −∞ 1 dω = 2π % π/T eiωt dω −π/T (6.32) sin πt/T ejπt/T − e−jπt/T = (1/T ) 2πjt πt/T ∆ = (1/T ) sinc t/T Sample −→ 1 δd (n) T where, ∆ δd (n) = 1, 0, n=0 (6.33) n "= 0 This result says that when we move the impulse function from continuous time to discrete time, we must scale it by the sampling rate. ∆(s) Band Limit −→ (1/T )∆(z) (6.34) This makes intuitive sense, since we would desire integration over a continuous impulse function to be equivalent to making a weighted rectangular sum over the digital impulse. % ∞ −∞ δa (t) dt = 1 = " ∞ ! $ δd (n) n=−∞ T T (6.35) 174 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING vh–(n) = vin(n) z−1 H(z) (Rh) vh+(n) = vout(n) G(z) v0δ(n) Figure 6.11: The Digital Wave-Decomposed Mass and Spring Filter The Second-Order Digital Transfer Function Picking up the argument from Equation 6.30, we must apply the bilinear transform and we must also band limit the continuous time impulse function mapping δ(t) → δ(n)/T . This leads to the correct second-order digital transfer function, Vout (z) = b0 + b1 z −1 + z −2 Vin (z) 1 + b1 z −1 + b0 z −2 (v0 /2αT )(1 + 2z −1 + z −2 ) + 1 + b1 z −1 + b0 z −2 (6.36) with the coefficients defined as ∆ b0 = ∆ b1 = mRh α2 − mkα + kRh , mRh α2 + mkα + kRh (6.37) 2(kRh − mRh α2 ) mRh α2 + mkα + kRh (6.38) Taking Advantage of the Arbitrary Reference Impedance Choosing the arbitrary reference impedance such that b0 = 0, Rh = mkα , mα2 + k a unit of delay may be factored out of the second-order transfer function. (6.39) The result is CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING m 175 v0 k(x) R0 Figure 6.12: String Loaded with Mass and Nonlinear Spring the efficient digital system shown in Figure 6.11 defined by Vout (z) = z −1 H(z)Vin (z) + G(z) v0 where H(z) = a0 + z −1 1 + a0 z −1 ! " a0 = k − mα2 k + mα2 1 G(z) = 2αT with a0 defined as 1 + 2z −1 + z −2 1 + a0 z −1 (6.40) (6.41) (6.42) (6.43) Combining Equations (6.39) and (6.43), we arrive at a simple relationship between Rh and a0 : Rh = 6.5.4 mα (1 + a0 ) 2 (6.44) Scattering Junction Connection The next step is to connect the mass and spring system to a string, as shown in Figure 6.12. Since we have decomposed the lumped mass and spring system into traveling waves, and have picked an associated wave impedance, Rh , we may join the system to the string system at a lossless 3–port scattering junction as shown in Figure 6.13. 176 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING vh− z−Μ vh+ v1+ v1− z−Μ v2− S v2+ z−Ν z−Ν Figure 6.13: Attaching the Wave Digital Hammer ∆ ∆ We define vout = vh + and vin = vh − , as is shown in Figure 6.11, so that traveling wave signals entering the scattering junction are superscripted with a plus sign, and traveling wave signals leaving the junction are superscripted with a minus sign. At the junction point where the mass and spring system connects to the string, the velocity of both sides of the string, v1 and v2 , and the driving point velocity of the spring, vh , must all equal vJ , the junction velocity. ∆ v1 = v2 = vh = vJ (6.45) In addition, the sum of the forces exerted by the string halves and the mass and spring at that point must be zero, since it is a massless point, ∆ f1 + f2 + fh = fJ = 0 (6.46) Combining the two series junction constraints given in (6.45) and (6.46) with the wave variable definitions and wave impedance relations, we can derive the lossless scattering equations for the interconnection of the wave decomposed mass and spring with the string halves: vJ = 2 (R0 v1 + + R0 v2 + + Rh vh + ) 2R0 + Rh (6.47) v1 − = vJ − v1 + (6.48) v2 − = vJ − v2 + (6.49) CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING vh − = vJ − vh + 177 (6.50) These equations indicate that, as a wave is coming into a junction, some portion of the wave reflects off the junction and travels back where it came from, while the rest of it travels into the junction and is divided among the other outgoing waves. The relative proportions of this scattering effect is dependent only on the relative wave impedances of the interconnected elements. Figure 6.14 shows how the mass and spring system may be attached to a membrane modeled using the 2-D digital waveguide mesh. Junctions marked J are lossless 4-port junctions. The mass and spring system is attached at the 5-port scattering junction marked S. Equations (6.47) through (6.50) must be modified appropriately to compute the 5-port junction. Note ”PNF”, or passive nonlinear filter components as described in the last chapter are attached at the edges of the 2-D mesh. This is a basic structure to model a gong with energy spreading through the modes using the 2-D mesh, the passive nonlinear filter and the wave-decomposed hammer models together. That felt hammer, or mallet, will sink into the membrane until it is thrown away by sufficiently strong returning force waves. 6.6 Making the Felt Nonlinear Now, to convert our string loaded with a mass and spring to a string being hit with a felt hammer, we must cope with the nonlinearity of the spring “constant”, k(xk ), which depends on the compression distance, xk , of the felt. Fortunately, we have signals in the mass spring loop which can give us this distance directly. In general, fk = kxk or xk = fk /k for a spring system. If we can find the force being applied to the spring, we may divide it by k to obtain the compression distance. But, the driving point force on the mass and spring system of Figure 6.9 is equal to the compression force on the spring alone. Hence, xk = (1/k)(fh − + fh + ) = (Rh /k)(vh − − vh + ). (6.51) (6.52) Rh /k in Equation (6.52) may be rewritten in terms of a0 by combining Equations (6.39) 178 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING A Piece of the Waveguide Gong PNF z-1 PNF z-1 z-1 z-1 z-1 z-1 J z-1 z-1 J z-1 v1+ z-1 z-1 J z-1 z-1 z-1 z-1 J z-1 z-1 v1– J vh– WDH + z-1 z-1 z-1 vh v3+ z-1 z-1 z-1 v4– S v2– J z-1 -1 v4+ z z-1 z-1 z-1 z-1 J z-1 z-1 z-1 z-1 z-1 z-1 z-1 v2+ v3– z-1 z-1 z-1 z-1 z-1 PNF z-1 z-1 J z-1 z-1 z-1 z-1 z-1 Figure 6.14: Attaching the Wave Digital Hammer to a 2-D Digital Waveguide Mesh 179 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING vh−(n) v1+(n) z–1 v1−(n) vh−(n−1) + S v2+(n) − vh+(n) v2−(n) H a0(n) u1(n) u2(n) u3(n) Rh(n) R a0(n) G vI(n) a0(n) X xk(n) a0(n) L u4(n) u5(n) K a0(n+1) z–1 a0(n) Figure 6.15: The Wave Digital Hammer and (6.43), to obtain xk = 1 − a0 (vh − − vh + ) 2α (6.53) With this final piece of the puzzle, we can complete the lossless wave digital (Fettweis, 1986) hammer system as shown in Figure 6.15. 6.6.1 The Lossless Digital Model Referring to Figure 6.15, the system loop containing S, H, and one unit of delay, z −1 , performs the essential mass and spring modeling. S is the scattering junction defined by Equations (6.47) through (6.50). H is the time–varying allpass filter defined by Equation (6.41). This loop oscillates at an instantaneous frequency of arccos(−a0 (n)) and models the second-order mass and spring system. Incidentally, if the computation of S is replaced with, vh − (n) = −vh + (n), (6.54) CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 180 which is physically equivalent to replacing the string or membrane portion of the system with a rigid wall, then the S—z −1 —H loop stands alone as an efficient, one-multiply sinusoidal oscillator. G is the modified integrator defined by Equation (6.42) which integrates the incoming initial hammer velocity impulse signal, vI (n), taking into account the wave decomposition and the nonlinear effects of the hammer felt. Signal u3 (n) is a combination of the velocity waves traveling in the hammer system which represents a normalized force of compression on the hammer felt. X computes the actual felt compression according to Equation (6.53), taking advantage of the fact that the force of compression on the felt is instantaneously proportional to the felt compression. K is a look–up table for the stiffness coefficient, a0 (n), indexed by felt compression, which may be defined by (6.43), replacing k with the compression dependent stiffness function, k(xk ). R computes the time–varying wave impedance of the hammer system from a0 according to Equation (6.44). Note that Rh (n) is zero when the hammer is not touching the string, that is when k(xk ) = 0, which means that there is no effect on the rest of the system when the hammer is not in contact with the string, although the motion of the hammer is still computed by the loop. As the hammer felt compresses, Rh (n) ramps up, representing the increased impedance of the compressed felt on the string. For the moment, assume L multiplies by 0, so that u4 (n) ≡ 0. This represents the full lossless hammer model. We will return to the definition of L after studying the effect of loss in the felt in the following section. 6.6.2 Hysteresis Loss in the Felt Hysteresis has been identified as an important factor in the piano tone (Boutillon, 1988; Stulov, 1995). Consider a model of the piano hammer where the felt is represented as a nonlinear spring in series with a nonlinear dashpot whose loss coefficient, µ, is dependent on felt compression, as shown in Figure 6.16. In the linear case we may say, f (t) = kx(t) + µv(t) (6.55) where f (t) is the force on the felt, x(t) is the felt compression, and v(t) = ẋ(t) is the velocity of compression. In the nonlinear case, we take the spring stiffness coefficient and CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 181 m x(t), v(t) k(x) µ(x) Figure 6.16: Nonlinear Spring and Dashpot the resistive loss coefficient for the dashpot both to be compression dependent giving us k(x) and µ(x). For times t near t0 , defining x(t0 ) = x0 and v(t0 ) = v0 , we may say that the force on the felt is, f (t) = k(x0 ) x(t) + µ(x0 ) v(t) D C µ(x0 ) v(t) x(t) = k(x0 ) + x(t) ≈ k̃(x0 , v0 ) x(t) (6.56) (6.57) (6.58) where we have defined the equivalent nonlinear spring as shown in Figure 6.17 to have a stiffness function which accounts for both the springiness and the loss in the felt model thus, ∆ k̃(x0 , v0 ) = lim k(x0 ) + t→t0 µ(x0 ) v(t) x(t) (6.59) Our first assumption must be that we can define a k̃(x0 , v0 ) at all. The fundamental nonlinear assumption is that both k(x) and µ(x) are zero when the hammer is not in contact with the string. Since we take t = 0 to be the time of initial contact, x(0) is zero, but v(0) may be anything. We therefore require µ(x0 )/x0 to be defined at x0 = 0. We have lim x0 →0 µ(x0 ) ∆ & = µ (0) x0 (6.60) Therefore, we require now that µ(x) be continuous at x0 and have a first derivative there. CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 182 m x(t), v(t) ∼ k(x,v) Figure 6.17: Equivalent Nonlinear Spring Now k̃(x0 , v0 ) is well defined, but it is still a function of both displacement and velocity, requiring a two-dimensional look-up table to implement. It would be convenient if we could find a way to compute it by consulting two one-dimensional tables in sequence, instead of indexing a true two-dimensional table. Let us assume that we could find k̃(x0 , v0 ) by adjusting the indexing of k(x0 ) according to some function of velocity, k̃(x0 , v0 ) = k(x0 + ε(x0 ) v0 ) (6.61) for some small–valued function, ε(x0 ). If this is possible, we can compute k̃ by adjusting x0 according to the ε table and velocity, and then index the k table. If ε(x0 ) v0 is small, we may approximate k(x0 + ε(x0 ) v0 ) by a truncated Taylor series expansion as k(x0 + ε(x0 ) v0 ) ≈ k(x0 ) + k& (x0 ) ε(x0 ) v0 (6.62) Plugging (6.59) into the left hand side of Equation (6.61) and (6.62) into the right hand side, we can solve for ε(x0 ): ε(x0 ) ≈ µ(x0 ) x0 k& (x0 ) (6.63) Fortunately, ε is a function of x0 alone. Therefore, the ε table may be designed as a one-dimensional table indexed by x0 . However, its definition leaves it undefined at CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 183 x0 = 0. By applying l’Hôpital’s rule repeatedly, we may obtain an appropriate definition of ε(0) as long as higher-order derivatives of µ do not become non-zero before higher-order derivatives of k at x0 = 0: µ(x0 ) x0 →0 x0 k & (x0 ) µ& (x0 ) = lim x0 →0 x0 k && (x0 ) + k & (x0 ) µ&& (x0 ) = lim x0 →0 x0 k &&& (x0 ) + 2k && (x0 ) .. . µ(n) (x0 ) = lim x0 →0 x0 k (n+1) (x0 ) + nk (n) (x0 ) ∆ ε(0) = lim (6.64) We can only model nonlinear mass/spring/dashpot systems as nonlinear mass/spring systems when the dashpot resistance function, µ(x), is continuous at x = 0 and is at least as smooth as the stiffness function, k(x), at x = 0. Referring back to the digital implementation shown in Figure 6.15, L is intended to compute ε(x0 )v0 , the small offset of the indexing signal xk (n). The modified indexing signal is then input to the felt stiffness table K. L should generally be of the form, u5 (n) = ε(xk (n))[xk (n) − xk (n − 1)]/T (6.65) where (xk (n)−xk (n−1))/T approximates the velocity of felt compression. We have derived the mathematical justification for this offset, along with its basic limitations. However, we may understand this offset to the stiffness table index as a direct implementation of felt hysteresis by realizing that a resistive loss in the felt will cause the felt to feel stiffer when being compressed and to feel less stiff when decompressing. The springiness of the felt is proportional to the felt compression, whereas the effect of loss is in the direction of felt compression velocity. Therefore, (6.65) offsets the index to the stiffness look-up table, K, such that, when the felt is compressing, the spring “constant” is greater, and when the felt is relaxing, the spring “constant” is smaller. ε(xk ) should be zero when the hammer is not in contact with the string and should ramp up smoothly from zero as defined in (6.63). 184 CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 20 18 16 Hammer Force (N) 14 12 10 8 6 4 2 0 0 0.5 1 1.5 2 Time from Impact (ms) 2.5 3 Figure 6.18: Calculated Forces on Hammer Felt for v0 = 1,2,3, and 4 m/s 6.7 Empirical Evaluation with Published Data We have been able to produce a variety of realistic struck string and struck membrane sounds using the wave digital hammer algorithm in combination with the digital waveguide string model and the 2-D digital waveguide mesh membrane model. While the hammer model easily proves its usefulness in the area of efficient sound synthesis, we also believe that, after some further development, it will compute physically correct, analytically useful interaction transients between hammers and strings. For the moment, we can compare our traveling wave model of hammer and string with the difference equation model proposed by Chaigne and Askenfelt. We tested our model computing the filter parameters using data provided in (Chaigne and Askenfelt, 1994a; Chaigne and Askenfelt, 1994b) for a hammer hitting a middle C piano string. CHAPTER 6. THE WAVE-DECOMPOSED MASS-SPRING 185 Figure 6.18 shows the hammer force response curves, computed at an audio sampling rate of 1/T = 44100 samples per second, given initial hammer strike velocities of v0 = 1, 2, 3, and 4 m/sec. Note the multiple force peaks which are caused by hammer interaction with return waves from the agraffe. In this case, we used the lossless version of our model and ignored felt hysteresis; in addition, we did not account for loss and stiffness in the string itself; further, we let the hammer interaction be localized at one point, rather than use a weighting function to spread the force interaction over a finite area. In these respects, we differ from Chaigne and Askenfelt. Nevertheless, despite these variations, our results are qualitatively similar, and fairly close in magnitude. Our model generated slightly lower hammer forces and slightly longer interaction times. Further work will include the careful measurement of piano hammer and string data, and the calibration of our models to the full extent permitted within the digital waveguide approach. In addition, we plan to develop physically correct calibrated 2-D waveguide mesh drum and mallet models. Chapter 7 The Commutable Piano Hammer Much effort has been undertaken in the automated but musical performance of acoustic piano (Risset and Van Duyne, 1996; Risset and Van Duyne, 1992), and in the development of new microtonal keyboards (Van Duyne, 1990) supporting up 72 notes per octave (Maneri and Van Duyne, 1986). In addition, work has been done on modeling the haptic interface (Gillespie, 1996). We present here several developments for piano synthesis using digital waveguides and a commuted body response. The musical use of commuted body response filter structures appears to have been first published independently in (Karjalainen et al., 1993) and (Smith, 1993). The basic commuted synthesis for piano approach is described in (Smith and Van Duyne, 1995) and (Van Duyne and Smith, 1998). Work presented in this chapter was originally published in (Van Duyne and Smith, 1995b). 7.1 Background The piano and its parts have long been a topic of study, with an eye toward better understanding of the acoustics (Weinreich, 1977), toward more reliable numerical modeling of the piano physics (Chaigne and Askenfelt, 1994a; Chaigne and Askenfelt, 1994b) and understanding the piano hammer (Boutillon, 1988; Zhu and Mote, 1994; Stulov, 1995; Suzuki, 1987; Hall, 1986; Hall, 1987a; Hall, 1987b; Hall, 1987c; Hall, 1988; Hall, 1992), toward the development of high-quality sound synthesis (Van Duyne et al., 1994; Van Duyne and Smith, 1993b), and toward the development of cost-effective sound synthesis (Karjalainen et al., 1993; Smith, 1993; Smith and Van Duyne, 1995; Van Duyne and Smith, 1992; Van Duyne and Smith, 1994). Our interest in this chapter is in the category of sound 186 CHAPTER 7. THE COMMUTABLE PIANO HAMMER 187 synthesis informed by physics and acoustics. A high-quality physical approach to piano synthesis can be cobbled together with gadgetry already described herein combining the wave digital hammer (Van Duyne et al., 1994) described in the last chapter with coupled string synthesis (Smith, 1993; Smith and Van Duyne, 1995) discussed in Chapter 2, using the 2-D digital waveguide mesh (Van Duyne and Smith, 1993b) described in Chapters 3 and 4 as a soundboard resonator, and using allpass filtering methods to stiffen the soundboard and the piano strings (Van Duyne and Smith, 1994) as discussed in Chapter 3. See Figure 7.1 for a high-level diagram of this proposed model, topped off with a haptic interface modeling the physical forces in the piano action (Gillespie, 1996). On the other hand, we have proposed an algorithmic method of synthesizing the inharmonic piano tones constructing spectral regions with specially tuned FM oscillator pairs (Van Duyne and Smith, 1992). The basis of this chapter is a hybrid method known as commuted piano synthesis (Smith, 1993; Smith and Van Duyne, 1995) which combines the high quality and control of physical modeling synthesis with the compute-effectiveness of sampling “synthesis”. This method takes advantage of the commutativity of linear systems, and replaces the high-order soundboard resonator with its own sampled impulse response played into the string at its excitation point. In order to implement Commuted Synthesis, we must linearize the hammer-string interaction, which is the focus of the first part of this paper. We have further hybridized and simplified the commuted piano synthesis method by replacing the sampled soundboard impulse response with a simple algorithmic synthesis method which idealizes the soundboard and makes its physical characteristics easier to control. Lastly, we offer a method to calibrate the coupled piano string algorithm to real physical data using only a simple recording of a hammer hitting one string. 7.2 Linearizing the Piano Hammer A fully physical nonlinear model of the hammer-string system has been presented already (Van Duyne et al., 1994) in Chapter 6. However, in order to implement commuted piano synthesis (Smith and Van Duyne, 1995), we must commute the resonant soundboard system through the hammer system to the point of excitation in the commuted piano model. This requires that we replace the entire hammer-string interaction with a linear filter. Rather inconveniently, the hammer-string interaction is highly nonlinear in two CHAPTER 7. THE COMMUTABLE PIANO HAMMER Figure 7.1: The Elaborate Physically Modeled Piano 188 189 CHAPTER 7. THE COMMUTABLE PIANO HAMMER V (R0) (R0) FS Figure 7.2: String Terminated on One Side Only important respects: First, the felt itself is nonlinear in that it gets stiffer the more it is compressed (Chaigne and Askenfelt, 1994a). Second, the hammer leaves the string at some point, which corresponds to a shift in the models from a string interacting with a hammer to a string vibrating freely. A “linearized” analysis of the piano hammer-string system follows. 7.2.1 Impedance of the Un-Terminated Ideal String The impedance experienced at some point on an un-terminated string is purely resistive: ∆ RS = FS /V = 2R0 , (7.1) where FS and V are the Laplace transforms of force and velocity at the driving point and R0 is the wave impedance of the string, which is dependent on the square root of string tension times string density. The 2R0 in the above equation results from taking into account the impedance of both halves of the string, as seen at the driving point. 7.2.2 Impedance of the Terminated Ideal String In the case of the piano hammer-string interaction, waves from the agraffe return and interact with the hammer before it leaves the string for most notes. However, the return waves from the bridge end of the string do not make it back before the hammer leaves the string, except in the very highest notes. Therefore, we formulate a half-terminated string impedance taking into account a one-sided termination at the agraffe end, as shown in Figure 7.2. The velocity response of a force impulse at the strike position is an impulse followed by an inverted impulse which returns reflected off the essentially rigid agraffe end 190 CHAPTER 7. THE COMMUTABLE PIANO HAMMER RH v0 m k V FH Figure 7.3: The Linear Mass-Spring Hammer Model of the string T seconds later: V = 7.2.3 FS , 1 − e−sT 2R0 =⇒ ∆ RS = 2R0 FS = V 1 − e−sT (7.2) Impedance of the Ideal Linear Hammer Let us assume that the hammer is of the form shown in Figure 7.3, essentially a mass and spring system, where the spring represents the felt portion of the hammer. We find that the impedance relation is: ! FH = RH V − v0 s " ∆ where RH = s2 ks + k/m (7.3) and where v0 /s represents the step input of the initial striking velocity. RH has a zero at DC and two conjugate poles indicating an oscillation frequency of 7.2.4 # k/m. Connecting the Hammer to the String When the hammer is in contact with the string, we take the velocity of the string equal to the velocity of the spring end of the hammer, and the force on the string equal and opposite to the force on the spring, FS = −FH . Plugging in the string impedance relation, 191 CHAPTER 7. THE COMMUTABLE PIANO HAMMER V = FS /RS , we find: ! ∆ FS = −FH = −RH V − =⇒ FS = ! v0 s RH RS RH + RS " " = −RH ! FS v0 − RS s " (7.4) E -v v0 ∆ , E 0 = RH ERS s s (7.5) In the un-terminated string case, we define H∞ as the transfer function from the initial striking velocity step to the force experienced by the string (and, equivalently, by the hammer felt). Taking the hammer to be a simple mass-spring system, we find that the H∞ transfer function is now a damped second-order system, which looks just like the RH except for the under-bracketed damping term (7.6). For practical physical parameters, this is an over-damped system with real poles. E E ∆ H∞ = RH ERS = ! "E ks ks E E 2R0 = k 2 s2 + k/m s + 2Rk 0 s + m (7.6) F GH I For the one side terminated string case, we define HT . Again, we find HT is like RH but for the under-bracketed damping term, which in this case contains an interesting time delay part. ∆ E E HT = RH ERS = 7.2.5 ! "E! " ks 2R0 E = E s2 + k/m 1 − e−sT s2 + Implementation ks k 2R0 F , - k 1 − e−sT s + m GH (7.7) I Conveniently, we find a recursion relationship between H∞ and HT , which is independent of the exact nature of the hammer impedance, RH . HT = H∞ 1 − e−sT H∞ (7.8) This allows a simple recursive hammer filter implementation of the form in Figure 7.4. Since, in this case, the hammer never leaves the string (from the linear system assumption), we may prefer to include a cutoff envelope in the feedback loop to terminate the reflections from the agraffe at some point, or better, break out the first few reflections in a feed-forward formulation as in Figure 7.5. 192 CHAPTER 7. THE COMMUTABLE PIANO HAMMER v0 s + FS H∞ Delay Figure 7.4: Step-Driven Recursive Hammer Filter v0 s H∞ + H∞ Delay Delay FS H∞ Figure 7.5: Feed-Forward Hammer Filter Noting that H∞ is a differentiated lowpass filter, H∞ = ks s2 + ∆ k 2R0 s + k m = sLp , (7.9) the step-driven hammer system of Figure 7.4 may be commuted to an impulse-driven system, as preferred for Commuted Piano Synthesis (Smith and Van Duyne, 1995). This is shown in Figure 7.6. In this formulation, the hammer feedback loop contains what is fundamentally a lowpass filter and a DC-blocker. It is easy to break this out into a feed-forward form as in Figure 7.5. v0δ + Lp s FS Delay Figure 7.6: Impulse-Driven Recursive Hammer Filter CHAPTER 7. THE COMMUTABLE PIANO HAMMER 7.3 193 Analysis of Real Hammer-String Interaction Data Using the Wave Digital Hammer (Van Duyne et al., 1994) parameterized with measured data provided by (Chaigne and Askenfelt, 1994a; Chaigne and Askenfelt, 1994b), we were able to compute the forces experienced by terminated and un-terminated middle-C (261 Hz) strings during a hard hammer strike. In the upper left plot of Figure 7.7, we see the felt compression force curves for a hammer hitting an un-terminated middle-C string (dashed line) and a terminated middle-C string (solid line). The multiple pulses correspond to return waves from the agraffe interacting with the hammer while it is still in contact with the string. Note that in the un-terminated string case, the force curve ramps smoothly to zero and the hammer apparently comes to rest on the string as in an over-damped secondorder system. However, in the terminated string case, the hammer leaves the string when the return waves finally throw it away. The upper right plot of Figure 7.7 shows the dB magnitude spectra of these force curves. Note that the overall bandwidth of both the terminated string and un-terminated string hammer shock spectra are about the same. The multi-pulse spectrum (solid line) differs from the single-pulse spectrum (dashed line) primarily in a slight ringing of the lower spectrum region. The lower right plot is the dB magnitude of the complex ratio of the multi-pulse spectrum and the single-pulse spectrum. The several low-frequency peaks correspond to the spectral peaks one would expect from the hammer staying in contact with the string at the strike point (about 1/8 the way along the string) for some finite duration. It is of some interest that keeping the hammer in contact with the string introduces spectral peaks about every eight harmonics, whereas an impulsive strike at the same position on the string introduces spectral nulls every eight harmonics. The piano hammer interaction is a compromise between these two extremes of behavior. We further note that there are odd looking wiggles in the ratio spectrum, clearly visible around the 5–10 kHz range. These correspond in width to the side lobes one would expect from rectangularly windowing the time domain signal at exactly the point where the hammer leaves the terminated string. Hence, the severe nonlinear effect of the hammer leaving the string (which changes the entire linear system model) turns out in the spectral domain to be a simple convolution by the appropriate rectangular windowed sinc function. The lower left plot in Figure 7.7 shows the inverse transform of the ratio spectrum. This is what is left of the multi-pulse hammer force signal if we de-convolve the single pulse 194 CHAPTER 7. THE COMMUTABLE PIANO HAMMER HAMMER FORCES FORCE SPECTRA 0 -50 0.4 dB amp 0.6 0.2 0 0 -100 -150 1 2 3 -200 0 ms DECONVOLUTION 5 kHz RATIO SPECTRUM 10 5 kHz 10 40 20 dB amp 0.4 0.2 -20 0 0 0 1 2 ms 3 -40 0 Figure 7.7: Middle-C (261 Hz) Struck Hard: Force Signals Computed Using the WDH Parameterized with Physical Data Taken from (Chaigne and Askenfelt, 1994b) 195 CHAPTER 7. THE COMMUTABLE PIANO HAMMER Lowpass Filter (4th Order) v0 δ EQ Filter (6th Order) F Figure 7.8: Spectral EQ Method of Modeling the Hammer Filter ms MULTI-PULSE RESULT kHz RATIO SPECTRUM FIT 20 10 0.4 dB amp 0.6 0.2 0 0 0 -10 1 2 3 -20 0 ms 5 kHz 10 Figure 7.9: Sixth-Order Filter Fit to Ratio Spectrum force signal out of it. It appears to be a recursively damped impulse train, with some DC blocking, eventually centering the signal around zero. This is what was predicted by the linear hammer analysis as shown in Figure 7.6. 7.4 Spectral Modeling Approach to the Multi-Pulse Effect An alternative approach to hammer filter design is to model the complex ratio spectrum as shown in the lower right plot of Figure 7.7 directly as a low-order filter. This reduces the recursive or feed-forward filter design methods of modeling multiple force pulses to a simple spectral equalization filter, as shown in Figure 7.8. In this case, we used a fourth-order fit for the single-pulse hammer lowpass filter. We then made a sixth-order equalization filter fit to a few of the significant low-frequency features of the ratio spectrum. The right hand plot of Figure 7.9 shows the equalization filter fit. The left-hand plot shows the time domain output of the hammer filter system shown in Figure 7.8. The thick dotted lines are actual data as generated by the Wave CHAPTER 7. THE COMMUTABLE PIANO HAMMER 196 Digital Hammer and the solid lines are the result of the filter fits. Note that the phase information in the sixth-order ratio spectrum fit results in a very good time domain approximation. In general, the coefficients of the lowpass filter part of this structure will be highly dependent on strike velocity, the harder the strike, the wider the bandwidth. However, the equalization part of this structure is reasonably consistent over strike velocity, and, in the simplified model, may be held constant over strike velocity, although it will vary with piano key number. 7.5 Excitation Synthesis with Nonlinearly Filtered Noise The impulse response of the piano soundboard is fundamentally a superposition of many exponentially decaying sinusoids, at least in its linear approximation. The reverberant effect of the soundboard occurs as energy from the struck piano strings is coupled into these modes and reverberated. However, if there were some particular modes of the soundboard which were unusually prominent, exhibiting a clear peak in the impulse response spectrum, and having an unusually long decay time, then a string which contained this frequency in one of its partials would couple into this mode more significantly than a string which did not have that frequency among its partials. This could produce unwanted unevenness in the piano tone from note to note. In general, much effort has been applied to the design of real piano soundboards to avoid such situations as these. The idealized piano soundboard should have a smooth, or flat spectral response locally, although it is evident that higher frequency modes decay a little faster than low-frequency modes (Wogram, 1980; Suzuki, 1986; Nakamura, 1983). It is difficult to design a resonant system with such a flat response without using a very high-order filter, for example the 2-D Digital Waveguide Mesh (Van Duyne and Smith, 1993b) described in Chapters 3 and 4. A finite element approach is described in (Kindel and Wang, 1987). On the other hand, it is easy to model the impulse response of such a system as exponentially decaying white noise, with the possible extension of a timevarying lowpass filter applied to model high-frequency modes decaying more quickly than low-frequency modes. Using such a nonlinearly filtered noise model, we may synthesize any number of reverberant systems which have the characteristic that they have more or less smooth responses over the frequency spectrum, with no particular peaks of importance. The piano soundboard is a system of this kind. 197 CHAPTER 7. THE COMMUTABLE PIANO HAMMER NOISE brightness control TIME VARYING FILTER gain control ENV1 ENV2 Figure 7.10: Synthesis of Soundboard Tap with Nonlinearly Filtered Noise NOISE x(n) 1-POLE LOWPASS FILTER WITH TIME VARYING COEFFICIENT y(n) a(n) ENV y(n) = [1+a(n)]x(n) - a(n) y(n-1), where a(n) ramps from 0 to -1 EXCITATION SIGNAL Figure 7.11: 1-Pole Soundboard Resonance Implementation Synthesized Highpass Portion of Soundboard Response + Low band excitation pulse for low mode resonator Hammer Filter String Model Low Mode Soundboard Resonator Figure 7.12: Noise-Plus-Resonator Soundboard Synthesis 198 CHAPTER 7. THE COMMUTABLE PIANO HAMMER RECORDED SOUNDBOARD TAP SPECTRUM 50 dB 0 -50 -100 0 2000 4000 6000 8000 10000 600 800 1000 Hz 40 dB 20 0 -20 -40 0 200 400 Hz Figure 7.13: dB Frequency Response of a Recorded Piano Soundboard Tap (above) and a Close-Up of the Lower Frequencies (below) 199 CHAPTER 7. THE COMMUTABLE PIANO HAMMER SYNTHESIZED SOUNDBOARD TAP SPECTRUM 40 dB 20 0 -20 -40 0 2000 4000 6000 8000 10000 600 800 1000 Hz 40 dB 30 20 10 0 -10 0 200 400 Hz Figure 7.14: Synthetic Soundboard Tap Using a Swept 1-Pole and Noise CHAPTER 7. THE COMMUTABLE PIANO HAMMER 200 NOISE TIME VARYING FILTERING (T60 ≈ 15 sec.) TIME VARYING FILTERING (T60 ≈ 1/3 sec.) + Synthesized Wet Soundboard Response Figure 7.15: “Pedal-Down” Synthesis of Dry Soundboard Tap Plus “Wet” Open Strings Tap In Figure 7.10 we show such a soundboard impulse response synthesis system. White noise is being fed into a time-varying lowpass filter whose gain and bandwidth are both being controlled by envelopes. One possible implementation of this would use a one-pole lowpass filter whose denominator coefficient is being swept toward −1, thereby shrinking the bandwidth. If the numerator coefficient is modified to keep gain at DC constant, the amplitude envelope might even be dispensed with in a simplified system as shown in Figure 7.11. Alternatively, more elaborate noise filtering systems may be developed, possibly breaking the noise into frequency bands which could be treated independently to model to some particular impulse response. Figure 7.12 shows such an example. Figures 7.13 and 7.14 compare the dB frequency response of a real measured piano soundboard tap and a synthesized soundboard tap based on the algorithm in Figure 7.11. 7.5.1 Synthesizing Sustain Pedal Effect One of the signature sound effects of piano performance is carefully articulated use of the sustain pedal, i.e. raising and lowering the string dampers. A full set of pen strings coupled into the soundboard obviously increases the resonator complexity. However, just as the dry soundboard impulse response may be commuted to the point of excitation, similarly we may commute the entire sampled impulse response of the soundboard plus open strings with dampers raised to the point of excitation to obtain the resonant effect of the sustain pedal. Further, since there are so many resonating partials, the spectral CHAPTER 7. THE COMMUTABLE PIANO HAMMER 201 response is essentially flat and filtered white noise with a long slow decay rate makes a good synthetic approximation. Figure 7.15 Shows a simple implementation taking the dry soundboard tap to have a T60 decay time of 1/3 second, and taking the decay time of the open strings to be approximately 15 seconds. Other Applications The piano excitation model described above, comprising the linear hammer filter in conjunction with the dry and wet soundboard synthesis methods, makes a very efficient way to enhance other percussive instrument models ranging from simple modal synthesis, modal stochastic event modeling (Cook, 1996) or the coupled mode synthesis (Chapter 6), to the waveguide mesh models in Chapters 3 and 4. Numerous examples were demonstrated live at (Porcaro et al., 1996). 7.6 Wrap Up We have wandered through the wave equations, difference representations and multidimensional waveguide mesh representations, applications of traveling wave decomposition of lumped impedances, nonlinearities and coupled systems. This last chapter investigated some simplified approaches to piano sound synthesis. The Appendices will outline several synthesis techniques tangentially related to and extending the work presented in the main body of this thesis. Much of this work has been published already in separate conference proceedings and journal articles in the 1990s; follow-on work is addressed only lightly herein. It is my hope that the presentation of the material in this form may be helpful to readers just entering the field to give them a flavor of the tools, techniques, and potential applications. Appendix A Pick-Up Point Modulation A.1 Implementation of a Variable Pick-Up Point on a Waveguide String Model with FM/AM Applications The waveguide string model can be extended through the addition of a movable pick-up point along the string. As the pick-up slides along the string, a flanging effect results. Accelerating the pick-up produces glissandi effects. Modulating the placement of the pick-up sinusoidally at audio rates produces modified FM sidebands around each partial on the string, with control over the presence of even and odd sidebands. This non-physical effect can be used to enrich the timbre of physical models, taking advantage of the wellunderstood theory of FM synthesis. This research was first published in (Van Duyne and Smith, 1992). A.2 Background and Description of the Model The bi-directional traveling displacement waves on an ideal string can be represented by a waveguide synthesis model. The actual displacement of the string at any point is determined by adding the displacements associated with the left- and right-going traveling waves in the bi-directional delay lines. The ideal reflection of the traveling waves at each end of the string, is modeled by multiplying the incoming wave by −1 and sending it through in the other direction. Figure A.1 illustrates the ideal string model. In order to listen to the vibrations on this string, a pick-up must be placed at some point on the string. Placement of a pick-up precisely on a sample point in the delay lines 202 203 APPENDIX A. PICK-UP POINT MODULATION y+(n) −1 −1 y−(n) 0 xp 1 y(n) Figure A.1: Terminated String and Pick-up Placement Model is straightforward. For our purposes, we would like to place a pick-up at any continuous point along the string. This necessitates an interpolation of some kind. If the pick-up is placed exactly at a sample point, the values of the upper and lower delay lines at that point are simply added. If the pick-up is to be placed at a fractional distance, α, between two sample points, then a weighted average of the two adjacent sample values must be performed. In these preliminary inquiries, linear interpolation is used. The results are excellent, but there is room for a better interpolation method in extreme cases of pickup point motion. Figure A.2 shows a close-up of the implementation of an interpolated pick-up point. A.3 Moving the Pick-Up Point Acoustically, the position of a pick-up on a string determines the relative magnitudes of the partials heard. If it is placed at one of the end points, no sound will be present as the end points do not move. If the pick-up is placed in the exact center of the string, only odd harmonics will be present in the spectrum as all even harmonics will have a node at that point. In general, placing the pick-up at a position 1/k across the string will zero out partials whose number is a multiple of k, and reduce levels of near multiples of k. The 204 APPENDIX A. PICK-UP POINT MODULATION ... -1 -1 Z -1 Z Z ... 1−α α y+(n) y(n) y-(n) 1−α α ... -1 Z -1 Z -1 Z ... Figure A.2: Close-up of the Interpolated Position of the Pick-up placement of a pick-up is therefore essentially a comb filter. Sliding the pick-up along the string slowly creates a flanging effect as the nodes of the various harmonics are crossed. Figure A.3 shows a sonograph view of the spectrum of the audio signal output from a sliding pick-up point. In this picture, the time axis is horizontal, and the frequency axis is vertical. The magnitude is indicated by relative lightness and darkness. Here, the pick-up slides across the length of the string at constant speed over the duration of the sound. The amplitude evolution of the first twelve harmonics on the string is shown in this sonograph view. When we slide the pick-up along the string, we are, in effect, catching up with one of the waves and losing ground with the other. This results in a separation of their frequencies through frequency modulation. Alternatively, one can view sliding the pickup point across the string as an amplitude modulation of each harmonic on the string at a frequency equal to half the harmonic number times the number of string lengths per second that the pick-up is moving. Figure A.4 shows a sonograph of a pick-up making discontinuous speed increases. Notice that the higher harmonics spread more than the lower in this linear frequency plot. This phenomenon is short-lived, however, if we are APPENDIX A. PICK-UP POINT MODULATION Figure A.3: Slow Continuous Pick-up Point Motion Over the String Length 205 APPENDIX A. PICK-UP POINT MODULATION Figure A.4: Fast Discontinuous Pick-up Point Speeds 206 APPENDIX A. PICK-UP POINT MODULATION 207 bounded by the string end points. It is convenient to contrive a theoretical placement of the pick-up point beyond the ends of the string by extrapolation of the standing wave on the string. To generalize pick-up point motion we must define what it means to place the pick-up somewhere off the end of the actual string, that is, to extend the string in some way without discontinuity of the traveling waves in the delay lines. We do this by reading the separate upper and lower traveling waves back through the end point filters (here perfect reflections) and around backwards on the other delay line. To read at a pick-up located theoretically at some 1 + δ, where the string length is 1, and δ is a positive number less than 1, we have the upper displacement, y + (1 + δ) = −y − (1 − δ) and the lower displacement, y − (1 + δ) = −y + (1 − δ). Therefore the composite displacement of the string, y, at pick-up point, 1 + δ, is as follows: y(1 + δ) = y + (1 + δ) + y − (1 + δ) (A.1) = −y − (1 − δ) − y + (1 − δ) (A.2) = −y(1 − δ) (A.3) In other words, to obtain a hypothetical displacement beyond the end of the string, just flip the sign and read backwards along the string. Now that we can maintain a continuous motion of the pick-up in one direction indefinitely, we may introduce the notion of acceleration as well as speed of the pick-up point along the string. Figure A.5 shows a string loaded with two harmonics at I kHz and 5 kHz with an accelerating pick-up point to produce expanding glissandi. In this four-second example, the pick-up point speed accelerates from 0 to 1000 string lengths per second. Since a string length is half the wavelength of the string fundamental, the downward gliding frequencies make it half the way to DC. Note there are also some aliasing sidebands in the picture relating to the error of linear interpolation. In the four seconds of sound depicted in Figure A.6, the pick-up point position is being modulated sinusoidally at a rate of 5 Hz, but its deviation from center is 10 string lengths. Where the double vibratos are at their furthest separation is when the pick-up point is flying past its center point of modulation at its greatest speed. Notice that the double vibratos in the upper harmonics cross over each other. APPENDIX A. PICK-UP POINT MODULATION Figure A.5: Effect of Accelerating Pick-up Point Position 208 APPENDIX A. PICK-UP POINT MODULATION Figure A.6: Sinusoidally Oscillating Pick-up Point Position 209 210 APPENDIX A. PICK-UP POINT MODULATION A.4 Modulating the Pick-Up Position at Audio Rates The next logical step is to modulate the pick-up point at audio rates. This results in a hybrid synthesis method akin to amplitude modulation (Dodge and Jerse, 1985) and/or frequency modulation (Chowning, 1973; Chowning and Bristow, 1987). We define the pick-up point modulation as follows: ∆ xp (t) = xp0 + d sin ωxp t, (A.4) where xp (t) is the resultant pick-up point placement measured in string lengths, xp0 is the center point of modulation, d is the deviation measured in string lengths, and ωxp is the frequency of the pick-up point modulation in radians. An excellent presentation of how standard FM math works can be found in (Schottstaedt, 1992). With some follow on analysis, a closed form expression for the resultant spectrum heard from this modulating pick-up can be found as follows: y(t) = $ yk (t), where (A.5) kεH yk (t) = Ak J0 (Ik ) sin φk cos ωk t + + ∞ $ i=odd ∞ $ (A.6) Ak Ji (Ik ) cos φk (sin (ωk + iωxp )t + sin ωk = iωxp t) Ak Ji (Ik ) sin φk (cos (ωk + iωxp )t + cos ωk = iωxp t), (A.7) (A.8) i=even (A.9) where k is the harmonic number, H is the set of harmonics on the string, yk is the ∆ contribution to the total spectrum resulting from the kth harmonic, Ik = πkd is the ∆ modulation index, φk = πkxp0 is the phase offset determined by the position of the modulation center point, ωk is the frequency of the kth harmonic in radians, and ωxp is the radian frequency of the pick-up point placement modulation. This expression indicates that around each of the harmonics on the string, ωk , sidebands are produced at plus and minus multiples of the pick-up modulation frequency, ωxp , and that their magnitudes are dependent on Bessel functions of the first kind operating on an index based on d, the deviation of pick-up point modulation. These equations differ from ordinary FM, however, in that the odd sidebands are scaled by cos φk and the even APPENDIX A. PICK-UP POINT MODULATION 211 Figure A.7: Effects of Constant Speed Plus Modulation Modulating on Pick-up Position sidebands are scaled by sin φk , where φk is, in effect, the relative position of the pick-up point modulation center point measured along the standing wave components of each of the harmonics on the string. When xp0 is at a harmonic node, that is at a position n/k on the string where n is an integer and k is the harmonic number, then sin φk evaluates to zero and the even harmonics are zeroed out. On the other hand, when xp0 is at an anti-node of a harmonic, that is, at a position (n + .5)/k along the string, cosφk evaluates to zero and the odd harmonics are zeroed out. Sliding the center point between a node and an anti-node produces a gradual exchange of energy from the even sidebands to the odd sidebands. Figure A.7 illustrates a four-second sound created by sliding the center point of pickup modulation from one end of the string to the other over the duration of the tone. The fundamental frequency of the string is 1000 Hz. Four harmonics were loaded onto the string, at start up. The modulation frequency was 100 Hz and the deviation was 0.1 string lengths. There are more side bands around the upper harmonics due to the greater effect of the deviation distance on the shorter wavelengths. Observe how the odd and even sidebands fade in and out as the center point of pick-up modulation glides over the nodes APPENDIX A. PICK-UP POINT MODULATION 212 Figure A.8: Effects of Accelerating Pick-up Position with Modulation and anti-nodes of the various harmonics. Figure A.8 shows how speed and modulation can be combined. Here the first and fifth harmonics are loaded onto a 1000 Hz string at start-up time. The center point of modulation accelerates across the string from a speed of 200 string lengths per second up to 500 string lengths per second. Meanwhile, with a modulation frequency of 200 Hz, the deviation ramps from 0 to 1 string lengths back down to 0 over the course of the sound. Note that we lose the nice feature of individual control of odd and even sidebands when using speed or acceleration in combination with modulation. A.5 Conclusion While it is true that the results in the simple case of the ideal string with perfect reflections at the end points could be duplicated with traditional FM means, nonetheless, the interesting synthesis area that this opens up is combining FM and physical modeling techniques. There are many possibilities when a low pass or other system filter is placed at the APPENDIX A. PICK-UP POINT MODULATION 213 end of the string instead of the perfect reflection. Waveguide models can be enriched by a modulating pick-up point, while on the other hand, traditional FM instruments can be rejuvenated by the loop filtering methods of physical modeling and waveguide synthesis. Appendix B Pitchbendable Allpass Interpolation An efficient method for signal controllable fractional delay implementation is described here. It combines the flexible control of linear interpolation with frequency independent losslessness of allpass interpolation, avoiding the undesirable effects of each method. These results were first published in (Van Duyne et al., 1997) and (Van Duyne et al., 1998). B.1 The Problem Statement The development of high quality well calibrated physical modeling synthesis algorithms based on Karplus-Strong-style feedback loops requires the use of non-integer length delay lines. These delay lines, ideally, should have two important features: (1) Their lengths must be smoothly and fractionally variable by some control signal in order to implement glissando and vibrato effects; (2) they must be lossless at all frequencies to minimize unwanted decay in physical modeling feedback loop structures. Linear interpolation can be easily calculated and varied smoothly, however the energy losses in the FIR structures are unsatisfactory, especially in high notes where they introduce unwanted and uncontrollable loop loss. On the other hand, allpass interpolation is lossless, but it is hard to interpolate the delay line length when the allpass filter coefficient gets out of range, and the sample length of the delay line needs to be changed. There is a discontinuity, or click, introduced into the loop. Some steps toward click-elimination are taken in (Välimäki et al., 1995) 214 APPENDIX B. PITCHBENDABLE ALLPASS INTERPOLATION 215 By combining work done in legato crossfading (Jaffe and Smith, 1995), allpass coefficient analysis (Välimäki et al., 1995), and taking note of some basic psychoacoustic research in just noticeable differences in pitch (Olson, 1967), we find a solution to the problem. B.2 Puzzle Pieces Implementation of linear interpolation using FIR filters and allpass interpolation was described in Chapter 2. We note here, that for a fractional delay of d samples, the corresponding first order allpass coefficient, ad , is approximated by the expression, ad ≈ (1 − d)/(1 − d) (B.1) So, if an output, y(n), is desired from a fractional point d fractional samples between samples x(n − 1) and x(n), the output signal can be written: y(n) = ad x(n) + x(n − 1) − ad y(n − 1) B.2.1 (B.2) Minimizing the Transient Effect The discontinuity resulting from changing the coefficient, a0 , can be minimized by keeping the coefficient value as close to zero as possible. The transient effect of changing the coefficient rings out at a rate proportional to the series: a, a2 , a3 , . . . We note that if the fraction delay, d, is kept within the unit range, 0.618 to 1.618, then the corresponding allpass coefficient, ad remains between −0.236 and +0.236. This means that, with d in this range, the transient effect of a discontinuity in the coefficient after 5 samples is a maximum of 0.2365 , of about 62 dB down. In effect, the allpass interpolation filter may be held to a 5 sample ”warm up” time. B.2.2 Legato Crossfade of Digital Waveguide String Models If a delay line length within a feedback loop changes suddenly, there will be a discontinuity in the signal. If the delay line length is changed gradually or smoothly (using fractional interpolation of some kind), audio artifacts may not result, but a glissando effect will result, which may not be desired. An algorithm to create a legitimate legato crossfade 216 APPENDIX B. PITCHBENDABLE ALLPASS INTERPOLATION DLEN_INT AP_COEF Parameter Generator DLEN Crossfade Ramp crossfade orientation Timing Controller AP_COEF2 1 AP_COEF1 0 DLEN_INT2 index DLEN_INT1 AUDIO IN u1(n) Reader 1 u2(n) … … … Delay Line direction of signal flow … … … Reader 2 AP 1 u3(n) Alternating Crossfader … u4(n) AP 2 AUDIO OUT u6(n) u5(n) Figure B.1: The Interpolated Allpass Crossfade Structure effect is proposed in (Jaffe and Smith, 1995) to solve this problem: Delay line memory is allocated using a circular buffer and setting up two delay line outputs, or read pointers and crossfading the output signal between them over a period of 15-30 milliseconds to produce a realistic legato (not glissando). This works with such a long crossfade time because the circular buffer is already filled naturally with appropriate waveform material for the 15-30 milliseconds of the crossfade. B.3 Implementation By combining the allpass interpolation method, and the legato crossfade method, we can find a practical structure for a flexible lossless fractional delay line implementation. The basic principle is to view glissando as lots and lots of very fast, tiny, legato crossfades. Construct a circular buffer delay line with two allpass interpolated read point outputs; APPENDIX B. PITCHBENDABLE ALLPASS INTERPOLATION 217 Warm-up Time Pan Position Function AP1 Cross Fade pan postion between AP1 and AP2 AP2 AP_COEF1, DLEN_INT1 Updates AP_COEF2, DLEN_INT2 Updates Audio Sample Rate Time Figure B.2: Timing Diagram for the Alternating Crossfade Between Read Point Outputs then send updated allpass interpolation coefficients to the allpass every 16 samples and begin a crossfade. Figure B.1 shows a block diagram of this structure. The problem with this, as it stands, is that the allpass interpolation filters will be producing clicks every time a reader is set to a new position. However, the transient effect lasts only 5 samples if the fractional delay range is maintained between 0618 and 1.618, as we have shown. The 5 sample warm up period can be ignored by using a special crossfading function which waits 5 samples before beginning the crossfade over to the newly set allpass reader. When using a 16 sample alternation rate, this leaves 11 samples to do the actual crossfade, which in practice, is enough. Figure B.2 shows the critical timing of setting the new allpass coefficients and performing the delayed crossfade. B.3.1 Psychoacoustical Detail The human hearing system is only able to detect a finite number of different pitches. Two tones which are sufficiently close together in pitch become indistinguishable. There is a just noticeable difference (JND) threshold for human pitch differentiation. The number of JNDs per octave varies with register, but a representative worst case for our problem is that there are approximately 280 JNDs between 1000 Hz and 2000Hz. (or, in musical pitch, this it the approximate range, c6 to c7). (Olson, 1967). A JND in this worst case range comes out to be about 0.1 samples in a Karplus-Strong feedback loop delay line APPENDIX B. PITCHBENDABLE ALLPASS INTERPOLATION 218 length for a 1000 Hz tone being computed at a sampling rate of 44.1kHz. It is easy to show that running the alternating crossfader at a rate of once per clock tick of 16 samples, and using a maximum glissando rate of one JND per clock tick, that we can gliss an octave from C6 to C7 in about one tenth of a second (280 × 16/44100 ≈ 0.1). Moreover we do this very quick glissando crossfading between tones different by one JND, and we wait 5 samples for each new allpass state to settle down before crossfading. B.3.2 A DSP Implementation Trick Many fixed-point DSP chips can perform very fast multiply-add operations but do not support fast divide operations. So computing the allpass coefficient, ad , is hard. On the other hand, building an interpolation table is also fraught with the trade off between error and memory wastage. Fortunately, expanding ad in a Taylor’s Series around the point d = 1 (which is in the middle of its working range, 06.18 to 1.618) provides a solution: ad ≈ 1−d d − 1 (d − 1)2 (d − 1)3 ≈− + − + ... 1+d 2 4 8 (B.3) This is a very efficient implementation using only a few multiplies, adds, and possibly, right shifts. Maximum error in three terms is 0.024 samples. Recall a JND in our worst case range, 1000Hz, is 0.1 samples. The allpass error using three terms of the expansion is on the order of a quarter of a JND (meaning it is not noticeable standing alone). Appendix C Stiffness Using Regions of FM C.1 Analysis/Synthesis Model of the Spectral Structure The work presented in this Chapter was first published in (Van Duyne, 1992). There are two fundamental elements to the spectral structure of low piano tones which work together to create their characteristic sound. First, the magnitude spectrum is arranged in groupings of eight or nine partials. These groupings are not related to any kind of formant phenomenon, but are apparently the result of the hammer strike position on the string. The hammer position on the low piano strings has traditionally been placed very carefully at some point near 1/8 or 1/9 the distance across the length of the string. The acoustics of such a system dictates these kind of near nulls in the string spectrum at harmonics which are near multiples of eight or nine. Figure C.1 shows the partials grouping in sets of 8 or 9. In another view, the sonograph in Figure C.2 shows these groupings as well, the horizontal axis is time. The vertical axis is frequency (0 Hz to 2000 Hz). Lightness and darkness indicate the relative magnitudes. The second element of the spectral structure is that the harmonics of the low piano string are in fact not harmonic, but instead stretched at a fairly linear rate throughout the spectrum. The stiffness of thick piano strings in the lowest register causes the sinusoidal components of the traveling wave on the string to travel faster when at higher frequencies, thereby spawning harmonic resonances in the string at ever increasing partial spacings through the spectrum. Stretching was measured for A0 (the lowest note on a conventional piano) at a rate of 10 Hz over 1000 Hz of spectrum. For example, near the A0 fundamental, 219 APPENDIX C. STIFFNESS USING REGIONS OF FM Figure C.1: Plotter Data Showing Natural Groupings of Partials of A0 220 APPENDIX C. STIFFNESS USING REGIONS OF FM Figure C.2: Spectral Evolution of A0 221 222 APPENDIX C. STIFFNESS USING REGIONS OF FM 2000 1500 1000 500 0 10 20 30 40 50 60 Figure C.3: Measured Partial Frequencies in Hz for A0 the separations between partials are near 27.5 Hz. At a height of 1000 Hz in the spectrum, the separations are near 37.5 Hz, and so on. For the note A1, one octave above A0, the rate of stretching was considerably lower: about 3 Hz per 1000 Hz. These rates, of course, vary from piano to piano. Figure C.3 shows the stretching for A0. The synthesis of low piano tones has been a complex problem due to stretching harmonics. However we can take advantage of the spectral groupings in the piano spectrum to build an FM model (Chowning, 1973) of piecewise linear partial separations. To model a string with fundamental f0 , assign one FM carrier/modulator pair to each of the groupings. Let the carrier and modulator frequencies for the ith FM pair be given as ci and mi . Choose m1 to be f0 and c1 to be 5f0 . With the proper choice of FM Index, this pair can be used to model a grouping of eight or nine partials. To obtain a piecewise stretching of the partials, select the parameters of the second FM pair to have a modulator slightly larger than m1, and a carrier c2 placed eight partials above c1 . Continuing this way with as many pairs as desired, we can construct a piecewise stretched spectrum arranged in groupings. We just require m1 < m2 < m3 < . . . < mn to model the stretching rate. Care must be taken to dovetail the pairs together with a proper choice of the carrier frequencies. We need ci = ci−1 + 4mi−1 + 4mi to insure that the fourth sidebands of each pair match frequency with the adjacent pair. Note that there is no longer any meaningful 223 APPENDIX C. STIFFNESS USING REGIONS OF FM c1 m1 c2 m2 cn mn ... Figure C.4: MUSIC 5 Diagram of Instrument c : m ratio for pairs above the first. The Index should be chosen not too large, to avoid de-tuned overlap of sidebands from adjacent pairs, and, on the other hand, not too small, in order to produce enough sideband presence to maintain a coherence of the spectrum. Mapping the amplitude envelope to the Index envelope seems a good first approximation here. Figure C.4 shows an outline schematic of the instrument. The experimental results show that a very good low piano tone can be made using only four or five of these additive FM pairs. Even with no stretching, i.e. with f0 = m1 = m2 = . . . = mn , a reasonable approximation of a piano is possible. However, with just the slightest piecewise stretching introduced, a naturalness and life is infused into the tone color which is hard to come by in an exactly harmonic spectrum. C.2 Construction of Decay Envelopes The choice of amplitude envelopes for the FM pairs is critical in the production of a believable piano sound. The decay envelope of the piano tone is generally exponential. However, the rate of decay is faster toward the beginning of the tone than later on. This effect can be modeled by making a linear combination of two exponential decays as follows: Amp(t) = α1 e−t/τ1 + α2 e−t/τ2 (C.1) APPENDIX C. STIFFNESS USING REGIONS OF FM 224 where t is time, τ1 and τ2 are the time constants of decay, and α1 and α2 are the relative scalings of each envelope component. We use a relatively short τ1 to model the decay rate in the first one or two seconds after the attack, and a longer τ2 to model the second stage decay rate. There are several other considerations in the construction of appropriate envelopes: (1) Higher frequency components of the piano tone die out more quickly than lower frequency components, necessitating separate parameters for each of the FM pairs used. Also, (2) louder attacked notes begin with a brighter spectrum, requiring more energy in the higher pairs at the attack. In addition to the decay envelope differences, (3) the cut-off release time is much longer for A0 than for A1. The slow release time of the lowest piano notes is an important part of their timbral signature. (4) The attack portion of the amplitude envelope of each FM pair is constructed using a rise-rate method where the actual time before the highest amplitude is reached depends on how high the envelope must rise. This naturally rounds out the attack a little by de-synchronizing the attack time over the spectrum. In addition, (5) a constant speaking-threshold segment is introduced before the rise time portion to bring the amplitude up from 0 to just audible. This segment, if the parameters are chosen right, produces a characteristic thump and broadens the attack. C.3 Fine Points: Beating in the Partials Some periodic amplitude fluctuation in the middle and higher partials on the order of 2 to 4 Hz is visible in Figure C.2. This is modeled by adding a sinusoidal amplitude modulation component to the Index envelopes of the FM pairs. Modulating the Indices instead of the amplitudes of the pairs attempts to give a variety of fluctuation levels for the different partials in each pair. The frequency of this modulation is given at higher rates for pairs which contributed to higher spectral areas, as is the general trend in the analyzed spectral data. While the resultant spectral pictures of these synthesis attempts are more like the pictures of real data, the auditory differences are negligible and otherwise only add complexity to a simple, elegant synthesis algorithm. APPENDIX C. STIFFNESS USING REGIONS OF FM C.4 225 Conclusion It is now evident that excellent models of nearly harmonic spectra can be built by separating the spectrum into piecewise regions of equally spaced partials, each region modeled with a carefully tuned FM pair. Using the same procedures, an entire class of synthesis algorithms become available for musical timbres with slowly changing rates of partial stretching or partial contracting over the spectrum. Bibliography Abel, J. and Smith, J. O. (2006). Robust design of very high-order allpass dispersion filters. In Proceedings of the 9th Int. Conf. on Digital Audio Effects (DAFX-06), Montreal. Abel, J. and Van Duyne, S. A. (May 30, 2007). Discussion on passive nonliner filters. Personal communication. Bensa, J. (2000). Analysis and synthesis of piano sounds using physical and signal models. PhD thesis, Université de la Méditerranée. Berners, D. P. (1999). Acoustics and Signal Processing Techniques for Physical Modeling of Brass Instruments. PhD thesis, Electrical Engineering Department, Stanford University. Bilbao, S. (2001). Wave and Scattering Methods for the Numerical Integration of Partial Differential Equations. PhD thesis, Electrical Engineering Department, Stanford University. Bilbao, S. (2004). Wave and Scattering Methods for Numerical Simulation. John Wiley and Sons, Chichester. Boutillon, X. (1988). Model for piano hammers: Experimental determination and digital simulation. Journal of the Acoustical Society of America, 83(2):746–754. Carrier, G. F. (1945). On the non-linear vibration problem of the elastic string. Quarterly of Applied Mathematics, 3:157–165. Chafe, C. (1990). Pulsed noise in self-sustained oscillations of musical instruments. In Proceedings IEEE International Conf. Acoust. Speech and Signal Proc., Albuquerque, NM. 226 BIBLIOGRAPHY 227 Chaigne, A. and Askenfelt, A. (1994a). Numerical simulations of piano strings. I. a physical model for a struck string using finite difference methods. Journal of the Acoustical Society of America, 95(2):1112–1118. Chaigne, A. and Askenfelt, A. (1994b). Numerical simulations of piano strings. II. comparisons with measurements and systematic exploration of some hammer-string parameters. Journal of the Acoustical Society of America, 95(3):1631–1640. Chowning, J. (1973). The synthesis of complex audio spectra by means of frequency modulation. Journal of the Audio Engineering Society, 21(7). reprinted in Computer Music Journal 1(2), 1977; reprinted in Foundations of Computer Music, C. Roads and J. Strawn (eds.), MIT Press, 1985. Chowning, J. and Bristow, D. (1987). FM Theory and Applications: By Mucisians for Musicians. Hal Leonard Corporation. Cook, P. (1990). Identification of Control Parameters in an Articulatory Vocal Tract Model, with Applications to the Synthesis of Singing. PhD thesis, Stanford University. Cook, P. (1996). Physically informed sonic modeling (phism): Percussive synthesis. In Proceedings of the International Computer Music Conference. Courant, R., Friedrichs, K., and Lewy, H. (1956). On the partial difference equations of mathematical physics. Contract AT(30-1)-1480, United States Atomic Energy Commission. Courant, R. and John, F. (1974). Introduction to Calculus and Analysis, volume 2. John Wiley & Sons, New York. Cruz, J. and Van Valkenburg, M. (1974). Signals in Linear Circuits. Houghton Mifflin, Boston. d’Alembert, J. L. R. (1749). Recherches sur la courbe que forme une corde tendue mise en vibration. From series Memoires de l’Academie royale des sciences et belles lettres. Classe de mathematique. Annee 1747, t.3. Dodge, C. and Jerse, T. A. (1985). Computer Music Synthesis, Composition, and Performance. Schirmer Books, New York. BIBLIOGRAPHY 228 Elmore, W. C. and Heald, M. A. (1985). Physics of Waves. Dover Publications, Inc., Ney York. First publication by McGraw-Hill Book Company, New York, in 1969. Fettweis, A. (1986). Wave digital filters: Theory and practice. Proceedings of the IEEE, 74(2):270–327. Fletcher, N. and Rossing, T. (1991). The Physics of Musical Instruments. Springer–Verlag, New York. Fontana, F. and Rocchesso, D. (1998). Physical modeling of membranes for percussion instruments. Acta Acustica, 84(3). Fontana, F. and Serefin, S. (2003). Modeling Savart’s trapezoidal violin using a digital waveduide mesh. In Proceedings Stockholm Music Acoustic Conference (SMAC03). Gillespie, R. B. (1996). Haptic Display of Systems with Changing Kinematic Constraints: The Virtual Piano Action. PhD thesis, Engineering Department, Stanford University. Graff, K. F. (1975). Wave Motion in Elastic Solids. Clarendon Press, Oxford. Hall, D. E. (1986). Piano string excitation in the case of small hammer mass. Journal of the Acoustical Society of America, 79(1):141–147. Hall, D. E. (1987a). Piano string excitation II: General solution for a hard narrow hammer. Journal of the Acoustical Society of America, 81(2):535–546. Hall, D. E. (1987b). Piano string excitation III: General solution for a soft narrow hammer. Journal of the Acoustical Society of America, 81(2):547–555. Hall, D. E. (1987c). Piano string excitation IV: The question of missing modes. Journal of the Acoustical Society of America, 82(6):1913–1918. Hall, D. E. (1988). Piano string excitation V: Spectra for real hammers and strings. Journal of the Acoustical Society of America, 83(4):1627–1638. Hall, D. E. (1992). Piano string excitation. VI: Nonlinear modeling. Journal of the Acoustical Society of America, 92(1):95–105. Hirschman, S. E. (1991). Digital Waveguide Modeling and Simulation of Reed Woodwind Instruments. PhD thesis, Electrical Engineering Dept., Stanford University. BIBLIOGRAPHY 229 Hsu, H. P. (1984). Applied Fourier Analysis. Harcourt Brace Jovanovich, Publishers, New York. In Harcourt Brace Jonanovich College Outline Series. Huang, P., Serafin, S., and Smith, J. O. (2000). A 3d waveguide mesh model of highfrequency violin body resonances. In Proceedings International Computer Music Conference, Berlin. Jaffe, D. and Smith, J. O. (1995). Performance expression in commuted waveguide synthesis of bowed strings. Proceedings ICMC, Banff. Jaffe, D. A. and Smith, J. O. (1983). Extensions of the Karplus–Strong plucked string algorithm. Computer Music Journal, 7(2):56–69. Karjalainen, M., Välimäki, V., and Janosy, Z. (1993). Towards high-quality sound synthesis of the guitar and string instruments. In Proceedings of the International Computer Music Conference, Tokyo. Karjalainen, M., Välimäki, V., and Tolonen, T. (1998). Plucked-string models: from the karplus-strong algorithm to digital waveguides and beyond. Computer Music Journal, 22(3). Karplus, K. and Strong, A. (1983). Digital synthesis of plucked string and drum timbres. Computer Music Journal, 7(2):43–55. Kelloniemi, A. (2006). Frequency-dependent boundary conditions for the 3-d digital waveguide mesh. In Proceedings International Conference of Digital Audio Effects (DAFX06), Montreal. Kelloniemi, A., Välimäki, V., Huang, P., and Savioja, L. (2005). Artificial reverberation using a hyper-dimensional FDTD mesh. In Proceedings European Signal Processing Conference (EUSIPCO). Kelloniemi, A., Välimäki, V., and Savioja, L. (2006). Simulation of room acoustices using 2-d digital waveguide meshes. In Proceedings IEEE Workshop on Acoustics, Speech and Signal Processing (ICASSP), Toulouse. Kindel, J. and Wang, I.-C. (1987). Modal analysis and finite element analysis of a piano soundboard. In Proceedings of the 5th Modal Analysis Conference, London, pages 1545–1549. BIBLIOGRAPHY 230 Kirk, R. E. (1959). Tuning preferences for piano unison groups. Journal of the Acoustical Society of America, 31(12):1644–1648. Kock, W. E. (1937). The vibrating string considered as an electrical transmission line. Journal of the Acoustical Society of America, 8:227–233. Kuo, F. (1966). Network Analysis and Synthesis. John Wiley & Sons, New York. Lagge, K. A. and Fletcher, N. H. (1984). Nonlinear generation of missing modes on a vibrating string. Journal of the Acoustical Society of America, 76:5–12. Leary, A. B. (1996). A real-time, polyphonic physical modeling synthesizer. The Journal of the Acoustical Society of America, 100(4):2810–2811. Levi, E. C. (1959). Complex-curve fitting. IRE Transactions on Automatic Control, AC(4):37–44. Ludeman, L. C. (1986). Fundamentals of Digital Signal Processing. John Wiley & Sons, Inc., New York. Chapter 2 on the Z–Transform. Magnusson, P. (1970). Transmission Lines and Wave Propagation. Allyn and Bacon, Boston. Maneri, J. G. and Van Duyne, S. A. (1986). Preliminary Studies in the Virtual Pitch Continuum. Accentuate Music, Plainview, New York. Martin, D. W. (1947). Decay rates of piano tones. Journal of the Acoustical Society of America, 19(4):535–541. Morse, P. M. (1976). Vibration and Sound. American Institute of Physics, for the Acoustical Society of America, (516)349-7800 x 481. (1st ed. 1936, 2nd ed. 1948.). Morse, P. M. and Ingard, K. U. (1968). Theoretical Acoustics. McGraw-Hill, New York. Murphy, D., Newton, C., and Howard, D. (2001). Digital waveguide mesh modeling of room acoustics: Surround-sound, boundaries and plug-in implementation. In Proceedings of the Conference on Digital Audio Effects (DAFX-01), Limerick. Nakamura, I. (1983). The vibrational charater of the piano soundboard. In Proceedings of the 11th International Congress on Acoustics, Paris, pages 385–388. BIBLIOGRAPHY 231 Nehari, Z. (1952). Conformal Mapping. McGraw-Hill, New York. Olson, H. (1967). Music, Physics, and Engineering. Dover Publications, Inc. Paladin, A. and Rocchesso, D. (1992). A dispersive resonator in real time on mars workstation. In Proceedings of the 1992 International Computer Music Conference, San Jose. Parks, T. W. and Burrus, C. S. (1987). Digital Filter Design. John Wiley & Sons, Inc., New York. Pierce, J. P. (1974). Almost All About Waves. The MIT Press, Cambridge, Massachusetts. Pierce, J. P. and Van Duyne, S. A. (1997a). A passive nonlinear digital filter design which facilitates physics-based sound synthesis of highly nonlinear musical instruments. Journal of the Acoustical Society of America, 101(2):1120–1126. Pierce, J. R. (January 20, 1993a). About the simulation of welling up of frequencies in strings. Personal notes documented during the collaboration on passive nonlinear filter research. Pierce, J. R. (July 2, 1993b). Conservative nonlinearities and synthesis of gong sounds. Personal notes documented during the collaboration on passive nonlinear filter research. Pierce, J. R. and Van Duyne, S. A. (Filed: May 10, 1994; Issued: December 30, 1997b). Passive nonlinear filter for digital musical sound synthesizer and method. United States Patent No. 5,703,313. Porcaro, N., Jaffe, D., Scandalis, P., Smith, J. O., Stilson, T., and Van Duyne, S. A. (1998). SynthBuilder: A graphical rapid-prototyping tool for the development of music synthesis and effects patches on multiple platforms. Computer Music Journal, 22(2):35–43. Porcaro, N., Scandalis, G. P., Jaffe, D., and Smith, J. O. (1996). Demonstration: Using SynthBuilder for the creation of physical models. In Proceedings of the International Computer Music Conference, Hong Kong. 232 BIBLIOGRAPHY Rauhala, J. and Välimäki, V. (2006). Dispersion modeling in waveguide piano synthesis using tunable allpass filters. In Int. Conf on Digital Audio Effects (DAFX-06), Montreal. Risset, J.-C. and Van Duyne, S. A. (1992). Duetto per un pianista: Realizzazione dal vivo di un’interazione tra pianoforte e computer. I Quaderni della Civica Scuola di Musica, 10(21-22). Risset, J.-C. and Van Duyne, S. A. (1996). Real-time performance interaction with a computer-controlled acoustic piano. Computer Music Journal, 20(1). Rodet, X. (1994). Stability/instability of periodic solutions and chaos in physical models of musical instruments. In Proceedings of the 1994 International Computer Music Conference, Århus. Savioja, L., Backman, J., Järvinen, A., and Takala, T. (1995). Waveguide mesh method for low-frequency simulation of room acoustics. Proceedings of the 15th International Conference on Acoustics (ICA-95), Trondheim, Norway, pages 637–640. Savioja, L., Rinne, T. J., and Takala, T. (1994). Simulation of room acoustics with a 3-d finite difference mesh. In Proceedings of the International Computer Music Conference, Arhus. Scavone, G. (1997). An Acoustic Analysis of Single-Reed Woodwind Instruments with an Emphasis on Design and Performance Issues and Digital Waveguide Modeling Techniques. PhD thesis, Music Department, Stanford University. Schottstaedt, W. (1992). An introduction to FM. This now available on line at http://ccrma.stanford.edu/software/snd/snd/fm.html. Schuck, O. H. and Young, R. W. (1943). Observations of the vibrations of piano strings. Journal of the Acoustical Society of America, 15(1):1–11. Serafin, S., Huang, P., and Smith, J. (2001). The banded digital waveguide mesh. In Proceedings Mosart Meeting, Barcelona. Serra, X. (1997). Musical sound modeling with sinusoids plus noise. In Roads, C., Pope, S., Picialli, A., and Poli, G. D., editors, Musical Signal Processing. Swets and Zwitlinger Publishers. BIBLIOGRAPHY 233 Smith, J. O. (1983). Techniques for Digital Filter Design and System Identification with Application to the Violin. PhD thesis, Stanford University. Smith, J. O. (1987). Music applications of digital waveguides. Technical Report STANM-39, Center for Computer Research in Music and Acoustics, Stanford University. Smith, J. O. (1992). Physical modeling using digital waveguides. Computer Music Journal, 16(4):74–91. Smith, J. O. (1993). Efficient synthesis of stringed musical instruments. In Proceedings of the International Computer Music Conference, Tokyo. Smith, J. O. and Little, J. N. (1988-1994). From matlab documentation: INVFREQZ Discrete filter least squares fit to frequency response data. The Mathworks, Inc. With improvements from L. Ljung and T. Krauss. Smith, J. O. and Van Duyne, S. A. (1995). Commuted piano synthesis. In Proceedings of the International Computer Music Conference, pages 319–326, Banff. Stilson, T. (1994). Simulations of a pressue wave in a bent tube using 3-d waveguide mesh. c-code simulations and animation plots of 6-port rectilinear mesh with reflective terminations filling the space in a bent tube shape. Stilson, T. (2006). Efficiently-Variable Non-Oversampled Algorithms in Virtual-Analog Music Synthesis. PhD thesis, Electrical Engineering Department, Stanford University. Stilson, T. S. (1997). Applying root-locus techniques to the analysis of coupled modes in piano strings. In Proceedings of the International Computer Music Conference, Thessaloniki. Strikwerda, J. C. (1989). Finite Difference Schemes and Partial Differential Equations. Wadsworth & Brooks, Pacific Grove, California. Stulov, A. (1995). Hysteretic model of the grand piano hammer felt. Journal of the Acoustical Society of America, 97(4):2577–2585. Suzuki, H. (1986). Vibration and sound radiation of a piano soundboard. Journal of the Acoustical Society of America, 80(6):1573–1582. BIBLIOGRAPHY 234 Suzuki, H. (1987). Model analysis of a hammer-string interaction. Journal of the Acoustical Society of America, 82(4):1145–1151. Välimäki, V. (1995). Discrete-Time Modeling of Acoustic Tubes Using Fractional Delay Filters. PhD thesis, Electrical Engineering Department, Helsinki University of Technology. Välimäki, V., Laasko, T., and Mackenzie, J. (1995). Elimination of transients in timevarying allpass fractional delay filters with applications to digital waveguide modeling. Proceedings ICMC. Van Duyne, S. A. (1992). Low piano tones: Modeling nearly harmonic spectra with regions of FM. In Proceedings of the International Computer Music Conference, San Jose. Van Duyne, S. A. (1997). Coupled mode synthesis. Proceedings ICMC, Thessaloniki. Van Duyne, S. A. (Filed: August 16, 1996; Issued: May 5, 1998). Method for inharmonic tone generation using a coupled mode digital filter. United States Patent No. 5,748,513. Van Duyne, S. A. (Filed: March 21, 1989; Issues: November 27, 1990). Microtonal key module and system. United States Patent No. 4,972,752. Van Duyne, S. A., Jaffe, D., Scandalis, G. P., and Stilson, T. (1997). A lossless, click-free, pitchbend-able, delay line loop imterpolation scheme. Proceedings ICMC, Thessaloniki. Van Duyne, S. A., Jaffe, D. A., Scandalis, G. P., and Stilson, T. S. (Filed: May 9, 1996; Issued: April 21, 1998). System and method for generating fractional length delay lines in a digital signal processing system. United States Patent No. 5,742,532. Van Duyne, S. A., Pierce, J. R., and Smith, J. O. (1994). Traveling wave implementation of a lossless mode–coupling filter and the wave digital hammer. In Proceedings of the International Computer Music Conference, Århus. Van Duyne, S. A. and Smith, J. O. (1992). Implementation of a variable pick-up point on a waveguide string model with FM/AM applications. In Proceedings of the 1992 International Computer Music Conference, San Jose, pages 154–157, San Francisco. Computer Music Association. BIBLIOGRAPHY 235 Van Duyne, S. A. and Smith, J. O. (1993a). The 2–d digital waveguide mesh. In Proceedings of the IEEE Workshop on Applications of Signal Processing to Audio and Acoustics, New Paltz, NY. Van Duyne, S. A. and Smith, J. O. (1993b). Physical modeling with the 2–D digital waveguide mesh. In Proceedings of the International Computer Music Conference, Tokyo. Van Duyne, S. A. and Smith, J. O. (1994). A simplified approach to modeling dispersion caused by stiffness in strings and plates. In Proceedings of the International Computer Music Conference, pages 407–410, Århus. Van Duyne, S. A. and Smith, J. O. (1995a). The 3–d tetrahedral digital waveguide mesh. In Proceedings of the IEEE Workshop on Applications of Signal Processing to Audio and Acoustics, New Paltz, NY. Van Duyne, S. A. and Smith, J. O. (1995b). Developments for the commuted piano. In Proceedings of the International Computer Music Conference, Banff. Van Duyne, S. A. and Smith, J. O. (1996). The 3d tetrahedral digital waveguide mesh with musical applications. In Proceedings of the International Computer Music Conference, Hong Kong. Van Duyne, S. A. and Smith, J. O. (Filed: May 10, 1994; Issued: November 14, 1995d). Music synthesizer system and method for simulating response of resonant digital waveguide struck by felt covered hammer. United States Patent No. 5,466,884. Van Duyne, S. A. and Smith, J. O. (Filed: May 2, 1997: Issued: July 7, 1998). Efficient synthesis of musical tones having nonlinear excitations. United States Patent No. 5,777,255. Van Duyne, S. A. and Smith, J. O. (Filed: May 4, 1993; Issued: November 28, 1995c). Multidimensional digital waveguide signal synthesis system and method. United States Patent No 5,471,007. Van Duyne, S. A. and Smith, J. O. (Filed: November 27, 1995: Issued: March 25, 1997). Multidimensional digital waveguide signal synthesis system and method (tetrahedral extension). United States Patent No. 5,614,686. BIBLIOGRAPHY 236 Weinreich, G. (1977). Coupled piano strings. Journal of the Acoustical Society of America, 62(6):1474–1484. Wogram, K. (1980). Acoustical research on pianos: Vibrational characteristics of the soundboard. Das Musikinstrument (English Version), 24:694–702, 776–782, 872–880. Wolfram, S. (1999). Mathematica. Cambridge University Press. Yegnanarayana, B. (1982). Design of recursive group–delay filters by autoregressive modeling. IEEE Trans. of Acoust. Sp. and Sig. Proc., ASSP–30:632–637. Zemanian, A. H. (1987). Generalized Integral Transforms. Dover Publications, Inc., New York. First publication by Interscience Publishers, New York, 1968, as Volume XVIII in the series Pure and Applied Mathematics, edited by R. Courant, L. Bers and J. J. Stoker. See, in particular, Section 3.9 on the application of the generalized bidirectional Laplace transform to the 1-D wave equation. Zhu, W. D. and Mote, Jr., C. D. (1994). Dynamics of the pianoforte string and narrow hammers. Journal of the Acoustical Society of America, 96(4):1999–2007.