@maruaudio/dsp/modulation/lfo is a low-frequency oscillator run at audio rate as a modulation signal: y = offset + depth × wave, rounded to f32. The waveforms are the voice oscillator stages of @maru/voices-stages, the same functions the audio oscillator calls: sine, PolyBLEP saw, PolyBLEP square and a leaky-integrated triangle.
const state = initLfoNode(48000)
setLfoNodeRate(state, 5)
setLfoNodeDepth(state, 0.5)
const m = lfoNodeTick(state)Parameters
| Setter | Range the setter enforces | Default |
|---|---|---|
setLfoNodeWaveform | Rounded, then 0 to 3: sine, saw, square, triangle | Sine |
setLfoNodeRate | 0 to 40 Hz | 1 Hz |
setLfoNodeDepth | 0 to 1 | 1 |
setLfoNodeOffset | −1 to 1 | 0 |
Lifecycle
initLfoNode → setters → lfoNodeTick → resetLfoNode. Reset zeroes the phase and the triangle integrator and keeps the settings. Setters do not touch the phase, so a rate change continues from where the wave is. Ticks allocate nothing and do no I/O.
When to use it
A repeating control for vibrato, tremolo, filter sweeps or panning, routed into another DSP node's parameter. The offset and depth place the swing, so offset 0.5, depth 0.5 gives a 0 to 1 control from a bipolar wave.
Limits
- Mono sample tick, no input; the rate is read on every tick with no smoothing.
- The phase accumulator is f32 and wraps into [0, 1).
- The triangle is a leaky integrator (× 0.999 per sample) of the square that starts from zero after init or reset.
- The clamps are the kernel node's conditional clamp; a NaN passes through.