@maruaudio/dsp/distortion/wavefolder ports the DaisySP Wavefolder: the offset is added before a signed gain, then each two-unit interval of the result is reflected through a triangle fold, in f32 order.
v = (x + offset) × gain
n = floor((v + 1)/2)
y = (n even ? 1 : −1) × (v − 2n) // always within ±1Parameters
| Setter | Range (clampFiniteWithFallback) | Fallback | Default |
|---|---|---|---|
setWavefolderGain | −32 to 32; negative gain folds through zero | 1 | 1 |
setWavefolderOffset | −1 to 1 | 0 | 0 |
Lifecycle
initWavefolderNode() (no sample rate) → setters → wavefolderNodeTick. There is no signal history: resetWavefolderNode does nothing and keeps gain and offset, so a reset render equals a newly configured state. Ticks allocate nothing and do no I/O.
When to use it
Folding a synth oscillator or a bass to add harmonics, with gain as the fold depth and offset for asymmetric folds. For a filtered, trimmed output with the DC removed, use @maru/distortion-voiced-wavefolder.
Limits
- Mono sample tick, wet only, no oversampling: the fold deliberately aliases.
- A non-zero offset produces DC, including on silence.
- The transformed value is clamped to ±524,288 (non-finite → 0) before the parity step, which keeps the behaviour finite without changing source parity in the normal domain.