Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@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 reading

Parameters

SetterRange the setter enforcesDefaultUnit
setPingPongTime0.001 to 2 s, at least 1 frame, then capped at the capacityThe init times
setPingPongFeedback0 to 0.950.3linear

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-kernels keeps the PCM16 interleaved render entry.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Parameters

ParameterTypeSetter
Feedback feedbackfloatsetPingPongFeedback
Seconds seconds

Change the active delay length immediately without interpolation or a state clear. History stays in the prepared lines; if the write index lies outside a newly shorter ring it restarts at zero. Hosts that require a tail-free retune must clear the node through the staged lifecycle below first.

floatsetPingPongTime

Dependencies

None: this node imports no other node.

Dependents

Used by