@maruaudio/dsp/mixing/gain multiplies one sample by a bounded linear gain: y = x × gain, a double multiply with no rounding of its own. Channel count belongs to the caller: a stereo caller runs the tick once per channel against one shared state.
const state = initGainNode(48000)
setGainNodeGain(state, 2)
const y = gainNodeTick(state, 0.3) // 0.6Parameters
| Setter | Range the setter enforces | Default |
|---|---|---|
setGainNodeGain | 0 to 4 (linear) | 1 |
The sample rate passed to initGainNode is stored and not read.
Lifecycle
initGainNode → setGainNodeGain → gainNodeTick. There is no reset; the state holds only the parameter. Ticks allocate nothing and do no I/O.
When to use it
An output level, a fixed trim or a send amount set as a linear factor. For a level set in decibels with a mute, use @maru/mixing-gain-db; for a gain driven by a control signal, use @maru/mixing-control-gain.
Limits
- Mono sample tick, not a block Processor.
- No negative gain: polarity inversion is not available here.
- Gain changes apply at once, with no smoothing.
- The clamp is the kernel node's conditional clamp, not the
math/rangepolicy: a NaN passes through unchanged.