@maruaudio/dsp/voices/gamelan models struck idiophones as a modal resonator bank: a strike drives a short exciter burst (deterministic xorshift noise under a raised-cosine window, plus a contact impulse) into up to six coupled-form two-pole resonators per voice, each with a left and right copy detuned by the ombak amount. Strike position and a velocity tilt set per-mode gains. Eleven recipes: gender, slenthem, saron, peking, bonang, bonang panerus, kenong, kempul, gong, bell and vibraphone.
Parameters
setGamelanParam(state, index, value), clamped as coded:
| Index | Range | Default | Unit |
|---|---|---|---|
0 IR_INSTRUMENT | Rounded, 0 to 10 (recipe order above) | 0 | — |
1 IR_DECAY_SCALE / 2 IR_DAMPING / 3 IR_STEREO_WIDTH | 0.1 to 3 / 0.05 to 4 / 0 to 1 | 1 / 1 / 0.5 | — |
4 OMBAK_AMOUNT / 5 OMBAK_RATE | 0 to 2 / 0 to 20 | 1 / 3 | — / Hz |
6 EXCITER_HARDNESS / 7 EXCITER_NOISE | 0 to 1 | 0.5 / 0.1 | — |
8 AMP_DECAY / 9 AMP_RELEASE | 0.05 to 4 / 0.02 to 4 | 4 / 0.25 | s |
10 TUNING_MODE / 11 TUNING_BASE_FREQ | Rounded, 0 equal, 1 just, 2 slendro, 3 pelog, 4 custom / 220 to 880 Hz | 2 / 440 | — |
12 MASTER_LEVEL | 0 to 1; 0.01 s glide while voices ring | 0.8 | — |
13 STRIKE_POSITION / 14 STRIKE_VEL_TONE / 15 IR_SIZE | 0 to 1 / 0 to 1 / 0.5 to 2 | 0.5 / 0.5 / 1 | — |
At an amp decay of 2.5 or more (DECAY_OPEN) no damping envelope applies.
Lifecycle
initGamelanVoice(rate) allocates every per-voice array → set parameters → gamelanNoteOn(note, velocity) returns 0 and touches nothing on an unmapped slendro or pelog key; otherwise it releases a ringing voice on the same note, takes a free slot or steals the oldest (starting the shared note-transition bridge), and strikes → gamelanNoteOff starts the release ramp (at least 5 ms) → per frame, gamelanVoiceTick(state, voice, out) per voice adds into a caller-owned stereo pair, then gamelanAdvanceMasterLevel once. To reset, init a new state.
When to use it
Gamelan metallophones and gongs in slendro or pelog, or bell and vibraphone, where strike position and velocity should change which partials ring.
Limits
- Stereo, sample tick, eight voices of six modes; a voice rings at most 7 s.
- Modes at or above 0.45 × the sample rate are silenced (Nyquist guard).
- The PCM16 render entry stays in audio-kernels; the voices barrel omits it.