@maruaudio/dsp/voices/unison lays out a stack of detuned copies of an oscillator: a symmetric cent detune across the lanes, equal-power stereo positions, and 1/count gain normalization that bounds the coherent peak. It owns no oscillator. The instrument reads each lane's ratio, left and right, keeps its own phases, envelopes and note allocation, and chooses the smoothing time. Layout changes glide lane by lane through a one-pole step, and removed lanes fade before the active bound contracts.
Parameters
configureUnison(state, voices, detuneCents, spread) returns false and changes nothing if any argument is non-finite.
| Argument | Clamp as coded | Default | Unit |
|---|---|---|---|
voices | Rounded, 1 to the state's capacity | 1 | lanes |
detuneCents | 0 to 100 (UNISON_MAX_DETUNE); the outer lanes' ± offset | 20 | cents |
spread | 0 (mono) to 1 (full width) | 1 | — |
coefficient of tickUnison | Caller supplies 0 to 1; not clamped | — | — |
With one lane, or a spread of 0, every active lane gets 1 / count on both sides; one lane has exactly unity ratio and gains.
Lifecycle
initUnison(capacity) allocates six Float32Arrays of the caller's capacity (independent of note polyphony) and settles one lane → configureUnison updates targets only → settleUnison applies targets at once, at preparation or reset → tickUnison(state, coefficient) once per sample, before rendering the notes that share the stack. limit is the highest audible lane plus one, including lanes still fading. unisonPhase(lane) gives an optional deterministic start phase (golden-ratio fraction, lane 0 at 0).
When to use it
A detuned, widened oscillator stack in a polyphonic synth. The synth voices guide names Wavetable as the production consumer and notes that existing product-specific unison laws need a deliberate migration before adopting this layout.
Limits
- Stereo gains only; the pan law is relative to the instrument's centre gain.
- A value within 0.000001 of its target snaps to it, so faded lanes reach 0.
tickUnisonwalks every lane of the capacity each sample.- Rendering the lanes, and summing them, is the caller's work.