These changes allow for easier integration with other MIDI libraries, by exposing low-level functions for reading and writing 32-bit USB-MIDI event packets directly, without having to use the callback functions for each MIDI event separately.
No new code was added, the functionality of the original MIDIDeviceBase class has been separated into two classes:
The new LowLevelMIDIDeviceBase class only deals with low-level MIDI over USB communication, like reading and writing 32-bit USB-MIDI event packets.
The MIDIDeviceBase class now inherits from the LowLevelMIDIDeviceBase class and parses the MIDI data, calling user-provided callbacks.
The code for reading a USB-MIDI event packet from the rx buffer and starting the next rx data transfer that was originally part of the MIDIDeviceBase::read() method has been moved into a separate LowLevelMIDIDeviceBase::read_packed() method.
I've tested the changes using InputFunctions.ino example, with some extra code to send MIDI notes in the main loop. A Teensy 3.2 running an usbMIDI sketch sending and receiving MIDI was connected to the USB host ports of both a T3.6 and a T4.1 to verify that MIDI USB communication using the MIDIDevice class still works as expected.
These changes allow for easier integration with other MIDI libraries, by exposing low-level functions for reading and writing 32-bit USB-MIDI event packets directly, without having to use the callback functions for each MIDI event separately.
No new code was added, the functionality of the original
MIDIDeviceBase
class has been separated into two classes:LowLevelMIDIDeviceBase
class only deals with low-level MIDI over USB communication, like reading and writing 32-bit USB-MIDI event packets.MIDIDeviceBase
class now inherits from the LowLevelMIDIDeviceBase class and parses the MIDI data, calling user-provided callbacks.The code for reading a USB-MIDI event packet from the rx buffer and starting the next rx data transfer that was originally part of the
MIDIDeviceBase::read()
method has been moved into a separateLowLevelMIDIDeviceBase::read_packed()
method.I've tested the changes using
InputFunctions.ino
example, with some extra code to send MIDI notes in the main loop. A Teensy 3.2 running an usbMIDI sketch sending and receiving MIDI was connected to the USB host ports of both a T3.6 and a T4.1 to verify that MIDI USB communication using theMIDIDevice
class still works as expected.The specific reason for this pull request is to allow integration with the tttapa/Control-Surface library. The code that couples Control Surface with USBHost_t36 can be found here: tttapa/Control-Surface#teensy-usb-host:src/MIDI_Interfaces/USBHostMIDI_Interface.hpp