Build with this node

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

Ask Studio

@maruaudio/dsp/voices/stages holds the per-sample operations of the G1 subtractive voice as separate stateless functions: a PolyBLEP residual and sine, saw, square and triangle oscillator samples, phase advance, a one-pole envelope coefficient and step with shared stage thresholds, and the RBJ low-pass coefficients and transposed direct form II biquad steps. The source header states that the voice and the standalone node kernels call these same functions, so the two cannot drift apart. Math.fround is applied at every stateful accumulation and at each biquad coefficient; intermediates stay double.

Parameters

This DSP node has no setters; each function takes its inputs as arguments.

FunctionInputs and coded behavior
polyBlep(t, dt)Returns 0 when dt <= 0 or outside the two edge windows
oscSineSample, oscSawSample, oscSquareSamplePhase in cycles, dt = frequency / rate for the blepped shapes
oscTriangleNext(tri, phase, dt)Leaky integration of the blepped square, × 0.999 per step
oscAdvancePhase(phase, dt)f32 accumulation, wraps once by subtracting 1
envelopeCoefficient(time, rate)Time floored at 0.0001 s; τ = time / 4.6
envelopeMoveToward(level, target, c)One f32 exponential step
rbjW0, rbjCos, rbjSin, rbjAlphaHz, rate and Q; cos and sin rounded to f32
rbjLowpassB0, rbjLowpassB1, rbjA1, rbjA2a0-normalized f32 low-pass coefficients
biquadOutput, biquadNextZ1, biquadNextZ2One TDF2 output and the two state updates

Thresholds: ENV_ATTACK_DONE 0.999, ENV_SUSTAIN_EPSILON 0.001, ENV_RELEASE_DONE 0.0005, shared with the standalone ADSR.

Lifecycle

None: there is no init or reset. The caller owns phase, the triangle integrator, envelope level and the two biquad state words.

When to use it

Build a voice that must match the subtractive voice sample for sample, or a node kernel that exposes one of its stages. For a complete mono voice use @maru/voices-subtractive; for the extended RBJ filter family use @maru/filters-biquad.

Limits

  • Mono, one sample per call; only the low-pass coefficient set is here.
  • oscAdvancePhase wraps a single cycle, so dt is expected below 1.
  • envelopeCoefficient and the RBJ functions call exp, cos and sin.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Dependencies

None: this node imports no other node.

Dependents

Used by