@maruaudio/dsp/voices/peaks translates the Mutable Instruments Peaks MultistageEnvelope with its UInt32 phase, int16 levels and tables. One state is one mono channel: Twin maps the four pots to one ADSR, Split maps pots 1–2 and 3–4 to two AD envelopes. Two states share the controls and take independent gates. Expert modes and other Peaks functions are silent.
Parameters
setPeaksParameter returns false for an unknown index or non-finite value:
| Index | Coded behavior | Default |
|---|---|---|
| 0 to 3 pots | Position 0 to 1 → left-aligned 12-bit ADC code (floor(p × 4095) << 4, max 65520) | Raw 0, 8192, 32768, 32767 |
| 4 edit mode | Rounded, 0 to 3: 0 Twin ADSR, 1 Split AD; 2 and 3 render silence | 0 |
| 5 function | Rounded, 0 to 7; only 0 (envelope) renders | 0 |
| 6 manual gate / 7 channel | ≥ 0.5 on, ORed with the tick's gate / ≥ 0.5 channel 1 | 0 / 0 |
| 8 gate CV | Stored as given; the tick reads only its gateHigh argument | 0 |
Twin: pot 1 attack, 2 decay, 3 sustain (code >> 1), 4 release. setPeaksPotRaw takes uint16 codes; peaksGateHigh is the 0.7 V threshold; peaksEnvelopeVolts maps the int16 value to 0..8 V.
Lifecycle
initPeaksState(rate, channel) → preparePeaksState reconfigures and resets → set pots and modes (each write reconfigures, keeping a still-valid segment) → tickPeaks(state, gateHigh) once per sample returns value / 32767, or tickPeaksRaw the int16 code → resetPeaksState clears phase, value, gates and the manual gate, and keeps the pots.
When to use it
A Peaks ADSR or dual AD envelope that keeps the original segment timing and curves.
Limits
- Mono control output, sample tick; the host defines volts per unit.
- Increments come from the 48 kHz table, scaled by 48000 / rate elsewhere.
- The pulse-shaper, bouncing-ball and mini-sequencer files in this folder are separate prepared leaves, not part of this export.