This is an old version of the documentation. View the latest version here.
Control Surface  1.0.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 USB, Teensy 3.x
// 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:43
SysExMessage
Definition: MIDI_Parser.hpp:64
SysExMessage::length
uint8_t length
Definition: MIDI_Parser.hpp:73
RealTimeMessage::CN
uint8_t CN
Definition: MIDI_Parser.hpp:79
RealTimeMessage::message
uint8_t message
Definition: MIDI_Parser.hpp:78
Control_Surface.h
The main header file that includes all Control-Surface header files.
ChannelMessage::data1
uint8_t data1
Definition: MIDI_Parser.hpp:49
Control_Surface
Control_Surface_ & Control_Surface
A predefined instance of the Control Surface to use in the Arduino sketches.
Definition: Control_Surface_Class.cpp:171
RealTimeMessage
Definition: MIDI_Parser.hpp:77
Control_Surface_::setMIDIInputCallbacks
void setMIDIInputCallbacks(ChannelMessageCallback channelMessageCallback, SysExMessageCallback sysExMessageCallback, RealTimeMessageCallback realTimeMessageCallback)
Set the MIDI input callbacks.
Definition: Control_Surface_Class.hpp:111
dec
Print & dec(Print &printer)
Definition: PrintStream.cpp:77
Control_Surface_::begin
void begin()
Initialize the Control_Surface.
Definition: Control_Surface_Class.cpp:22
endl
Print & endl(Print &printer)
Definition: PrintStream.cpp:27
hex
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
ChannelMessage::header
uint8_t header
Definition: MIDI_Parser.hpp:48
ChannelMessage
Definition: MIDI_Parser.hpp:47
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
SysExMessage::CN
uint8_t CN
Definition: MIDI_Parser.hpp:74
ChannelMessage::data2
uint8_t data2
Definition: MIDI_Parser.hpp:50
SysExMessage::data
const uint8_t * data
Definition: MIDI_Parser.hpp:72
Control_Surface_::loop
void loop()
Update all MIDI elements, send MIDI events and read MIDI input.
Definition: Control_Surface_Class.cpp:45
MIDI_Notes::F
constexpr int8_t F
Definition: Notes.hpp:23