A wavefolder
Distortion that folds instead of clipping.
Anyone who has run out of things to do with a lowpass.
A clipper stops a waveform at a boundary. A wavefolder reflects it back inward. As the input grows, more of the wave crosses the boundary and bends back, adding corners and therefore harmonics.
This patch applies three reflections in sequence. Its compact shape makes it easy to follow one sample by hand before listening to a whole signal.
Controls#
| Parameter | Default | Range | Meaning |
|---|---|---|---|
fold | 3.2 | 1–12 | Gain applied before the reflections. More gain drives more folding. |
level | 0.7 | 0–1 | Gain applied after the three stages. |
Both endpoints are mono. Begin with a quiet sine and a low output level; the three-stage folder is not a limiter for arbitrarily large inputs.
The complete patch#
processor Fold
{
input stream float in;
param float fold = 3.2f [1.0f, 12.0f] smooth 20.0f;
param float level = 0.7f [0.0f, 1.0f] smooth 20.0f;
output stream float out;
void main()
{
loop
{
let a = in * fold;
let a1 = a > 1.0f ? 2.0f - a : (a < -1.0f ? -2.0f - a : a);
let a2 = a1 > 1.0f ? 2.0f - a1 : (a1 < -1.0f ? -2.0f - a1 : a1);
let a3 = a2 > 1.0f ? 2.0f - a2 : (a2 < -1.0f ? -2.0f - a2 : a2);
out <- a3 * level;
advance();
}
}
}Follow one sample#
First the input is multiplied by fold. At each stage, a value above 1 is
reflected with 2 - x, while a value below -1 is reflected with -2 - x.
Values already inside the interval pass through.
For example, 1.4 becomes 0.6 at the first stage. A larger value may cross the
opposite boundary and need the next stage. Three stages handle three such
reflections; they do not keep every possible input inside -1…1. The final
level control scales the result from silence to its full processed level;
it does not guarantee that the folding stages themselves stay inside -1…1.
Try it#
Use a sine, set fold to 1 and increase it slowly. Listen for added brightness
as the peaks begin to fold. Reduce level as needed so a louder result does
not mask the change in tone.
This is a nonlinear effect and can alias, especially with bright or high-pitched input. For guaranteed output bounds add a deliberate output clamp; for cleaner high-frequency behaviour a fuller design needs an anti-aliasing strategy.
Next: the effects chain.