Control Surface master
MIDI Control Surface library for Arduino


This example shows prints all MIDI messages that arrive over USB to the Serial monitor so you can use the Arduino as a MIDI monitor. It also allows you to enter MIDI messages as text in the Serial monitor, and then sends these messages as MIDI over USB.

AVR USB, Due, Nano 33 IoT, Nano 33 BLE, Teensy 3.x

This example requires an Arduino board with native MIDI over USB support.

To send a MIDI message from the Serial monitor, select “Newline” as the line ending, enter the MIDI message in hexadecimal, and press enter.
For example, if you enter 90 3C 7F, a MIDI Note On message for middle C (0x3C) with a velocity of 127 (0x7F) will be sent over USB.
Spaces between bytes are not required (903C7F will be interpreted as 90 3C 7F), but they are recommended to prevent framing errors.

See also
MIDI Tutorial: Routing MIDI messages

Written by PieterP, 2021-06-28

#include <Control_Surface.h> // Include the Control Surface library
// Instantiate the two MIDI interfaces
// Instantiate a MIDI pipe to connect the two interfaces
void setup() {
// Create a bidirectional route between the interfaces:
// all input to one interface is sent to the output of the other
midiusb | mpipe | mididbg;
// Initialize all MIDI interfaces
void loop() {
// Continuously handle MIDI input
The main header file that includes all Control-Surface header files.
static void updateAll()
Update all enabled instances of this class.
Definition: Updatable.hpp:190
static void beginAll()
Begin all enabled instances of this class.
Definition: Updatable.hpp:186
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over the USB CDC...
A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.
std::pair< MIDI_Pipe, MIDI_Pipe > BidirectionalMIDI_Pipe
A bidirectional pipe consists of two unidirectional pipes.
Definition: MIDI_Pipes.hpp:589