Build with this node

Start with a prompt in Studio, or copy it into your own coding agent.

Ask Studio

@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.

IndexRead asDefault
0 algorithmRounded at note-on: 0 stack, 1 twin, 2 fan, 3 split, 4 pair, 5 additive1
1, 7, 13, 17 ratioRounded, 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 Hz2, 2, 14, 8
2, 8, 14, 18 level0 to 1; index = 12 × level²0.85, 0.42, 0.16, 0.3
3, 9, 15, 19 attack / 4, 10, 16, 20 decaySeconds, at least 0.0010.001 / 1.6, 0.35, 0.28, 0.18
5, 11 sustain (ops 1–2)0 to 1; ops 3–4 have none0.55, 0.06
6, 12 release (ops 1–2)Seconds, at least 0.001; ops 3–4 share 0.06 s0.5, 0.3
21 feedback0 to 1 (β); rebuilds the harmonic table on write0.06
22 velocity sensitivity0 to 1; blends 0.18 + 0.82 × velocity^1.35 into the index0.75
23 brightnessIndex multiplier, at least 01
24 master level0 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.

Algorithm properties and proofs

No Lean 4 proof is mapped to this node.

Explore proofs alongside performance

Dependencies

Dependents

No other node imports this one.

Used by