A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over the USB CDC connection. More...
#include <MIDI_Interfaces/DebugMIDI_Interface.hpp>
Public Member Functions | |
USBDebugMIDI_Interface (unsigned long baud=AH::defaultBaudRate) | |
Construct a USBDebugMIDI_Interface with the given baud rate. More... | |
void | begin () override |
Start the Serial interface at the predefined baud rate. More... | |
MIDI_read_t | read () override |
MIDI_Parser & | getParser () |
ChannelMessage | getChannelMessage () |
Return the received channel message. More... | |
SysExMessage | getSysExMessage () const |
Return the received system exclusive message. More... | |
uint8_t | getCN () const |
Return the cable number of the received message. More... | |
void | update () override |
Read the MIDI interface and call the callback if a message is received. More... | |
void | setCallbacks (MIDI_Callbacks *cb) override |
Set the callbacks that will be called when a MIDI message is received. More... | |
virtual void | setCallbacks (MIDI_Callbacks *cb)=0 |
Set the callbacks that will be called when a MIDI message is received. More... | |
void | setCallbacks (MIDI_Callbacks &cb) |
Set the callbacks that will be called when a MIDI message is received. More... | |
void | setCallbacks (MIDI_Callbacks &cb) |
Set the callbacks that will be called when a MIDI message is received. More... | |
void | send (uint8_t m, uint8_t c, uint8_t d1, uint8_t d2) |
Send a 3-byte MIDI packet. More... | |
void | send (uint8_t m, uint8_t c, uint8_t d1) |
Send a 2-byte MIDI packet. More... | |
void | send (SysExMessage message) |
Send a MIDI System Exclusive message. More... | |
template<size_t N> | |
void | send (const uint8_t(&sysexdata)[N], uint8_t cn=0) |
Send a MIDI System Exclusive message. More... | |
void | send (uint8_t rt, uint8_t cn=0) |
Send a single-byte MIDI message. More... | |
void | sendOnCable (uint8_t m, uint8_t c, uint8_t d1, uint8_t d2, uint8_t cn) |
Send a 3-byte MIDI packet with cable number. More... | |
void | sendOnCable (uint8_t m, uint8_t c, uint8_t d1, uint8_t cn) |
Send a 2-byte MIDI packet with cable number. More... | |
void | sendOnCable (uint8_t r, uint8_t cn) |
Send a single-byte MIDI packet with cable number. More... | |
void | sendNoteOn (MIDICNChannelAddress address, uint8_t velocity) |
Send a MIDI Note On event. More... | |
void | sendNoteOff (MIDICNChannelAddress address, uint8_t velocity) |
Send a MIDI Note Off event. More... | |
void | sendKP (MIDICNChannelAddress address, uint8_t pressure) |
Send a MIDI Key Pressure event. More... | |
void | sendCC (MIDICNChannelAddress address, uint8_t value) |
Send a MIDI Control Change event. More... | |
void | sendPC (MIDICNChannelAddress address) |
Send a MIDI Program Change event. More... | |
void | sendPC (MIDICNChannel address, uint8_t value) |
Send a MIDI Program Change event. More... | |
void | sendCP (MIDICNChannel address, uint8_t pressure) |
Send a MIDI Channel Pressure event. More... | |
void | sendPB (MIDICNChannel address, uint16_t value) |
Send a MIDI Pitch Bend event. More... | |
void | setAsDefault () |
Set this MIDI interface as the default interface. More... | |
Static Public Member Functions | |
static MIDI_Interface * | getDefault () |
Return the default MIDI interface. More... | |
Protected Member Functions | |
void | sendImpl (uint8_t m, uint8_t c, uint8_t d1, uint8_t d2, uint8_t cn) override |
Low-level function for sending a 3-byte MIDI message. More... | |
void | sendImpl (uint8_t m, uint8_t c, uint8_t d1, uint8_t cn) override |
Low-level function for sending a 2-byte MIDI message. More... | |
void | sendImpl (const uint8_t *data, size_t length, uint8_t cn) override |
Low-level function for sending a system exclusive MIDI message. More... | |
void | sendImpl (uint8_t rt, uint8_t cn) override |
Low-level function for sending a single-byte MIDI message. More... | |
bool | dispatchMIDIEvent (MIDI_read_t event) |
Protected Attributes | |
SerialMIDI_Parser | parser |
Stream & | stream |
Private Member Functions | |
void | onRealtimeMessage (uint8_t message) |
void | onChannelMessage () |
void | onSysExMessage () |
Static Private Member Functions | |
static uint8_t | hexCharToNibble (char hex) |
Convert a hexadecimal character to a 4-bit nibble. More... | |
Private Attributes | |
decltype(Serial) & | serial |
const unsigned long | baud |
char | firstChar = '\0' |
char | secondChar = '\0' |
MIDI_Callbacks * | callbacks = nullptr |
Static Private Attributes | |
static MIDI_Interface * | DefaultMIDI_Interface = nullptr |
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over the USB CDC connection.
Boards without a native USB connection (UNO, MEGA, Nano ...) use HardwareSerial0 for USB communication.
Definition at line 115 of file DebugMIDI_Interface.hpp.
|
inline |
Construct a USBDebugMIDI_Interface with the given baud rate.
baud | The baud rate to start the USB Serial connection with. |
Definition at line 124 of file DebugMIDI_Interface.hpp.
|
inlineoverridevirtualinherited |
Start the Serial interface at the predefined baud rate.
Reimplemented from MIDI_Interface.
Definition at line 76 of file DebugMIDI_Interface.hpp.
|
overridevirtualinherited |
Implements Parsing_MIDI_Interface.
Definition at line 40 of file DebugMIDI_Interface.cpp.
|
overrideprotectedvirtualinherited |
Low-level function for sending a 3-byte MIDI message.
Implements MIDI_Interface.
Definition at line 77 of file DebugMIDI_Interface.cpp.
|
overrideprotectedvirtualinherited |
Low-level function for sending a 2-byte MIDI message.
Implements MIDI_Interface.
Definition at line 88 of file DebugMIDI_Interface.cpp.
|
overrideprotectedvirtualinherited |
Low-level function for sending a system exclusive MIDI message.
Implements MIDI_Interface.
Definition at line 99 of file DebugMIDI_Interface.cpp.
|
overrideprotectedvirtualinherited |
Low-level function for sending a single-byte MIDI message.
Implements MIDI_Interface.
Definition at line 108 of file DebugMIDI_Interface.cpp.
|
inlinestaticprivateinherited |
Convert a hexadecimal character to a 4-bit nibble.
Definition at line 43 of file DebugMIDI_Interface.hpp.
|
inlineinherited |
Definition at line 201 of file MIDI_Interface.hpp.
|
inherited |
Return the received channel message.
Definition at line 120 of file MIDI_Interface.cpp.
|
inherited |
Return the received system exclusive message.
Definition at line 124 of file MIDI_Interface.cpp.
|
inherited |
Return the cable number of the received message.
Definition at line 128 of file MIDI_Interface.cpp.
|
overridevirtualinherited |
Read the MIDI interface and call the callback if a message is received.
Implements MIDI_Interface.
Definition at line 132 of file MIDI_Interface.cpp.
|
inlineoverridevirtualinherited |
Set the callbacks that will be called when a MIDI message is received.
cb | A pointer to an object that implements the MIDI_Callbacks class. |
Implements MIDI_Interface.
Definition at line 220 of file MIDI_Interface.hpp.
|
inherited |
Set the callbacks that will be called when a MIDI message is received.
cb | A pointer to an object that implements the MIDI_Callbacks class. |
|
inlineinherited |
Set the callbacks that will be called when a MIDI message is received.
cb | A reference to an object that implements the MIDI_Callbacks class. |
Definition at line 159 of file MIDI_Interface.hpp.
|
inlineinherited |
Set the callbacks that will be called when a MIDI message is received.
cb | A reference to an object that implements the MIDI_Callbacks class. |
Definition at line 159 of file MIDI_Interface.hpp.
|
protectedinherited |
Definition at line 143 of file MIDI_Interface.cpp.
|
privateinherited |
Definition at line 154 of file MIDI_Interface.cpp.
|
privateinherited |
Definition at line 159 of file MIDI_Interface.cpp.
|
privateinherited |
Definition at line 164 of file MIDI_Interface.cpp.
|
inherited |
Send a 3-byte MIDI packet.
m | MIDI message type. [0x80, 0xE0] |
c | The MIDI channel. [1, 16] |
d1 | The first data byte. [0, 127] |
d2 | The second data byte. [0, 127] |
Definition at line 22 of file MIDI_Interface.cpp.
|
inherited |
Send a 2-byte MIDI packet.
m | MIDI message type. [0x80, 0xE0] |
c | The MIDI channel. [1, 16] |
d1 | The first data byte. [0, 127] |
Definition at line 26 of file MIDI_Interface.cpp.
|
inherited |
Send a MIDI System Exclusive message.
Definition at line 100 of file MIDI_Interface.cpp.
|
inlineinherited |
Send a MIDI System Exclusive message.
Definition at line 120 of file MIDI_Interface.hpp.
|
inherited |
Send a single-byte MIDI message.
Definition at line 109 of file MIDI_Interface.cpp.
|
inherited |
Send a 3-byte MIDI packet with cable number.
m | MIDI message type. [0x80, 0xE0] |
c | The MIDI channel. [1, 16] |
d1 | The first data byte. [0, 127] |
d2 | The second data byte. [0, 127] |
cn | The MIDI Cable Number. [0, 15] |
Definition at line 30 of file MIDI_Interface.cpp.
|
inherited |
Send a 2-byte MIDI packet with cable number.
m | MIDI message type. [0x80, 0xE0] |
c | The MIDI channel. [1, 16] |
d1 | The first data byte. [0, 127] |
cn | The MIDI Cable Number. [0, 15] |
Definition at line 42 of file MIDI_Interface.cpp.
|
inherited |
Send a single-byte MIDI packet with cable number.
r | The MIDI byte to send. |
cn | The MIDI Cable Number. [0, 15] |
Definition at line 52 of file MIDI_Interface.cpp.
|
inherited |
Send a MIDI Note On event.
Definition at line 58 of file MIDI_Interface.cpp.
|
inherited |
Send a MIDI Note Off event.
Definition at line 64 of file MIDI_Interface.cpp.
|
inherited |
Send a MIDI Key Pressure event.
Definition at line 70 of file MIDI_Interface.cpp.
|
inherited |
Send a MIDI Control Change event.
Definition at line 75 of file MIDI_Interface.cpp.
|
inherited |
Send a MIDI Program Change event.
Definition at line 85 of file MIDI_Interface.cpp.
|
inherited |
Send a MIDI Program Change event.
Definition at line 80 of file MIDI_Interface.cpp.
|
inherited |
Send a MIDI Channel Pressure event.
Definition at line 90 of file MIDI_Interface.cpp.
|
inherited |
Send a MIDI Pitch Bend event.
Definition at line 95 of file MIDI_Interface.cpp.
|
staticinherited |
Return the default MIDI interface.
Definition at line 18 of file MIDI_Interface.cpp.
|
inherited |
Set this MIDI interface as the default interface.
Definition at line 16 of file MIDI_Interface.cpp.
|
privateinherited |
Definition at line 79 of file DebugMIDI_Interface.hpp.
|
privateinherited |
Definition at line 80 of file DebugMIDI_Interface.hpp.
|
privateinherited |
Definition at line 37 of file DebugMIDI_Interface.hpp.
|
privateinherited |
Definition at line 38 of file DebugMIDI_Interface.hpp.
|
protectedinherited |
Definition at line 39 of file SerialMIDI_Interface.hpp.
|
protectedinherited |
Definition at line 70 of file SerialMIDI_Interface.hpp.
|
privateinherited |
Definition at line 240 of file MIDI_Interface.hpp.
|
staticprivateinherited |
Definition at line 182 of file MIDI_Interface.hpp.