# 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:

```faust
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.save` persists.
- Read the current value from `documents.list` → `midi_channel`.
- Builder twin: the `midi_note` node's `channel` param /
  `dsp.midi.channel.set` — same semantics on the visual side.

## The multi-timbral recipe

1. Give every instrument DSP its channel: lead → 1, bass → 2, drums → 3, …
2. Give every sequencer track the matching channel:
   `sequencer.track.midi-channel.set { track_id, channel }`.
3. Patchbay-connect `sequencer-default:out` to **each** DSP's
   `:midi-in` sink (the bus is filter-free by design — receivers do the
   filtering).
4. 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**.

> 🟦 **CHIP-ERA ALTERNATIVE**: before the channel filter existed, DSPs
> separated themselves by note *register* — each one gating on a frequency
> window (`inRange = (freq > lo) & (freq < hi)`). The 8-Bit/SID book uses
> that trick; it's still a legitimate creative constraint, but channels are
> the clean default now.
