Karplus–Strong: A Plucked String Made From a Delay
Short answer: Fire a tiny burst of noise into a very short echo that feeds back into itself. The echo repeats so fast that you stop hearing repeats and hear a note. Put a filter in the loop that dulls the sound a little on every trip, and the note starts bright and dies away dark, like a plucked string. No recording and no tone generator are involved.
The trick, step by step
- Make a very short burst of noise. This is the pluck.
- Send it into a delay, which is a box that plays back whatever went in a moment later.
- Take what comes out, dull it slightly with a filter, turn it down a touch, and feed it back into the delay.
- Let it go round and round.
Wikipedia describes the original the same way: the excitation "was a burst of white noise", it is "fed back into a delay line", and the output "is fed through a filter" on the way back in. It adds one rule: the filter's gain "must be less than 1 at all frequencies". In plain words, every trip has to come back a little quieter. Otherwise the loop grows until it howls.
Why an echo turns into a note
With a slow echo you hear separate repeats. Shorten the delay and the repeats bunch closer together. Make it short enough that the sound goes round hundreds of times a second, and your ear gives up counting. It hears a pitch.
So the length of the loop is the note. A shorter loop gives a higher note and a longer loop gives a lower one. This still seems slightly magical to me: nothing in the setup knows what a note is.
Why it sounds like a string
The filter does it. On each trip it takes a little more off the top than off the bottom. The note starts bright, because the noise burst has everything in it, and then darkens as it fades.
There is also no steady part. The sound is dying from its first instant. Nothing holds it up, so it can never turn into a drone.
Who came up with it
According to Wikipedia, "Alexander Strong invented the algorithm, and Kevin Karplus did the first analysis of how it worked", and their paper came out in 1983. I find it cheering that one of the best-known tricks in computer sound is this small.
Where I used it, and what I had to fix
The pluck is one of the melody sounds in Space. It is the only sound in the app that works by imitating how a physical thing behaves. Everything else is stacked plain tones or filtered noise.
It did not work the first time. Three things went wrong.
- It twanged. The first version sounded like a bright steel string, which had no business among slow drifting sounds. I made the loop dull the sound much harder and softened the noise burst before it goes in. Now it's low and rounded, closer to a soft thump that has a pitch.
- It clicked. I was switching the burst on instantly, and an instant jump in loudness is a click. Fading the burst in over a few thousandths of a second removed it. The same thing bit me in other sounds: why a fast start becomes a click.
- High notes came out wrong. In a browser the loop can't be shorter than one small chunk of audio, so there is a ceiling on how high a pluck can go. I drop any note above it by an octave until it fits. The full story is in the 128-sample floor.
Space is one of the two paid worlds, so the pluck isn't in the free part.
Sources
Try it: Open Ambient Sound Online and start with Ocean, which is free. The pluck lives in Space, which a one-time payment unlocks together with Forest.
Open Ocean, free