@maruaudio/dsp/voices/tetra-box plays sixteen morphing sample pads over a shared clip arena. A strike projects the morph position onto an apex-base triangle for barycentric weights over up to three corner clips per pad, turns them into equal-power gains over the loaded corners (√(w / Σw)), multiplies by velocity² and the pad's gains, and starts one-shot reads at 2^(tune/12) × clip rate / engine rate with linear interpolation. Moving the triangle changes the next strike, not sounding voices. Thirty-two voices with cut and layer policies, group-aware stealing and choke groups.
Parameters
Parameters are fields on the TetraBoxVoice struct; the clamps apply at a strike.
| Field | Clamp as coded | Default |
|---|---|---|
morphX, morphY | 0 to 1 | 0.5, 2/3 |
padTune[pad] / padGain[pad] | −24 to 24 semitones / 0 to 1 | 0 / 1 |
decayTrim | 0.1 to 1 (fade floor 15 ms) | 1 |
masterLevel / padsVoices | Applied by the caller per frame / 0 kit policy, 1 cut, 2 layer | 0.9 / 0 |
padsLayout / padsFold | Layouts 0 to 4 (0, 3, 4 contiguous from 36, 48, 60; 1 GM; 2 MPC) / fold on 1 | 0 / 1 |
tetraBoxSetPad(voice, pad, mode, maxVoices, choke, gain) returns false for an unknown pad or mode; it clamps the cap to 1..32 and the kit gain to 0..4. tetraBoxSetClip(voice, pad, layer, offset, frames, rate) refuses a clip outside the arena or a non-positive rate.
Lifecycle
createTetraBoxVoice() allocates the 4,608,000-sample arena and every table at their maxima (from preparation, never the realtime path) → the host fills the arena and calls tetraBoxSetClip and tetraBoxSetPad → set the struct fields → on a note, tetraBoxPadForNote then tetraBoxStrikePad(voice, pad, velocity) → tetraBoxRenderFrame once per frame returns the mono mix before master; the caller applies masterLevel and writes both channels. tetraBoxClearVoices and tetraBoxResetParams keep clips and pad metadata; tetraBoxClearClips drops both for a kit change.
When to use it
A pad sampler whose hits blend up to three recorded layers per pad, with choke groups and per-pad tuning.
Limits
- One mono mix for a centre-panned pair; 16 pads × 3 layers, 32 voices.
- One-shot playback only; a voice retires at the clip's end.
- Cut and choke fade over 12 ms; a steal from a full pool uses the shared 5 ms note-transition bridge.