@maruaudio/dsp/voices/fm-keys is a four-operator phase-modulation keyboard voice: six algorithms latched per voice at note-on, a stepped ratio table, a modulation index scaled by the carrier's own frequency, a closed-form Bessel series for operator 4's self-feedback (24 harmonics, normalized by a 256-point peak scan), per-operator envelopes and a velocity-to-index law, over an eight-voice pool summed to one mono bus, with its f32 boundaries kept.
Parameters
setFmKeysParam stores the raw f32 value (indices outside 0..24 are ignored); clamps apply where it is read.
| Index | Read as | Default |
|---|---|---|
| 0 algorithm | Rounded at note-on: 0 stack, 1 twin, 2 fan, 3 split, 4 pair, 5 additive | 1 |
| 1, 7, 13, 17 ratio | Rounded, 0 to 19: entries 0–14 ratios 0.5 to 8 of the note (with the √2 family), 15–19 fixed 55, 110, 220, 440, 1100 Hz | 2, 2, 14, 8 |
| 2, 8, 14, 18 level | 0 to 1; index = 12 × level² | 0.85, 0.42, 0.16, 0.3 |
| 3, 9, 15, 19 attack / 4, 10, 16, 20 decay | Seconds, at least 0.001 | 0.001 / 1.6, 0.35, 0.28, 0.18 |
| 5, 11 sustain (ops 1–2) | 0 to 1; ops 3–4 have none | 0.55, 0.06 |
| 6, 12 release (ops 1–2) | Seconds, at least 0.001; ops 3–4 share 0.06 s | 0.5, 0.3 |
| 21 feedback | 0 to 1 (β); rebuilds the harmonic table on write | 0.06 |
| 22 velocity sensitivity | 0 to 1; blends 0.18 + 0.82 × velocity^1.35 into the index | 0.75 |
| 23 brightness | Index multiplier, at least 0 | 1 |
| 24 master level | 0 to 1, 10 ms one-pole glide (operator 1 level glides too) | 0.8 |
Lifecycle
initFmKeysVoice(rate) allocates every array and applies the factory patch → set parameters → fmKeysNoteOn(note, velocity) (note rounded into 0..127; a sounding voice on the same note is ducked over 12 ms; then the lowest free slot or the oldest active one) / fmKeysNoteOff → fmKeysRenderFrame once per frame returns one mono sample (or fmKeysAdvanceFrame once, then fmKeysRenderVoiceFrame per slot, for spatial hosts). resetFmKeysVoice restores the factory patch; setFmKeysPerformance adds mono and legato glide.
When to use it
FM keyboard patches (electric piano, bell, bass) whose index should follow velocity.
Limits
- Mono output, sample tick, eight voices; the voices barrel does not export it.
- The algorithm is latched through the ratio clamp (0..19); a value above 5 sounds all four operators unmodulated with a carrier divisor of 1.
- Any positive sample rate is accepted; the rate is held as an f32.