@maruaudio/dsp/modulation/flanger is a mono flanger: a short sine-modulated fractional delay over @maru/delays-fractional, with signed feedback and a dry/wet mix.
lfo = 0.5 + 0.5 × sin(2π·phase) // 0 to 1
d = (1 ms + depth × lfo) × sampleRate / 1000
wet = read(d); write(x + wet × feedback)
y = fround(x × (1 − mix) + wet × mix)The delay sweeps upward from a fixed 1 ms minimum by the depth in milliseconds.
Parameters
| Setter | Range the setter enforces | Default |
|---|---|---|
setFlangerRate | 0.01 to 20 Hz | 0.5 Hz |
setFlangerDepth | 0 to 10 ms sweep above the 1 ms minimum | 2 ms |
setFlangerFeedback | −0.75 to 0.75 | 0 |
setFlangerMix | 0 to 1 | 0.5 |
setFlangerPhaseOffset | −180 to 180 degrees, stored as 0 to 1 cycles; also sets the phase | 0° |
Lifecycle
initFlangerNode allocates the delay ring (50 ms plus two frames at the init rate; 2,402 frames at 48 kHz) → setters → flangerNodeTick → resetFlangerNode, which clears the line and returns the phase to the offset. clearFlangerNodeStep(state, cursor, budget) clears the line in bounded steps for live replacement, then finalizeFlangerNodeClear resets the write index and phase. Ticks allocate nothing and do no I/O.
When to use it
A swept comb filter on guitars, drums or full mixes. Negative feedback inverts the regenerated signal; two states with phase offsets 180° apart form a phase-locked stereo pair.
Limits
- Mono sample tick; one state per channel.
- There is no sample-rate prepare: create a new state for a new rate.
- The line stores
x + wet × feedbackclamped to ±1 at f32. - Parameter changes apply at once; a phase-offset change jumps the phase.