@maruaudio/dsp/delays/saturated-feedback is a tape-style delay core. Each sample reads the whole-frame line, passes the read through a one-pole damping filter (pole exp(−2π·fc/rate), f32), saturates it with the rational approximation tanh(x) ≈ x(27 + x²)/(27 + 9x²) (input clamped to ±3) divided by the drive for unity slope at silence, scales by feedback and writes clamp(x + that, −1, 1) back as f32. The output is x·(1 − mix) + read·mix. Since |saturate(x)| ≤ |x| and feedback is at most 0.95, the loop is bounded.
const state = initSaturatedFeedbackDelayNode(48000, SATURATED_DELAY_MAX_MILLISECONDS)
setSaturatedDelayTime(state, 420)
setSaturatedDelayAge(state, 0.6) // sets the damping pole
const y = saturatedFeedbackDelayNodeTick(state, x)Parameters
| Setter | Range the setter enforces | Default | Unit |
|---|---|---|---|
setSaturatedDelayTime | 1 to 2000 ms, then capped at the line allocated by init | The init time | ms |
setSaturatedDelayFeedback | 0 to 0.95 | 0.55 | linear |
setSaturatedDelayMix | 0 to 1 | 0.35 | linear |
setSaturatedDelayAge | 0 to 1; damping cutoff 7000 − 4600·age Hz | 0.6 | normalized |
setSaturatedDelayDrive | 0.25 to 4, rounded to f32 | 1.6 | linear |
Lifecycle
initSaturatedFeedbackDelayNode(sampleRate, ms) allocates the line once; pass the maximum time and the highest rate to leave room → setters → tick → resetSaturatedFeedbackDelayNode, which zeroes line, index and damping state and keeps the controls. prepareSaturatedFeedbackDelayNodeSampleRate re-derives the length and the damping pole (fixed in Hz) without allocating and keeps history. clearSaturatedFeedbackDelayNodeStep zeroes at most 256 samples per call, returning the line length when done; then call finalize…Clear.
When to use it
Echoes that darken and soften as they repeat, from slapback to long tape-style feedback.
Limits
- Mono, whole-frame delay; a time change jumps the read position.
- A new state reads age 0.6 but has a damping pole of 0 (no damping) until
setSaturatedDelayAgeor prepare runs. - The rational curve saturates to exactly ±1 at
|x| ≥ 3; the browser reference's oversampledtanhis not reproduced.