@maruaudio/dsp/dynamics/stereo-expander is a linked downward expander on the finite max(|L|, |R|) peak of @maru/dynamics-stereo-linked (−240 dB floor). Below the threshold it attenuates by (threshold − level)·(ratio − 1) dB, joined to unity by a quadratic knee with continuous value and slope. The linear gain is smoothed by a branching one-pole (attack opens, release closes), rounded to f32, and returned for the caller to apply to both channels.
const state = initStereoExpander(48000)
setStereoExpanderRatio(state, 3)
const g = stereoExpanderGainTick(state, left, right)Parameters
Each setter replaces a non-finite value with the fallback shown, then clamps.
| Setter | Range the setter enforces | Default (fallback) | Unit |
|---|---|---|---|
setStereoExpanderThreshold | −80 to 0 | −40 (−40) | dB |
setStereoExpanderRatio | 1 to 20; 1 is exact unity | 2 (1) | ratio |
setStereoExpanderKnee | 0 to 72 (full width) | 6 (0) | dB |
setStereoExpanderAttack | 0 to 1; governs opening | 0.01 (0.01) | s |
setStereoExpanderRelease | 0.001 to 10; governs closing | 0.1 (0.1) | s |
setStereoExpanderParameters sets four at once; downwardExpansionReductionDb is the static curve.
Lifecycle
initStereoExpander(sampleRate) (rate bounded to 8 to 384 kHz, NaN gives 48 kHz) → setters → stereoExpanderGainTick → resetStereoExpander, which returns the gain to unity and keeps controls and coefficients. There is no prepare step.
When to use it
Lowering room noise, bleed or tails between phrases on a stereo source, in proportion to how far below the threshold they fall.
Limits
- Gain only, linked. No hysteresis, range floor, hold, detector filter, mix, lookahead or latency. One attack time from silence reaches about 63 %.