@maruaudio/dsp/delays/ping-pong is a true ping-pong delay: two fixed whole-frame lines that feed each other. A mono input enters the left line; the left line's output feeds the right and the right's feeds back into the left, so repeats alternate left, right, left. Writes are clamp(x + right·feedback, −1, 1) and clamp(left·feedback, −1, 1), stored as f32. The DSP node is fully wet; the caller owns any dry blend.
const state = initPingPongDelayNode(48000, 0.375)
setPingPongFeedback(state, 0.5)
const l = pingPongDelayLeft(state), r = pingPongDelayRight(state)
pingPongDelayWriteAdvance(state, x) // after readingParameters
| Setter | Range the setter enforces | Default | Unit |
|---|---|---|---|
setPingPongTime | 0.001 to 2 s, at least 1 frame, then capped at the capacity | The init time | s |
setPingPongFeedback | 0 to 0.95 | 0.3 | linear |
Lifecycle
initPingPongDelayNode(sampleRate, seconds, capacitySeconds = 2) allocates both lines at the capacity → setters → per sample, read pingPongDelayLeft and pingPongDelayRight, then pingPongDelayWriteAdvance(state, input) → resetPingPongDelayNode, which zeroes both lines and the index. A time change applies at once, with no interpolation or clear; history stays and the index restarts only if it falls outside the new length. preparePingPongDelayNodeSampleRate re-derives the length within the capacity and keeps history. clearPingPongDelayNodeStep zeroes at most 256 samples per call across left then right, returning their combined length when done; then call finalizePingPongDelayNodeClear.
When to use it
Echoes that bounce across the stereo field from a mono or summed source.
Limits
- Mono in, stereo out, whole-frame delay; one time for both lines.
- The ±1 write bound stops in-phase repeats of a full-scale input from building to
1/(1 − feedback²)on the left line; quiet repeats are unchanged. audio-kernelskeeps the PCM16 interleaved render entry.