Control Surface pin-t-adl
MIDI Control Surface library for Arduino
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
Read the MIDI interface and call the callback if a message was received.
void begin() override
Initialize the MIDI Interface.
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.
Definition: MIDI_Pipes.hpp:589