@maruaudio/dsp/modulation/phaser sums four swept first-order allpass sections against the dry signal. Each section is H(z) = (a + z⁻¹)/(1 + a·z⁻¹) with one f32 history value, and the coefficient is prewarped so the swept frequency is the section's −90° point:
f = base × 2^(octaves × depth × (0.5 + 0.5 sin 2π·phase))
a = (tan(π·f/rate) − 1)/(tan(π·f/rate) + 1), f clamped to 1 Hz … 0.45 × rate
y = fround(x × (1 − mix) + allpass⁴(x + feedback × previous) × mix)Parameters
| Setter | Range the setter enforces | Default |
|---|---|---|
setPhaserRate | 0.01 to 10 Hz | 0.5 Hz |
setPhaserDepth | 0 to 1 | 1 |
setPhaserBaseFrequency | 20 to 2000 Hz | 350 Hz |
setPhaserOctaves | 0.5 to 6 octaves of sweep | 3 |
setPhaserMix | 0 to 1 | 0.5 |
setPhaserFeedback | −0.75 to 0.75; NaN → 0 | 0 |
setPhaserPhaseOffset | −180 to 180 degrees, NaN → 0, stored as 0 to 1 cycles | 0° |
A phase-offset change moves the running phase by the difference from the previous offset; repeating the same offset changes nothing.
Lifecycle
initPhaserNode allocates the four-value history once → setters → phaserNodeTick → resetPhaserNode, which clears the histories and the feedback value and restores the phase to the offset, keeping parameters. phaserAllpassCoefficient and phaserAllpassStageTick are exported for other allpass banks. Each tick calls pow and tan once.
When to use it
Swept phase movement on keys, guitar or pads. Paired states with a phase offset give two stereo lanes from one rate.
Limits
- Mono sample tick; one state per channel.
- At zero feedback the arithmetic is the original four-stage path, byte for byte.
- The sweep is recomputed every sample with no smoothing of the controls.
- The clamps are the kernel node's conditional clamp, except feedback and phase offset, which map NaN to 0.