@maruaudio/dsp/dynamics/keyed-compressor is a feed-forward, log-domain compressor with a sidechain key: optional detector filters, peak or RMS level in dB, a quadratic soft-knee gain computer (Giannoulis, Massberg and Reiss, JAES 2012), one-pole smoothing of the reduction with an integer hold, a range ceiling and a dry/wet mix. Ratio 1000 is the limiter sentinel. It also exports the auto-makeup, stereo link and crest-factor auto-release laws.
const state = initDynamicsCompressorNode(48000)
updateDynamicsCompressorBlock(state) // once per block
const y = dynamicsCompressorNodeTick(state, x, key) // key = x for internalParameters
Setters are setDynamicsCompressor<Name>(state, value).
| Name | Range the setter enforces | Default | Unit |
|---|---|---|---|
Threshold / Ratio / Knee | −80 to 0 dB / 1 to 1000 / 0 to 72 dB | −18 / 4 / 6 | dB, ratio |
Attack / Release | 0 to 1 (0 instantaneous) / 0.001 to 10 | 0.005 / 0.08 | s |
Hold | 0 to 0.5, stored as whole samples; suspends release only | 0 | s |
Range | 0 to 60, ceiling on the applied reduction | 60 | dB |
Makeup / Mix | −24 to +36 dB / 0 to 1 | 0 / 1 | dB, linear |
DetectorMode / RmsWindow | ≥ 1 RMS, else peak / 0.0005 to 0.2 s | Peak / 0.010 | mode, s |
DetectorHp / DetectorLp | 20 to 2000 Hz, off at 20 / 200 to 20000 Hz, off at 20000 | Off / Off | Hz |
AutoRelease | ≥ 1 on | Off | flag |
Lifecycle
initDynamicsCompressorNode(sampleRate) → setters → updateDynamicsCompressorBlock once per block (makeup and release coefficient, from the crest state with auto-release) → dynamicsCompressorNodeTick(state, input, key) → resetDynamicsCompressorNode, which clears history and keeps the settings. prepareDynamicsCompressorNodeSampleRate re-derives rate values.
When to use it
Bus or channel compression, or ducking one signal under a key such as a kick.
Limits
- Mono with one key input; a zero key gives no reduction, so an unpatched sidechain is bypass. Stereo linking is the caller's.
Math.expruns only at block rate; per sample,log,powand, in RMS mode,sqrt. Reduction, RMS and crest states are f32; detector filters at their defaults are skipped.