Skip to content

Instantly share code, notes, and snippets.

@kmorrill
Last active February 3, 2025 04:50
Show Gist options
  • Save kmorrill/65381e9a61f436d7994afca7a62fe6b7 to your computer and use it in GitHub Desktop.
Save kmorrill/65381e9a61f436d7994afca7a62fe6b7 to your computer and use it in GitHub Desktop.
Mozaic MIDI Interception
MIDI Reception and Intervention
• MIDI Input Handling:
• Mozaic triggers the @OnMidiInput event when any MIDI data is received.
• Note: Incoming MIDI is not automatically forwarded to the output—you must explicitly forward it using commands like SendMIDIThru or SendMIDIThruOnCh <channel>.
• Forwarding MIDI Data:
• Use SendMIDIThru to pass all incoming MIDI data unchanged.
• Use SendMIDIThruOnCh <channel> to reassign all incoming MIDI to a specific channel (e.g., SendMIDIThruOnCh 9 routes everything to channel 9).
• Filtering MIDI Events:
• The variable MIDICommand holds the last received MIDI command (e.g., Note On 0x90, Note Off 0x80, CC 0xB0).
• Mozaic supports both hexadecimal (e.g., 0xB0) and decimal (e.g., 176) notation.
• Gotcha: To filter out specific MIDI events (like MIDI CC), check the value of MIDICommand within your @OnMidiInput block:
@OnMidiInput
if MIDICommand = 0xB0
// Handle or filter out CC events as needed.
else
// Forward non-CC events.
endif
SendMIDIThruOnCh 9
@End
• Channel Handling: Within @OnMidiInput, the channel number in MIDICommand is set to 0. Use the variable MIDIChannel to retrieve the original channel if needed.
All channels coming into Mozaic are 0 based, so you often need to subtract one from the hardware devices human readable track number.
When working with the OP-XY, it's MIDI controller channel works across MIDI channel 0. It will send notes and MIDI CC, bank and program in on channel 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment