@maruaudio/dsp/dynamics/gate is a soft envelope gate: an absolute-value detector, a one-pole smoothed envelope e = c·e + (1 − c)·|x|, a logistic comparator g = 1 / (1 + exp(−60·(clamp(e) − clamp(threshold)))) with both terms clamped to 0 to 1, and a VCA y = x·g. The envelope is rounded to f32. The smoothing coefficient is exp(−1 / (t·rate)) with the gate's own bounds (t 0.0001 to 2 s, rate 8 to 384 kHz).
const state = initGateNode(48000)
setGateThreshold(state, -50)
const y = gateNodeTick(state, x)Parameters
| Setter | Range the setter enforces | Default | Unit |
|---|---|---|---|
setGateThreshold | −100 to 0, stored as an f32 linear gain | −40 | dB |
setGateSmoothing | 0.005 to 0.5 | 0.05 | s |
The logistic steepness is the constant GATE_STEEPNESS (60).
Lifecycle
initGateNode(sampleRate) → setters → gateNodeTick → resetGateNode, which zeroes the envelope and keeps the settings. prepareGateNodeSampleRate re-derives the coefficient from the stored smoothing time without allocating.
When to use it
Quieting the space between notes on a noisy guitar, drum or vocal track. The logistic curve fades the gain around the threshold instead of switching it.
Limits
- Mono sample tick. One smoothing time serves both opening and closing; there is no hold, range floor or lookahead.
- The comparator compares linear levels; at the threshold the gain is 0.5.
- Clamps are the kernel node's conditional clamp, not
@maru/math-range. audio-kernelskeeps the PCM16 render entries.