@maruaudio/dsp/filters/envelope-filter is a low-pass whose cutoff follows the input level. A peak @maru/dynamics-envelope-follower detects the input before filtering, and its linear value e sweeps the base cutoff by a signed number of octaves, fc = clamp(cutoff·2^(e·amount), 20 Hz, 0.45 × rate). The cutoff drives a low-pass @maru/filters-state-variable. Positive amounts open on louder input; negative amounts close.
const state = initEnvelopeFilterNode(48000)
setEnvelopeFilterEnvelopeAmount(state, 2)
const y = envelopeFilterNodeTick(state, x)Parameters
| Setter | Range the setter enforces | Default | Unit |
|---|---|---|---|
setEnvelopeFilterCutoff | 20 Hz to 0.45 × the sample rate | 400 | Hz |
setEnvelopeFilterResonance | The SVF Q clamp, 0.025 to 40 | 0.7071 | Q |
setEnvelopeFilterEnvelopeAmount | −8 to +8 | 4 | octaves at full envelope |
setEnvelopeFilterResponse | 0.0001 to 2; sets the follower attack and release alike | 0.03 | s |
The follower clamps its release to at least 0.001 s, so the shortest response gives a 0.0001 s attack and a 0.001 s release.
Lifecycle
initEnvelopeFilterNode(sampleRate) → setters → envelopeFilterNodeTick → resetEnvelopeFilterNode. The resonance setter refreshes the SVF coefficients at once. The tick refreshes them only when the derived cutoff changes, so settled input costs one envelope step and one SVF tick. Reset clears the detector and filter histories, restores the base cutoff and keeps the controls. There is no prepare step; create a new state for another rate.
When to use it
An auto-wah or touch-sensitive filter on bass, guitar or a synth line, where playing harder opens or closes the tone.
Limits
- Mono. A stereo caller creates one state per lane; nothing here links them.
- The detector receives the magnitude of the input with NaN and infinities replaced by 0; the filter receives the original sample.
- No cutoff smoothing beyond the follower's own one-pole ballistics.