@maruaudio/dsp/delays/reverse-delay plays each completed window of input backwards while the next window records. At window position p it reads the caller-owned @maru/delays-fractional ring 2p + 1 samples back, so the read walks backwards through the previous window. A Hann fade, 0.5 − 0.5·cos(π·d/fade) within fade samples of either window edge, suppresses splice clicks. The write is clamp(x + wet·feedback, −1, 1). It is wet only.
const state = initReverseDelay(48000)
configureReverseDelay(state, 250, 0.3, 5, 0)
reverseDelayTick(state, ringL, ringR, left, right) // state.outLeft, state.outRightParameters
configureReverseDelay(state, windowMs, feedback, fadePercent, outputDb); a non-finite value takes the default, then clamps.
| Argument | Range the code applies | Default | Unit |
|---|---|---|---|
windowMs | 20 to 500, rounded to frames | 100 | ms |
feedback | 0 to 0.75 | 0 | linear |
fadePercent | 1 to 25 % of the window, at least 1 frame | 5 | % |
outputDb | −24 to 0 | 0 | dB |
Lifecycle
initReverseDelay(sampleRate) (8 to 192 kHz, NaN gives 48 kHz) and the two rings are created outside processing → configureReverseDelay → reverseDelayTick(state, lineLeft, lineRight, left, right) → resetReverseDelay, which restarts the window and clears the outputs. The caller owns the rings' reset and clear, configuration fades and the dry/wet blend. Ring capacity must be at least 2 × window + 2 samples.
When to use it
Backwards swells and reversed echoes on a guitar, vocal or drum part, in time with a window length.
Limits
- Stereo, wet only. Edge fades mean it is not gapless file reversal.
- Input is bounded to ±16 (NaN 0) before the write clamp.
- A window change restarts the position only if it falls outside the new window.