# Karplus-Strong in Faust

## White Tone Oscillator

As explained in the Sound Synthesis Introduction, the Karplus-Strong algorithm is based on a sequence of white noise. The following example uses a feedback structure to create a looped version of a white noise array:

Main components of the above example are the excitation and the resonator. The resonator is a feedback loop with an adjustable delay:

The excitation passes a random sequence to the resonator, once the gate is activated. It will oscillate until the gate is released.

Load the example in the Faust online IDE for a quick start:

// white_tone.dsp
//
// Henrik von Coler
// 2021-07-04

import("all.lib");

// Control parameters:
freq = hslider("freq Hz", 50, 20, 1000, 1) : si.smoo; // Hz
gate = button("gate");

// processing elements for excitation:
diffgtz(x) = (x-x') > 0;
decay(n,x) = x - (x>0)/n;
release(n) = + ~ decay(n);
trigger(n) = diffgtz : release(n) : > (0.0);

P = SR/freq;

// Resonator:
resonator = (+ : delay(4096, P) * gate) ~ _;

// processing function:
process = noise : *(gate : trigger(P)): resonator <: _,_;


## Karplus-Strong in Faust

The Karplus-Strong algorithm for plucked string sounds is explained in detail in the Sound Synthesis Introduction. That implementation is based on a ring buffer with a moving average filter. For the Faust implementation, this example has been adjusted, slightly (Smith, 2007).

### Exercise

Exercise

Extend the White Tone example with a filter in the feedback to turn it into a Karplus-Strong synthesis.