Chapter 3 of 10
MIDI
Companion lab · Read full chapter in the guide →
Route DAW and UI notes through midinotein, allocate voices, and drive ADSR in the graph—not JS timers.
In this lab you will
- Chain
midinotein→ allocate → unpack - Build
trigger,latch, andadsrfor one voice - Play keys with
await wax.midi.ready()+noteOn/noteOff
Minimal pattern
const midiIn = wax.midinotein();
const voices = wax.midinoteallocate({ voices: 8 }, midiIn);
const [frequency, velocity] = wax.midinoteunpack({ channel: 0 }, voices);
const trigger = wax.ge(velocity, wax.const({ key: "triggerEps", value: 0.001 }));
const ampEnv = wax.adsr(a, d, s, r, trigger);
Try it
MIDI voice demo · Poly synth (Ch. 6)
Example code
Loading…