xtc/docs/decisions/0011-midi-track-instruments.md
2026-11-06 15:20:20 +01:00

1.7 KiB

0011 — Prepared MIDI Track Instruments

Accepted. Extend the modern C99 adapters with zero-audio-input, mono-output instruments and one event input. Keep graph effects separate from track bindings. Each assigned track owns one prepared instance; the existing instrument source sums their mixed output and the sine output of unassigned tracks. A stable saved live target prevents accidental broadcast/double playback.

Bindings are copied metadata in the project/history model, serialized in v12. Loading metadata never executes modules. GUI edits prepare a candidate before publication, preserving the previous project on missing/invalid binaries. Existing quiescent plan retirement owns destruction; no module operation belongs in audio.

Preallocate 256-frame audio scratch and 256 incoming events per chunk. Stable insertion orders reset, scheduled off/on and live events without callback sort or allocation. VST3 translates into a bounded 2304-event IEventList (2048 possible held keys plus 256 incoming events); panic expands held keys to note-offs. CLAP prefers MIDI where supported, otherwise native note events; VST2 uses MIDI ABI messages. Native CLAP and VST3 currently omit controller mapping. Existing 32 simultaneous scheduled notes and 4096 stored notes remain validation bounds.

Discontinuities send all-off and chase spanning notes with fresh note-ons. Panic suppresses already-started scheduled notes. Neither operation promises opaque DSP reconstruction or removal of release tails. Overflow/process errors silence the block and arm reset for the following render. Hosts cannot guarantee that third-party processing is realtime safe. Qualification covers original ABI fixtures; arbitrary third-party plugins, physical audio and MIDI remain unverified.