@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.
| Function | Inputs and coded behavior |
|---|---|
polyBlep(t, dt) | Returns 0 when dt <= 0 or outside the two edge windows |
oscSineSample, oscSawSample, oscSquareSample | Phase 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, rbjAlpha | Hz, rate and Q; cos and sin rounded to f32 |
rbjLowpassB0, rbjLowpassB1, rbjA1, rbjA2 | a0-normalized f32 low-pass coefficients |
biquadOutput, biquadNextZ1, biquadNextZ2 | One 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.
oscAdvancePhasewraps a single cycle, sodtis expected below 1.envelopeCoefficientand the RBJ functions callexp,cosandsin.