@maruaudio/dsp/dynamics/stereo-linked computes one gain for both channels of a stereo signal from max(|L|, |R|), with NaN and infinities read as 0. The max link keeps a hard-panned event and cannot cancel anti-phase material. It holds two gain controllers: a linked compressor, which runs @maru/dynamics-keyed-compressor on a unit carrier with the linked magnitude as key, and a hysteretic linked gate, which opens at the threshold, closes 3 dB below it and smooths its 0 or 1 state through @maru/dynamics-envelope-follower. The caller multiplies both channels by the returned gain.
const comp = initLinkedCompressor(48000)
const g = linkedCompressorGainTick(comp, left, right)
outL = left * g; outR = right * gParameters
| Setter | Range the code applies | Default | Unit |
|---|---|---|---|
setLinkedCompressorParameters(state, threshold, ratio, attack, release) | Keyed-compressor clamps: −80 to 0 dB, 1 to 1000, 0 to 1 s, 0.001 to 10 s | −24 dB, 4, 0.01 s, 0.1 s | dB, ratio, s |
setLinkedCompressorMakeup | −24 to +36 | 0 | dB |
setLinkedGateParameters(state, threshold, attack, release) | Threshold −80 to 0; follower attack 0.0001 to 2 s, release 0.001 to 10 s | −40 dB, 0.01 s, 0.1 s | dB, s |
setLinkedGateHold | 0 to 0.5, stored as whole samples | 0 | s |
The compressor's knee is fixed at 6 dB with peak detection and a unity mix.
Lifecycle
initLinkedCompressor or initLinkedGate → setters → linkedCompressorGainTick or linkedGateGainTick per stereo sample → resetLinkedCompressor or resetLinkedGate, which clear history and keep the settings. Gate hold counts down only while the level is below the close threshold; a new open sample retriggers the full count.
When to use it
Compressing or gating a stereo bus without the image shifting when only one side gets loud.
Limits
- Gain only: no output buffer, dry mix or lookahead. The gate never adds gain.
- The gate's hysteresis window is the constant
LINKED_GATE_HYSTERESIS_DB(3).