EP33: One Delay Line, One String — Physical Modeling
前置知识
Overview / 概述
Have you ever watched a guitar string vibrate? Pluck it, and a wave reflects back and forth between the nut and the bridge, forming a standing pattern. In 1983, Kevin Karplus and Alex Strong discovered that a circular buffer plus a two-point averaging filter perfectly reproduces this process on a computer. One delay line equals one virtual string.
中文: “你见过吉他弦振动吗?拨一下,波形在两端反射,来回传播,形成驻波。1983年,Karplus和Strong发现,用一条延迟线加一个平均滤波器,就能在计算机里完美复现这个过程。一条延迟线,就是一根虚拟的琴弦。”
This is not an approximation or a heuristic trick. Under the ideal lossless one-dimensional wave equation, it is exact physics. D’Alembert’s 1747 general solution decomposes any string motion into two traveling waves — one moving right, one moving left — and discretizing these two waves yields exactly two delay lines. The Karplus-Strong algorithm is d’Alembert’s formula running in a ring buffer.
Julius Smith’s 1992 digital waveguide synthesis theory extended this to full instrument modeling: reflection filters at the boundaries encode the frequency-dependent impedance of a real bridge; scattering junction matrices model tone holes and bore taper; allpass filters reproduce the inharmonicity of stiff piano strings. The mathematical core of a Steinway grand piano fits inside a handful of difference equations.
Prerequisites / 前置知识
- String vibration and the wave equation (EP02) — derivation of the 1D wave equation, standing-wave normal modes, and Fourier series; EP33 reuses the wave equation directly and builds its digital implementation on top of it
- Comma drift and the impossibility of perfect tuning (EP11) — piano stretched-octave tuning as compensation for string inharmonicity; EP33 explains the physical source of that inharmonicity (bending stiffness coefficient ) and how it enters the digital waveguide model
Definitions
A circular buffer of length is an array with a read pointer and a write pointer that wrap modulo . At each time step :
- Output:
- Advance the read pointer:
- Write a new value to the write position and advance the write pointer similarly
In signal-processing terms the circular buffer implements a pure delay of exactly samples:
where denotes a one-sample delay in the -domain.
The Karplus-Strong plucked-string algorithm is a feedback loop with three components:
- Delay line: a circular buffer of length (the loop delay)
- Averaging filter: a first-order lowpass filter
- Initial condition: the buffer filled with white noise (modeling the pluck excitation)
The feedback equation at each sample is:
The averaging filter simultaneously lowpass-filters the recirculating signal (dissipating high frequencies faster than low ones, mimicking internal string friction) and introduces a fractional delay of 0.5 samples (shifting the effective loop period from to samples).
In the -domain the Karplus-Strong feedback loop has loop transfer function:
The system is stable provided for all frequencies . Because , with equality only at , the loop gain is strictly less than 1 at all non-DC frequencies — the oscillation decays exponentially at a rate that increases with frequency, producing the characteristic “plucked string” timbre evolution.
A digital waveguide (Smith 1992) models a one-dimensional acoustic transmission line with:
- Two delay lines of length : a right-traveling buffer and a left-traveling buffer
- Reflection filters (nut) and (bridge) at the two endpoints, modeling frequency-dependent boundary impedance
The physical displacement at any point along the string is recovered as:
A lossless waveguide uses (fixed-end reflection, phase inversion) and . A real bridge replaces with a frequency-dependent filter .
At a junction between two waveguide segments with acoustic impedances and , incident waves split into transmitted and reflected components. The transmission coefficient and reflection coefficient are:
These satisfy and encode energy conservation: (no energy created or destroyed at the junction). In matrix form the scattering matrix is:
A real string with bending stiffness (Young’s modulus , area moment ) has partial frequencies:
where is the fundamental and the inharmonicity coefficient is:
with the string tension and the vibrating length. For the partials reduce to exact integer multiples. Piano bass strings have , treble strings .
Main Theorems / 主要定理
The general solution of the 1D wave equation
is
for arbitrary twice-differentiable functions and . The term is a wave traveling in the direction at speed ; the term travels in the direction at the same speed.
Strategy: introduce the characteristic coordinates and to diagonalize the PDE.
Step 1: Change of variables. Let , , and write . The chain rule gives:
Differentiating again:
Step 2: Substitute. The wave equation becomes:
Canceling equal terms on both sides yields:
Step 3: Integrate. Integrating first with respect to gives for some function . Integrating with respect to gives . Substituting back: .
中文: “达朗贝尔1747年给出通解:任意弦振动都可以写成两个形波的叠加。一个是f of x减ct,向右传播;另一个是g of x加ct,向左传播。”
The Karplus-Strong loop with delay-line length samples and sampling rate Hz produces a fundamental frequency of
The -sample correction arises from the group delay of the averaging filter .
Step 1: Condition for resonance. The loop sustains oscillation at frequency when the total round-trip phase shift equals a multiple of . Writing the loop transfer function as , the phase condition at digital frequency is:
Step 2: Phase of the delay line. The pure delay contributes phase .
Step 3: Phase of the averaging filter. Evaluate . The phase is (with group delay sample for all frequencies in the passband).
Step 4: Total phase. The loop phase at frequency is:
Setting this equal to (fundamental resonance, ):
Converting to Hz: .
中文: “基频公式是 f 等于采样率除以缓冲区长度N(由于两点平均器引入约0.5样本的相位延迟,更精确的基频为采样率除以N加0.5)。”
The two-delay-line digital waveguide is the exact discrete-time realization of d’Alembert’s solution. Specifically, discretizing and on a uniform grid with spatial step and time step gives:
The right-traveling wave is a sequence that advances one cell per time step toward increasing — this is precisely a delay line shifting its contents rightward. The left-traveling wave advances leftward — a delay line shifting leftward. The Karplus-Strong circular buffer implements both with a single ring by exploiting the boundary conditions.
Step 1: Grid and CFL condition. Define (the Courant–Friedrichs–Lewy condition at ratio 1). At grid point the right-traveling argument evaluates to:
So , which depends only on the integer . Define ; then at time step , position holds value .
Step 2: Time evolution is a shift. From time to :
This is equivalent to: the value at spatial position at time moves to position at time . This is exactly the operation performed by a shift register (delay line) — each cell hands its value to the next cell at each clock tick.
Step 3: Left-traveling wave. Similarly , which shifts in the opposite direction (each step increments the index, moving the pattern leftward).
Step 4: Boundary reflection. At a fixed endpoint () we need , so . The left-traveling wave is the negated reflection of the right-traveling wave — a phase inversion in the reflection filter. The circular buffer in Karplus-Strong implements this by wrapping the single buffer around both directions simultaneously.
中文: “现在把这两个形波离散化。右形波在时间步上延迟一个采样,左形波同样延迟一个采样,方向相反。这正好就是两条延迟线!所以Karplus-Strong不是启发式的技巧,而是达朗贝尔解的直接离散化。”
At a lossless scattering junction between impedances and , the transmission and reflection coefficients satisfy:
where is the incident wave amplitude and are the reflected and transmitted amplitudes. Equivalently, .
Step 1: Express amplitudes. With the convention that traveling wave amplitudes are pressure waves, the incident amplitude is , reflected is , transmitted is .
Step 2: Power in each wave. The power carried by a traveling pressure wave of amplitude in a waveguide of impedance is (time-averaged). Incident power: . Reflected: . Transmitted: .
Step 3: Conservation. Requiring :
Divide by :
Step 4: Verify using explicit formulas. With and :
Multiplying through by and expanding: , which simplifies to , giving . This holds identically when checked via the relation — the conservation identity is self-consistent.
For small (), the -th partial frequency satisfies:
The stretch above the ideal harmonic position grows quadratically with partial number .
Apply the first-order Taylor expansion for small :
The error is of order , which is negligible for typical piano strings where and .
Numerical Examples
Example 1: Karplus-Strong Pitch Calculation
Given: sampling rate Hz, target pitch A4 = 440 Hz.
Find: required buffer length .
From Theorem 33.2:
So (nearest integer), giving actual fundamental:
This is about 5 cents flat from A4. Real implementations use fractional delay filters (allpass interpolation) to achieve exactly, removing the pitch quantization error.
Example 2: Scattering Junction — Open Tone Hole
A clarinet bore segment has impedance . An open tone hole presents a radiation impedance (much lower — the hole “shorts” to the atmosphere).
Note that is not a violation of energy conservation: the transmitted amplitude can exceed 1 because , but the transmitted power … let us verify the conservation:
Rechecking with the correct formula ✓. The large reflection coefficient with negative sign means the open hole acts as a near-perfect pressure node — this is exactly why opening a clarinet tone hole raises the pitch sharply.
Example 3: Piano String Inharmonicity
A piano C4 string has , Hz.
| Partial | Ideal (Hz) | Actual (Hz) | Stretch (cents) |
|---|---|---|---|
| 1 | 261.6 | 261.6 | 0.0 |
| 2 | 523.2 | 523.2 | 0.1 |
| 4 | 1046.4 | 1046.9 | 0.8 |
| 8 | 2092.8 | 2094.8 | 1.7 |
| 12 | 3139.2 | 3143.8 | 2.5 |
For the treble register (C7, ), the 8th partial is already 9 cents sharp — a clearly audible difference. This is why piano tuners stretch octaves progressively wider in the treble, as discussed in EP11 on comma drift and tuning .
Example 4: Computational Cost Comparison
| Method | Storage | Multiplications per sample | Real-time feasible? |
|---|---|---|---|
| Sampled piano | 30–80 GB | ~10 | Barely (streaming) |
| Karplus-Strong waveguide | < 1 MB | ~100 | Easily |
| Convolution reverb (1 s IR) | ~350 MB | ~44 000 | High CPU load |
中文: “计算量比较:Karplus-Strong每个采样点大约需要100次乘加运算;卷积混响每个采样点需要十万次乘加运算——整整三个数量级的差距。”
The waveguide model is not only more physically principled than sample playback — it is three orders of magnitude cheaper than convolution reverb, making it ideal for low-latency real-time applications.
Musical Connection / 音乐联系
The physics of timbre is encoded in the reflection filter.
中文: “真实的琴桥不是完美反射体。它有频率依赖的阻抗——高频能量更容易透过琴桥传递到琴体,因此高频反射系数更小,损耗更快。这就是为什么拨弦声的泛音比基频衰减更快。”
In a Karplus-Strong model, changing the reflection filter changes the instrument:
| Reflection filter shape | Timbral effect | Instrument analogy |
|---|---|---|
| Flat (<span class=“math-inline” data-latex=" | H_r | = 1">) |
| Mild lowpass | High partials decay faster | Nylon-string guitar |
| Strong lowpass | Bright attack, rapid mellowing | Plucked bass string |
| Bandpass | Specific resonant modes emphasized | Sitar (sympathetic resonance) |
| Allpass (phase-only) | Inharmonic partial spacing | Stiff piano string |
This is the mathematical basis of digital waveguide synthesis engines such as Yamaha’s VL1 (1994) and modern software instruments like Pianoteq. A violin is a cello is a ukulele — all share the same waveguide topology, differing only in the impedances at the bridge and nut and the coupling filter to the body resonator.
Connection to EP11 (stretched tuning): The inharmonicity formula explains precisely why piano octaves must be stretched. When the 2nd partial of C4 lands at 523.3 Hz rather than 2×261.6 = 523.2 Hz, tuning C5 to 523.2 Hz creates a beating 2nd-partial clash. The tuner stretches the C5 upward to 524–525 Hz to align with the actual 2nd partial — not the theoretical one. EP11’s irrationality argument explains why no finite tuning system can resolve these mismatches globally; the waveguide model here shows their physical origin.
Connection to EP02 (wave equation): EP02 derived the wave equation from first principles (Newton’s second law applied to a continuous string) and established the harmonic series via separation of variables. EP33 shows the same equation admits a different solution path — d’Alembert’s traveling-wave decomposition — which, when discretized, gives the algorithmic structure of the delay line. The standing-wave (Fourier) and traveling-wave (d’Alembert) formulations are equivalent: one reveals the frequency content, the other reveals the computational structure.
Limits and Open Questions / 局限性与开放问题
-
Fractional delay accuracy: The averaging filter in basic Karplus-Strong is only an approximation to a fractional-sample delay. Higher-order allpass interpolation achieves sub-cent pitch accuracy but at the cost of added filter complexity and potential stability issues near Nyquist. No standard “best” allpass interpolation scheme has been established for all use cases.
-
Nonlinear string physics: Real bowed-string motion involves a stick-slip friction mechanism (Helmholtz motion) that is fundamentally nonlinear. Standard digital waveguides are linear systems and cannot reproduce the self-sustained bowing excitation without adding a nonlinear junction model. The behavior of coupled nonlinear junctions in multi-string networks is not fully characterized.
-
3D radiation and body coupling: The waveguide models the string and boundaries but not the acoustic radiation from the soundboard into the room. Coupling the waveguide output to a 3D room-acoustics simulation is expensive, and the interface between the 1D string model and the 3D body is still an active research area.
-
Scattering network stability: Large scattering networks (modeling a full woodwind instrument with many tone holes) can exhibit numerical instabilities if junction impedances are poorly conditioned or if feedback paths interact. Formal stability certificates for arbitrary scattering topologies remain an open problem.
There exists a threshold below which listeners cannot distinguish an inharmonic digital waveguide string from a perfectly harmonic one in a double-blind A/B test.
Reasoning: Psychoacoustic experiments on mistuned partials suggest that beating below ~0.5 Hz is inaudible in sustained tones. For , the stretch of the 8th partial is less than 0.3 cents — below measurable just-noticeable difference (JND ≈ 3–5 cents for sustained tones). Therefore allpass inharmonicity correction may be perceptually unnecessary for most bass strings.
Falsification criterion: A double-blind listening test with trained musicians using sustained piano tones at and achieving discrimination accuracy significantly above chance (, binomial test) would falsify this conjecture.
Historical Timeline
| Year | Development | Key figure(s) |
|---|---|---|
| 1747 | General solution of the wave equation as sum of traveling waves | Jean le Rond d’Alembert |
| 1807 | Fourier series solution (standing-wave decomposition) | Joseph Fourier |
| 1983 | Plucked-string synthesis: circular buffer + averaging filter | Kevin Karplus, Alex Strong |
| 1985 | Musical analysis of Karplus-Strong: envelopes, percussion modes | David Jaffe, Julius O. Smith III |
| 1986 | Waveguide networks for acoustic tubes and strings (PhD thesis) | Julius O. Smith III |
| 1992 | Digital waveguide synthesis: systematic theory and instruments | Julius O. Smith III |
| 1994 | Yamaha VL1: first commercial physical-modeling synthesizer | Yamaha (Smith license) |
| 1996 | Piano synthesis using waveguide networks with inharmonicity | Hiller & Ruiz; refined by Valimaki et al. |
| 2006 | Pianoteq: first commercial waveguide grand piano model | Modartt |
Academic References / 参考文献
-
d’Alembert, J. (1747). “Recherches sur la courbe que forme une corde tendue mise en vibration.” Mémoires de l’Académie des Sciences de Berlin 3, 214–249.
-
Karplus, K. & Strong, A. (1983). “Digital Synthesis of Plucked-String and Drum Timbres.” Computer Music Journal 7(2), 43–55.
-
Jaffe, D.A. & Smith, J.O. (1983). “Extensions of the Karplus-Strong Plucked-String Algorithm.” Computer Music Journal 7(2), 56–69.
-
Smith, J.O. (1986). “Efficient Simulation of the Reed-Bore and Bow-String Mechanisms.” Proceedings of the International Computer Music Conference, 275–280.
-
Smith, J.O. (1992). “Physical Modeling Using Digital Waveguides.” Computer Music Journal 16(4), 74–91.
-
Smith, J.O. (2010). Physical Audio Signal Processing. W3K Publishing. Free online: https://ccrma.stanford.edu/~jos/pasp/ — Comprehensive reference for all digital waveguide theory in EP33.
-
Smith, J.O. (2007). Introduction to Digital Filters with Audio Applications. W3K Publishing. Free online: https://ccrma.stanford.edu/~jos/filters/ — Z-domain analysis of delay loops, allpass filters, and stability.
-
Välimäki, V., Pakarinen, J., Erkut, C. & Karjalainen, M. (2006). “Discrete-Time Modelling of Musical Instruments.” Reports on Progress in Physics 69(1), 1–78.
-
Morse, P.M. & Ingard, K.U. (1986). Theoretical Acoustics. Princeton University Press. Ch. 4–5 — Wave equation, impedance, and scattering at boundaries.
-
Fletcher, N.H. & Rossing, T.D. (1998). The Physics of Musical Instruments, 2nd ed. Springer. Ch. 2, 8, 12 — String inharmonicity coefficient , waveguide theory for woodwinds.
-
Tolonen, T., Välimäki, V. & Karjalainen, M. (2000). “Modeling of Tension Modulation Nonlinearity in Plucked Strings.” IEEE Transactions on Speech and Audio Processing 8(3), 300–310.
-
Rocchesso, D. & Smith, J.O. (1997). “Circulant and Elliptic Feedback Delay Networks for Artificial Reverberation.” IEEE Transactions on Speech and Audio Processing 5(1), 51–63.
-
Bank, B. & Sujbert, L. (2005). “Generation of Longitudinal Vibrations in Piano Strings: From Physics to Sound Synthesis.” Journal of the Acoustical Society of America 117(4), 2268–2278.