The MIDI channel filter: one sequencer, many instruments
By default a .dsp is Omni — it reacts to notes on every MIDI
channel. That's fine for one instrument; with several DSPs on the bus,
every note plays every instrument. The fix is the per-DSP channel filter:
declare options "[midi:chan 2][midi:on][nvoices:8]";
[midi:chan N] (1–16) is a FaustWave convention token in the declare options string — libfaust ignores it; the DSP's MIDI handler filters on
it. Absent token = Omni.
What the filter applies to (one rule everywhere since the pre-arm
round): notes, pitch bend, and the two panic CCs (120 All Sound Off,
123 All Notes Off) are channel-scoped — they are what a wrong channel
would make audible. Everything else passes regardless of channel:
system messages, clock, program change, and ordinary CCs. A CC that
should listen on one channel only says so per control, with
[midi:ctrl N CH] in the parameter's metadata — that is the one
per-patch channel scoping Faust itself understands.
You rarely write it by hand. The action does it for you, live on the running DSP, no recompile:
dsp.midi.channel.set { module_id, channel }— 0 = Omni (removes the token), 1–16 = accept only that channel. Marks the buffer dirty;documents.savepersists.- Read the current value from
documents.list→midi_channel. - Builder twin: the
midi_notenode'schannelparam /dsp.midi.channel.set— same semantics on the visual side.
The multi-timbral recipe
- Give every instrument DSP its channel: lead → 1, bass → 2, drums → 3, …
- Give every sequencer track the matching channel:
sequencer.track.midi-channel.set { track_id, channel }. - Patchbay-connect
sequencer-default:outto each DSP's:midi-insink (the bus is filter-free by design — receivers do the filtering). - Play. Each track now drives exactly one instrument.
Auditioning a single instrument respects the same rule: midi.note.play { note, channel } — a filtered DSP still lists in midi_consumers but
silently drops other-channel notes, so when an audition note stays
silent, check the receiver's channel before suspecting broken MIDI.