Control Surface  1.2.0
MIDI Control Surface library for Arduino
Mackie-Control-Universal-Reverse-Engineering.ino

Mackie-Control-Universal-Reverse-Engineering

Sketch that reads the MIDI input from the USB MIDI Interface and prints it to the Serial monitor, including the Mackie Control Universal note names.

This is useful to discover what kinds of messages your DAW is sending.

Boards:
AVR, AVR USB, Nano Every, Due, Nano 33, Teensy 3.x, ESP32
// A MIDI over USB interface
bool channelMessageCallback(ChannelMessage cm) {
if ((cm.header & 0xF0) == 0x90)
Serial << hex << cm.header << ' ' << cm.data1 << ' ' << cm.data2 << dec
<< "\t(" << MCU::getMCUNameFromNoteNumber(cm.data1) << ")" << endl;
else
Serial << hex << cm.header << ' ' << cm.data1 << ' ' << cm.data2 << dec << endl;
return false; // Return true to indicate that handling is done,
// and Control_Surface shouldn't handle it anymore.
// If you want Control_Surface to handle it as well,
// return false.
}
bool sysExMessageCallback(SysExMessage se) {
Serial << F("SysEx: ") << hex;
for (size_t i = 0; i < se.length; ++i)
Serial << se.data[i] << ' ';
Serial << dec << F("on cable ") << se.CN << endl;
return false; // Return true to indicate that handling is done,
// and Control_Surface shouldn't handle it anymore.
// If you want Control_Surface to handle it as well,
// return false.
}
bool realTimeMessageCallback(RealTimeMessage rt) {
Serial << F("Real-Time: ") << hex << rt.message << dec
<< F(" on cable ") << rt.CN << endl;
return false; // Return true to indicate that handling is done,
// and Control_Surface shouldn't handle it anymore.
// If you want Control_Surface to handle it as well,
// return false.
}
void setup() {
// Make sure that the Serial interface is fast enough, so it doesn't stall the MIDI
// application
Serial.begin(1000000);
Control_Surface.setMIDIInputCallbacks(channelMessageCallback, //
sysExMessageCallback, //
realTimeMessageCallback); //
}
void loop() {
}
USBMIDI_Interface
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
Definition: USBMIDI_Interface.hpp:41
SysExMessage
Definition: MIDI_MessageTypes.hpp:138
SysExMessage::data
const uint8_t * data
Definition: MIDI_MessageTypes.hpp:156
AH::dec
Print & dec(Print &printer)
Definition: PrintStream.cpp:77
ChannelMessage::header
uint8_t header
MIDI status byte (message type and channel).
Definition: MIDI_MessageTypes.hpp:83
ChannelMessage::data2
uint8_t data2
First MIDI data byte.
Definition: MIDI_MessageTypes.hpp:85
Control_Surface.h
The main header file that includes all Control-Surface header files.
Control_Surface_::loop
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Definition: Control_Surface_Class.cpp:68
Control_Surface
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
Definition: Control_Surface_Class.cpp:203
RealTimeMessage
Definition: MIDI_MessageTypes.hpp:173
AH::hex
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
ChannelMessage::data1
uint8_t data1
First MIDI data byte.
Definition: MIDI_MessageTypes.hpp:84
SysExMessage::CN
uint8_t CN
Definition: MIDI_MessageTypes.hpp:158
Control_Surface_::setMIDIInputCallbacks
void setMIDIInputCallbacks(ChannelMessageCallback channelMessageCallback, SysExMessageCallback sysExMessageCallback, RealTimeMessageCallback realTimeMessageCallback)
Set the MIDI input callbacks.
Definition: Control_Surface_Class.hpp:153
MIDI_Notes::F
constexpr int8_t F
Definition: Notes.hpp:23
MCU::getMCUNameFromNoteNumber
FlashString_t getMCUNameFromNoteNumber(uint8_t note)
Convert a note number to the name of the corresponding Mackie Control Universal function.
Definition: MCUNameFromNoteNumber.cpp:253
ChannelMessage
Definition: MIDI_MessageTypes.hpp:72
RealTimeMessage::CN
uint8_t CN
Definition: MIDI_MessageTypes.hpp:190
SysExMessage::length
uint8_t length
Definition: MIDI_MessageTypes.hpp:157
RealTimeMessage::message
uint8_t message
Definition: MIDI_MessageTypes.hpp:189
AH::endl
Print & endl(Print &printer)
Definition: PrintStream.cpp:27
Control_Surface_::begin
void begin()
Initialize the Control_Surface.
Definition: Control_Surface_Class.cpp:25