Control Surface  1.1.1
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, 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:35
SysExMessage
Definition: MIDI_Parser.hpp:64
SysExMessage::data
const uint8_t * data
Definition: MIDI_Parser.hpp:72
ChannelMessage::header
uint8_t header
Definition: MIDI_Parser.hpp:48
ChannelMessage::data2
uint8_t data2
Definition: MIDI_Parser.hpp:50
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:48
Control_Surface
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
Definition: Control_Surface_Class.cpp:176
RealTimeMessage
Definition: MIDI_Parser.hpp:77
MCU::getMCUNameFromNoteNumber
const __FlashStringHelper * getMCUNameFromNoteNumber(uint8_t note)
Convert a note number to the name of the corresponding Mackie Control Universal function.
Definition: MCUNameFromNoteNumber.cpp:253
ChannelMessage::data1
uint8_t data1
Definition: MIDI_Parser.hpp:49
SysExMessage::CN
uint8_t CN
Definition: MIDI_Parser.hpp:74
Control_Surface_::setMIDIInputCallbacks
void setMIDIInputCallbacks(ChannelMessageCallback channelMessageCallback, SysExMessageCallback sysExMessageCallback, RealTimeMessageCallback realTimeMessageCallback)
Set the MIDI input callbacks.
Definition: Control_Surface_Class.hpp:118
hex
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
MIDI_Notes::F
constexpr int8_t F
Definition: Notes.hpp:23
endl
Print & endl(Print &printer)
Definition: PrintStream.cpp:27
ChannelMessage
Definition: MIDI_Parser.hpp:47
RealTimeMessage::CN
uint8_t CN
Definition: MIDI_Parser.hpp:79
SysExMessage::length
uint8_t length
Definition: MIDI_Parser.hpp:73
dec
Print & dec(Print &printer)
Definition: PrintStream.cpp:77
RealTimeMessage::message
uint8_t message
Definition: MIDI_Parser.hpp:78
Control_Surface_::begin
void begin()
Initialize the Control_Surface.
Definition: Control_Surface_Class.cpp:25