@maruaudio/dsp/mixing/gain-db scales one sample by a gain set in decibels, with a mute gate: y = mute ? 0 : x × 10^(dB/20). The decibel conversion is @maru/math-decibels (dbToGain), done in the setter; the per-sample multiply is the same double multiply as @maru/mixing-gain.
const state = initGainDbNode(48000)
setGainDbNodeGainDb(state, -12)
const y = gainDbNodeTick(state, x)Parameters
| Setter | Range the setter enforces | Default |
|---|---|---|
setGainDbNodeGainDb | −60 to +24 dB, stored as linear gain | 0 dB (linear 1) |
setGainDbNodeMute | 0 is off, any other value is on | Off |
Lifecycle
initGainDbNode → setters → gainDbNodeTick. There is no reset; the state holds only the linear gain and the mute flag. The setter calls pow, so call it when the level changes, not per sample. Ticks allocate nothing and do no I/O.
When to use it
A channel fader or trim set in decibels, or a level control that also needs a hard mute. At −60 dB the gain is 0.001, not silence; use the mute for silence.
Limits
- Mono sample tick, not a block Processor.
- Gain and mute changes apply at once, with no smoothing or fade.
- The clamp is the kernel node's conditional clamp, not the
math/rangepolicy: a NaN passes through todbToGain.