Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
USBHostMIDI_Interface-Passthrough.ino

USBHostMIDI_Interface-Passthrough

This example demonstrates how to use the USBHostMIDI_Interface to send and receive MIDI data to and from USB MIDI devices connected to a Teensy's USB Host port.

Boards: 🛈
Teensy 3.6, Teensy 4.1

Connections

Behavior

Mapping

Written by PieterP, 2021-01-31
https://github.com/tttapa/Control-Surface

// Create the ports for USB devices plugged into Teensy's 2nd USB port (via hubs)
USBHost usb;
USBHub hub {usb};
// USB Device MIDI (primary USB port)
USBMIDI_Interface devicemidi;
// USB Host MIDI (second USB port)
USBHostMIDI_Interface hostmidi {usb};
// Alternatively, use `USBHostMIDI_Interface_BigBuffer`
// Pipe to route MIDI data between two USB ports
void setup() {
// Wait 1.5 seconds before turning on USB Host. If connected USB devices
// use too much power, Teensy at least completes USB enumeration, which
// makes isolating the power issue easier.
delay(1500);
hostmidi | p | devicemidi; // Connect the interfaces using a MIDI pipe
usb.begin(); // Initialize the USB Host
hostmidi.begin(); // Initialize the MIDI interfaces
devicemidi.begin();
}
void loop() {
// Continuously read incoming MIDI data and route it between the interfaces
hostmidi.update();
devicemidi.update();
}
The main header file that includes all Control-Surface header files.
void update() override
Poll the backend (if necessary) and invoke the callbacks for any received MIDI messages,...
void begin() override
Initialize.
A class for MIDI interfaces sending MIDI messages to a MIDI USB device connected to a Teensy's USB ho...
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.