Build with this node

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

Ask Studio

@maruaudio/dsp/delays/alignment delays a signal by an exact whole number of frames, y[n] = x[n − frames], with no clipping, interpolation or feedback. It exists to line up a dry carrier with a parallel path that has latency, such as a lookahead limiter, and keeps over-unity samples intact. The line is a Float32Array, so stored samples round to f32.

const state = initAlignmentDelay(maxFrames) // control thread
prepareAlignmentDelay(state, lookaheadLimiterLatencySamples(2, 48000))
const dry = alignmentDelayTick(state, x)

Parameters

There are no setters. The capacity is passed to init and the active length to prepare.

CallAcceptsDefaultUnit
initAlignmentDelay(maximumFrames)Rounded up, at least 1—frames
prepareAlignmentDelay(state, frames)Whole numbers from 0 to the capacity; anything else returns false and changes nothing0 (pass-through)frames

Lifecycle

initAlignmentDelay allocates the line once → prepareAlignmentDelay validates the length and clears the line → alignmentDelayTick per sample → resetAlignmentDelay, which zeroes the line and position and keeps the length. Prepare and reset belong on the control thread. With 0 frames the tick returns its input unchanged.

When to use it

Keeping a dry/wet mix phase-coherent when the wet path adds a known delay. The Voice Talk module derives its length from its prepared limiter.

Limits

Implementations

Rust Output verified: The build passed and its output matches the reference implementation.

Verified on Apple Silicon macOS native and Node WASM with 0, 1, 2, 127 and 2048 frame delays; this node has no sample-rate parameter. Output and state match the TypeScript reference, with no observed allocations, reallocations or deallocations during the tested processing, control and reset calls. Boolean preparation results and unchanged state after invalid preparations were checked. Browser hosts, plugins, other operating systems and realtime deadlines have not been verified. Performance has not been measured.

View target checks and scope

Algorithm properties and proofs

Lean 4 checks specific properties of this algorithm’s mathematical model. Each model result applies within its stated domain and assumptions.

3 Lean 4 results: 2 proofs in their stated domains; 1 counterexample.

Proved in the stated domain.Advancing a ring cursor by compare-and-reset produces an index below every positive active length.Natural-number cursor and positive active length
Limits and assumptions
  • Hand-written source-reviewed model, not formal refinement of TypeScript or compiled code. Named functions and whole-file source digests are checked; finite canonical JavaScript cases are compared with executable Lean definitions. Integer addresses must be valid, nonnegative and exactly representable; validated region and arena assumptions are explicit. Sampler mapping covers only its delegated indexing/interpolation stage, not voice lifecycle, arena ownership or the whole renderer. The read before this update still needs a valid initial cursor and allocated capacity.
Theorem
MaruLean.LeafContracts.ring_step_in_bounds
Recorded axioms
propext, Quot.sound
Manifest reviewed
Proved in the stated domain.The final active ring position advances to zero.Natural-number positive active length
Limits and assumptions
  • Hand-written source-reviewed model, not formal refinement of TypeScript or compiled code. Named functions and whole-file source digests are checked; finite canonical JavaScript cases are compared with executable Lean definitions. Integer addresses must be valid, nonnegative and exactly representable; validated region and arena assumptions are explicit. Sampler mapping covers only its delegated indexing/interpolation stage, not voice lifecycle, arena ownership or the whole renderer.
Theorem
MaruLean.LeafContracts.ring_step_last
Recorded axioms
propext, Quot.sound
Manifest reviewed
Counterexample.An empty active ring has no valid in-range cursor, even when compare-and-reset returns zero.One zero-length integer witness
Limits and assumptions
  • Hand-written source-reviewed model, not formal refinement of TypeScript or compiled code. Named functions and whole-file source digests are checked; finite canonical JavaScript cases are compared with executable Lean definitions. One concrete witness; it refutes the stated unrestricted claim, not every possible guarded implementation. Alignment deliberately bypasses its buffer when frames is zero; this is not a claim that its bypass is unsafe.
Theorem
MaruLean.LeafContracts.ring_empty_refuses_bound
Manifest reviewed
Explore proofs alongside performance

Ports

  • In ininput · audio · mono
  • Out outoutput · audio · mono

One sample per alignmentDelayTick call.

Dependencies

None: this node imports no other node.

Dependents

No other node imports this one.

Used by