If a synth keeps playing after you lift your finger, don't assume the controller failed to send a Note Off. A valid Note Off can address the wrong note. A giveaway: it happens after you change an octave, channel, or route while a note is still held.

Capture the address that was actually sent

The MIDI Association’s message reference shows that MIDI 1.0 Note On and Note Off both carry a channel and a note number. Trace the mapper's output, not just the key or gesture entering it.

In a test patch, start source note 60 on channel 1 with one control. While it is held, raise the mapping by an octave and set it to channel 2. Start another independent control with the same input pitch, then lift the first control and the second. For a mapper that keeps the old note playing until release, the four output events are:

90 3C 50 First press: channel 1, note 60 91 48 50 Second press: channel 2, note 72 80 3C 00 First release uses its original note and channel 81 48 00 Second release uses the newer note and channel 

The wire numbers channels from zero; the labels above use the usual 1–16 display convention. If the first release instead sends 81 48 00, note 60 on channel 1 hasn't received its release. Depending on the receiver, the new note may also stop too soon.

Keep the original address until release

Map each press once and remember the emitted port, channel and pitch under a source-press identity. Release to that stored address rather than applying the current octave and route. New presses use the new mapping. If a mode change should move already-held notes, explicitly release the old notes first, then start their replacements and store the new addresses.

This runnable model uses one output port and unique input IDs, with zero-based wire channels:

def messages(events): offset, out_channel = 0, 0 held = {} for op, a, b in events: if op == 'map': offset, out_channel = a, b elif op == 'down' and a not in held: key = b + offset if 0 <= key <= 127: held[a] = (out_channel, key) yield (0x90 | out_channel, key, 80) elif op == 'up' and a in held: ch, key = held.pop(a) yield (0x80 | ch, key, 0) trace = [('down', 'a', 60), ('map', 12, 1), ('down', 'b', 60), ('up', 'a', 60), ('up', 'b', 60)] assert [bytes(msg).hex(' ') for msg in messages(trace)] == [ '90 3c 50', '91 48 50', '80 3c 00', '81 48 00'] 

Test the overlap cases separately

  • For raw MIDI, an input port, channel and pitch can still repeat before release. Pick an explicit overlap policy rather than replacing the previous press's record silently. Receivers can handle repeated note-ons differently.
  • If an onset was dropped because the mapped note fell outside 0–127, lifting that control shouldn't generate a new release just because the mapping has since changed.
  • If a destination is removed, release outstanding notes before closing the route where possible. A disconnected destination cannot receive its Note Off.

The four-byte-triplet trace, 500 seeded press/release sequences and a dropped out-of-range note passed in a synthetic model. These checks do not establish behavior in any commercial DAW or controller.

Prepared for Sonari Studio with AI. No physical instrument or product behavior was tested.