Blog / Sound Design

Karplus-Strong: How a Ring Buffer Became the World's Most Elegant String Synthesizer

Karplus-Strong: How a Ring Buffer Became the World's Most Elegant String Synthesizer
Photo by Brett Jordan on Unsplash

In 1983, Kevin Karplus and Alex Strong published a plucked-string synthesis algorithm that required no acoustic modeling knowledge, no physical equations, and almost no computation. You initialize a short buffer with white noise, feed it back through a two-point average, and it sounds like a guitar. The algorithm fits in about fifteen lines of C. The reason it works took another four years to fully explain.

The Algorithm in Three Parts

Create a delay line of N samples, where N = sample_rate / desired_frequency. Fill it with white noise. At each sample tick, output the first sample, then replace it with the average of itself and the next sample, and advance the read pointer.

That is the complete Karplus-Strong algorithm. Here is the core loop:

float karplus_strong_tick(std::vector<float>& buf, int& pos) {
    int N = buf.size();
    int next = (pos + 1) % N;
    float out = buf[pos];
    buf[pos] = 0.5f * (buf[pos] + buf[next]);
    pos = next;
    return out;
}

For a 440 Hz note at 44100 Hz sample rate, N = 44100 / 440 = 100 samples, roughly 2.3 milliseconds of audio. The white noise burst is the pluck excitation. Everything after that is the averaging filter working on the recirculating buffer.

Why It Sounds Like a String

The two-point averaging is a linear-phase FIR lowpass filter with transfer function H(z) = (1 + z^-1) / 2. Its magnitude response attenuates high frequencies more aggressively than low ones. Apply that filter once per period and the harmonics decay at different rates: the higher the harmonic, the more the averaging attenuates it, the faster it disappears.

This mirrors what happens in a real string. When you pluck a guitar string, the initial displacement contains energy across many harmonics. High partials decay quickly because of frequency-dependent internal friction and how the string couples to the bridge saddle. Karplus-Strong does not model any of this physics explicitly. It reproduces the same perceptual result with one add and one shift per sample.

The decay rate of the n-th harmonic scales approximately as p^3 / n^2, where p is the delay line length in samples. For a 440 Hz tone at 44100 Hz, the 10th harmonic decays roughly 100 times faster than the fundamental. The sound gets duller as it sustains, exactly like an acoustic string.

The Pitch Problem

There is a constraint: N must be an integer. At 44100 Hz you can synthesize 441 Hz (N = 100) or 436 Hz (N = 101), but nothing in between. For higher pitches the delay line gets short enough that one sample represents tens of cents. A naive implementation plays noticeably out of tune at the top of a keyboard.

David Jaffe and Julius O. Smith III solved this in their 1983 paper "Extensions of the Karplus-Strong Plucked-String Algorithm," published in the same volume of Computer Music Journal. A first-order allpass filter inserted in the feedback loop introduces fractional delay without affecting the magnitude spectrum. By choosing its single coefficient, you tune the loop's effective delay to any value, not just integers. Pitch accuracy across five octaves becomes a fraction of a cent.

The extensions paper also introduced the stretch parameter, which weights the two-point average asymmetrically:

y[n] = (1 - S) * buf[n - N] + S * buf[n - (N+1)]

Where S between 0 and 1 shifts the lowpass filter's effective cutoff, altering how quickly brightness decays. A higher S makes the string duller and longer. Lower values give a brighter, shorter decay. This one parameter covers the timbral range from nylon classical guitar to steel-string mandolin.

Six Filters for One String

The Extended Karplus-Strong is not a single enhancement but a cascade of six independent filters, each modeling one physical property of a plucked string:

Pick-position comb filter: A string plucked at its midpoint excites only odd harmonics. Plucking at one-quarter of the string length cancels the fourth harmonic and its multiples. A comb filter with delay equal to the pluck position replicates this accurately and lets you sweep the plucking point in real time.

Pick-direction lowpass filter: Plucking toward the body produces a brighter attack than pulling away from it. One-pole IIR filter, coefficient set at note onset.

String stiffness allpass filter: Real strings are not perfectly flexible. Their upper harmonics are slightly sharp compared to integer multiples of the fundamental, a property called inharmonicity. Higher strings on a piano exhibit this noticeably. A second-order allpass filter in the loop introduces frequency-dependent phase shift that recreates the effect.

String-tuning allpass filter: The fractional delay allpass mentioned above for pitch accuracy.

String-damping filter: A pole-zero filter modeling overall energy loss per period, separately controllable from the decay shape set by the averaging.

Dynamic-level lowpass filter: Softer playing produces a duller attack. This filter's cutoff is set proportional to note velocity at onset.

Each filter runs once per period at the feedback loop rate, not once per output sample. A 440 Hz string at 44100 Hz applies its full filter chain 440 times per second, not 44100. The full Extended Karplus-Strong synthesizer ran in real time on hardware available in 1983.

The Wave Equation Connection

The reason the algorithm works at all went unexplained for four years. Karplus and Strong knew it produced plausible output. They did not claim a physical model.

In 1987, Julius O. Smith III published a technical report at Stanford's CCRMA (STAN-M-39) showing that the Karplus-Strong algorithm is a special case of digital waveguide synthesis. The interpretation reframes the delay line as a model of bidirectional wave propagation along a string. A real string supports two traveling waves moving in opposite directions. In digital waveguide synthesis, you model each direction with a separate delay line. The feedback filter in Karplus-Strong corresponds exactly to the total frequency-dependent loss accumulated per round trip along the string.

This connection makes the algorithm structurally extendable to any physical resonator. The same delay-loop topology, with different filter configurations, models wind instruments, bowed strings, resonant tubes, and percussion membranes. The parameter space maps directly to physical dimensions: delay length to tube length, filter coefficients to material properties.

Modern Implementations

Mutable Instruments Rings, a widely used Eurorack module, is a direct implementation of Smith's digital waveguide model. Its source code is publicly available on GitHub. The synthesis engine contains both a string model derived from the Extended Karplus-Strong structure and a modal resonator bank for stiff objects like plates and bells. The two engines share the same allpass-delay-filter topology, differing in how energy is distributed across modes.

The commercial path of the original algorithm was more complicated. Karplus and Strong patented the algorithm after publication. Stanford later bundled it with over 400 physical modeling patents into the Sondius-XG package and licensed the group to Yamaha in 1989. Yamaha reportedly invested millions and nearly a decade developing commercial applications. Whether any Yamaha hardware actually shipped using Karplus-Strong synthesis specifically is, according to accounts of the deal, unclear.

In the meantime, free software implementations multiplied without license payment. No enforcement followed. The algorithm is now effectively in the public domain through widespread uncontested use, and every modern physical modeling synthesizer owes its architecture to the six-filter chain Jaffe and Smith described in a 1983 journal paper.

Implementing It Today

The minimum viable version is twenty to thirty lines of C++ or Python. The Extended version with fractional delay and pick-position control adds another fifty. Julius O. Smith's book Physical Audio Signal Processing is available free online at the CCRMA website and gives complete derivations for every filter in the chain, including the stiffness allpass coefficients and the comb filter for pluck position.

If you want to start from working production code, the Mutable Instruments Rings source on GitHub shows how the Extended Karplus-Strong structure scales to a polyphonic module with chord modes and per-voice parameter control. The distance from the 1983 Computer Music Journal paper to a shipping hardware product with a million units sold is shorter than most synthesis algorithms manage.