Build with this node

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

Ask Studio

@maruaudio/dsp/delays/primitives holds the three stateless operations the chain's fixed delay performs, shared with @maru/delays-feedback and @maru/delays-bounded so they cannot diverge:

  • delayFrameCount(ms, rate): max(1, round(ms·rate/1000)) whole frames.
  • delayDryWetMix(dry, delayed, mix): dry·(1 − mix) + delayed·mix.
  • delayFeedbackWrite(dry, delayed, feedback): clamp(dry + delayed·feedback, −1, 1), the value to store back into the line.
const frames = delayFrameCount(250, 48000) // 12000
const y = delayDryWetMix(x, line[i], 0.5)
line[i] = delayFeedbackWrite(x, line[i], 0.4) // Float32Array store

Parameters

This DSP node has no setters or state; every value is passed to the function. None of the three clamps its mix or feedback argument; the write clamps its result to −1 to 1.

Lifecycle

There is no instance state. The caller owns the delay line, its index and its reset. Call delayFrameCount when time or rate changes, and the mix and write once per sample.

When to use it

Building a fixed echo, slapback or simple feedback delay that must match the chain's arithmetic byte for byte.

Limits

  • Double-precision arithmetic; f32 quantization happens only in the caller's Float32Array store.
  • The write clamp is a conditional clamp, not @maru/math-range, so a NaN passes through it.
  • Whole-frame lengths only; fractional delays belong to @maru/delays-fractional.

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.

4 Lean 4 results: 4 proofs in exact arithmetic.

Proved in exact arithmetic.The dry/wet sum and the subtract-then-scale interpolation form are algebraically equal.Exact rational samples and mix coefficient
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. Exact rational arithmetic only: IEEE rounding, overflow, NaN, infinities and signed-zero behavior are not proved. Sampler mappings cover the named shared stage only. No optimization is enabled or claimed faster. This does not authorize changing the existing floating-point operation order.
Theorem
MaruLean.LeafContracts.drywet_is_lerp
Recorded axioms
propext, Classical.choice, Quot.sound
Manifest reviewed
Proved in exact arithmetic.A dry/wet mix stays inside the common input interval for a mix between zero and one.Exact rationals; ordered finite bounds and stated coefficient guards; mix in [0, 1]
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. Exact rational arithmetic only: IEEE rounding, overflow, NaN, infinities and signed-zero behavior are not proved. Sampler mappings cover the named shared stage only. No optimization is enabled or claimed faster.
Theorem
MaruLean.LeafContracts.drywet_bounded
Recorded axioms
propext, Classical.choice, Quot.sound
Manifest reviewed
Proved in exact arithmetic.The clamped feedback write is between minus one and one in exact arithmetic.Exact rational dry sample, delayed sample and feedback
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. Exact rational arithmetic only: IEEE rounding, overflow, NaN, infinities and signed-zero behavior are not proved. Sampler mappings cover the named shared stage only. No optimization is enabled or claimed faster. This covers only the write stage, not feedback-system stability.
Theorem
MaruLean.LeafContracts.feedback_write_bounded
Recorded axioms
propext, Classical.choice, Quot.sound
Manifest reviewed
Show 1 more Lean 4 results
Proved in exact arithmetic.At zero feedback the write stage is exactly the clamped dry sample.Exact rational dry and delayed samples; feedback = 0
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. Exact rational arithmetic only: IEEE rounding, overflow, NaN, infinities and signed-zero behavior are not proved. Sampler mappings cover the named shared stage only. No optimization is enabled or claimed faster.
Theorem
MaruLean.LeafContracts.feedback_zero
Recorded axioms
propext, Classical.choice, Quot.sound
Manifest reviewed
Explore proofs alongside performance

Dependencies

None: this node imports no other node.

Dependents

Used by