The Piano MUS420/EE367A Lecture 6B Piano Synthesis Julius O. Smith III ([email protected]) Center for Computer Research in Music and Acoustics (CCRMA) Department of Music, Stanford University Stanford, California 94305 Acoustics of the Piano • Five Lectures on the Acoustics of the Piano1 • The Piano Hammer as a Nonlinear Spring2 Piano Synthesis March 24, 2014 We know how to Outline • The Piano • simulate strings efficiently • Commuted Piano Synthesis • couple strings at the bridge • Hammer Modeling We will now discuss how to • Piano String Modeling • commute resonators and strings (for speed) • convolve resonator impulse response with excitation (hammer) • simulate a piano hammer in more detail • identify the string-loop filter for stiff strings 1 2 1 http://www.speech.kth.se/music/5_lectures/ http://www.acs.psu.edu/drussell/Piano/NonlinearHammer.html 2 Commuted Synthesis e(t) Trigger Features of Commuted Synthesis y(t) s(t) String Excitation Resonator Output Schematic diagram of a stringed musical instrument. Trigger Excitation String Resonator Output Equivalent diagram in the linear, time-invariant case. Trigger Aggregate Excitation a(t) • Good qualitative excitation signals are easy to measure (just tap on the bridge) • Apparent “resonator size” can be modulated by changing the playback rate of the excitation table Drawbacks: • Requires linearity and time invariance x(t) String • Enormous resonators can be implemented inexpensively (three orders of magnitude less computation for typical stringed instruments) Output Use of an aggregate excitation given by the convolution of original excitation with the resonator impulse response. s(t) Bridge Coupling Guitar Body Air Absorption Room Response y(t) Output Possible components of a guitar resonator. 3 4 Commuted Piano Synthesis Synthesis of One Hammer-String Interaction Pulse Hammer-string interaction pulses (force): Impulse Impulse Response Force Lowpass Filter 0.5 0.4 Time Time 0.3 0.2 • Filter input = impulse 0.1 5 10 15 Time 20 • Vertical lines = locations and amplitudes of three impulses • Hammer-string interaction signal synthesized using one to three digital filters • Filter output = desired hammer-string force pulse • As input amplitude increases, output pulse narrows ⇒ nonlinear filter • For each specific impulse, filter is linear time-invariant • Piano is “linearized” separately for each hammer velocity • Filters depend on striking velocity 5 6 Synthesis of Multiple Hammer-String Interaction Pulse Complete Piano Model Natural Ordering: Multiple hammer-string interaction pulses = superposition of several individual pulses: vc Impulse δ1 Tapped δ1 GenerDelay δ2 Trigger ator Line Force Impulse 1 Impulse 2 Impulse 3 δ1 LPF1 δ2 LPF2 δ3 LPF3 + String Input δ3 0 Time • Input to each filter is a single impulse • Sum of outputs = superposition of hammer-string force pulses LPF1 + LPF2 String Sound Board & Enclosure Output LPF3 Commuted Ordering: vc Sound Board & Enclosure Trigger Impulse Response LPF1 Tapped Delay Line LPF2 + String Output LPF3 • As impulse amplitude grows, output pulses become taller and thinner, showing less overlap. • Soundboard and enclosure are commuted • Only need a stored recording of their impulse response • An enormous digital filter is otherwise required 7 8 Simplified Variations of the Commuted Piano Three General Interaction Pulses One interaction pulse: Hammer/String Collision Velocity vc Hammer/String Collision Velocity vc Excitation Table Lowpass Filter Optional Output Scaling LPF1 Excitation Table LPF2 + String Output LPF3 String Output Differentially Filtered Interaction Pulses Up to three identical interaction pulses: vc Hammer-String Collision Velocity Excitation Table + Hammer/String Collision Velocity Optional Output Scaling Lowpass Filter String LPF1 Output Excitation Table Delay + LPF2 Delay String Output LPF3 Each new delay is equal to the travel from the hammer, to the agraffe, and back to the hammer 9 10 Striking a Digital Waveguide String Equivalent Computational Models Waveguide string in “physical canonical form”: String Output f+(n) Example Output Delay “Agraffe” Rigid Termination f -(n) (x = 0) - Hammer Strike f(t) g(t) Delay Delay Hammer Strike f(t) Delay Filter “Bridge” Yielding Termination Filter • Hammer position set by feedforward comb filter Delay (x = striking position) Delay (x = L) • Delay lines contain traveling force waves • String model independent of hammer position (more valuable for plucked strings) • Same factoring applies to pickup locations • Hammer-string force pulses are summed into both directions (by physical symmetry) 11 12 Use of a Tapped Delay Line Excitation Factoring Commuted Piano Synthesizer: Tap Input c Output Delay Filter • Delay-line tap simulates hammer-strike echoes returning from the far end of the string vc Excitation & Nonlinear Filtering Resonator(s) and/or Equalization and/or Reverb and/or Comb Filter(s) String(s) Outputs A few small filters are retained in parametric form for • Total delay line length equals twice the travel time along the entire length of the string • Soundboard and enclosure • Placement is not critical, so an interpolating tap is not necessary • Reverberation • Equalization for color variations • Tap motion gives a free built-in “flanger” effect • Flange • Since force waves are most convenient, no sign inversion at the string endpoints • Chorus • Simulated hammer-strike echoes • Multiple outputs Filters are easily modified, even while a note is playing 13 14 Piano and Harpsichord Sound Examples The Ideal (Lossless) Stiff String • http://ccrma.stanford.edu/~jos/wav/pno-cs.wav • http://ccrma.stanford.edu/~jos/wav/harpsi-cs.wav Output • y+(n) N samples delay + y (n-N) http://ccrma.stanford.edu/~jos/wav/Harpsichord.wav • Julien Bensa’s synthetic piano Allpass Simulation of a rigidly terminated, stiff string. • All N allpass filters Ha(z) have had a minimum sample of delay extracted, corresponding to the delay at fs/2 • All have been combined at a single point • The delay-line length N is the number of samples in K periods of fK , where K is the number of the highest partial (usually the last one before fs/2) • In stiff strings, high frequencies travel faster ⇒ allpass delay decreases with frequency • An order 10 allpass gives high quality piano synthesis • FFT convolution most efficient for maximum accuracy (FIR filter length ≈ N/2 for note F1) 15 16 Nonparametric Model of Measured Piano-String Frequency Response (from Julien Bensa’s thesis) Corresponding Impulse Response Piano String Impulse Response 0.8 Piano String, Note F1, Frequency Response Model 0.6 −0.5 0.4 −1 0.2 −1.5 Phase (cycles) 0 2 4 6 8 10 0 100 −0.2 50 0 −0.4 0 2 4 6 8 10 0 Delay (samples) Amplitude Gain (dB) 0 −0.6 −0.8 −500 0 5 10 15 20 Time (msec) −1000 Loop-filter impulse response, note F1. 0 2 4 6 Frequency (kHz) 8 10 High-quality frequency-response model based on measurements from a grand-piano string, note F1. 17 18 Stiff-String Loop-Filter Identification A basic problem in waveguide synthesis of string is identifying the loop filter Hl (z) which controls • Partial overtone decay time (due to Hl (ejω )) • Partial overtone tuning perturbations (due to ∠Hl (ejω )) Loop-Filter Design Methods One of the earliest methods was “periodic linear prediction” — a linear combination of a small group of samples predicts a sample one period away from the midpoint of the group. More recently, methods have been developed based on measurements of the time-constant of decay for each partial overtone, since this is what matters the most. • Record a plucked (or struck) string. • Measure frequency fk and decay time τk for each overtone. – Energy Decay Relief (EDR) useful for this purpose 19 – Sinusoidal modeling has been used as well – In either case: ∗ Fit a straight line to the log of the amplitude envelope (e.g., using polyfit in Matlab or Octave). ∗ Decay time τk is simply related to the slope of this line. • Translate each decay-time τk into a desired loop-gain at each frequency fk , thus determining Hl (ejωk ) for each partial. • If desired, use the inharmonic spacing of the fk to compute samples of the desired phase of the loop filter, ∠Hl (ejωk ). • Use a general purpose digital filter design routine to design the loop filter which best approximates the desired frequency-response samples Hl (ejωk ). • Phase-matching filter design utilities: – Steiglitz-McBride algorithm (IIR or FIR) See stmcb in Matlab Signal Processing Tool Box – Equation-Error Minimization (IIR or FIR) See invfreqz in matlab – Hankel-Norm Minimization (IIR) 20 Also called a “balanced truncation model” (state space) – Linear-phase FIR (fir1, firls, remez) • Phase-insenstive filter design: – Linear Prediction See lpc or yulewalk in the Matlab SPTB – Create a desired linear or minimum phase and use a phase-sensitive design method. • The fit at low frequencies should be weighted higher. • A simple 1/f weighting usually works well. • Bark spectral warping is commonly used. It implicitly weights low frequencies more by “stretching out” the low-freqency frequency axis and compressing the high-frequency frequency axis. • Piano strings are highly dispersive: – Recall that every LTI filter can be factored into a linear phase filter in series with an allpass filter – The allpass part for a low-pitched string requires on the order of 100 poles (and 100 zeros) to provide a closely matched impulse response – Ten poles is a typical number used in practice (can be very good perceptually) 21 – Most methods for allpass filter design fail numerically at this high order – The linear-phase part, in contrast, is well approximated using only an 8-tap FIR filter, and can be designed by any good method for FIR filter design (e.g., invfreqz in Matlab/Octave) Order Estimation Given a desired frequency response, a rough digital filter order estimate can be obtained as follows: • FIR: Look at the IFFT duration (e.g., 20 log(|h(n)|)) • IIR: Start with half of the FIR order (equal degrees of freedom) • In either case, convert desired frequency response to minimum phase whenever possible: Matlab code: http://ccrma.stanford.edu/~jos/filters/Matlab listing mps m.html • For piano strings, a low-order minimum-phase damping filter is fine because we’re going to need a high-order allpass dispersion filter anyway 22
© Copyright 2026 Paperzz