@maruaudio/dsp/distortion/oversampled-waveshaper is the shared fixed-4× oversampling stage the kernel's nonlinear DSP nodes use, with a rational tanh approximation as its transfer. Each input sample is linearly interpolated to four points between the previous and current input, each point is shaped and stored at f32, and one output is taken through the fixed 31-tap symmetric FIR WAVESHAPER_FIR over the last 31 shaped points.
fastTanh(x) = x (27 + x²)/(27 + 9x²), x clamped to ±3
shaped = fastTanh(input × (1 + 8 × drive))
y = x × (1 − mix) + FIR(shaped) × outputGain × mix@maru/distortion-drive and @maru/distortion-chebyshev reuse the factor and FIR taps.
Parameters
| Setter | Range the setter enforces | Default |
|---|---|---|
setOversampledWaveshaperDrive | 0 to 1 (pre-gain 1 to 9) | 0.5 |
setOversampledWaveshaperMix | 0 to 1 | 1 |
setOversampledWaveshaperOutputGain | −24 to +12 dB, stored as f32 linear | 0 dB |
Lifecycle
initOversampledWaveshaperNode allocates the 32-value history → setters → oversampledWaveshaperNodeTick → resetOversampledWaveshaperNode, which zeroes the history and marks the state uninitialized. The first tick after init or reset starts the interpolation from the current input, not from 0. Ticks allocate nothing and do no I/O.
When to use it
Saturation on a voice or bus with less aliasing than a direct waveshaper, or as the oversampling stage for another transfer.
Limits
- Mono sample tick. The symmetric FIR delays the wet path by 15 oversampled frames (3.75 samples); the dry path is not delayed, so partial mix values combine misaligned signals.
- The output is a double; only the shaped points are rounded to f32.
- Parameter changes apply at once, with no smoothing.