#include <MIDI_Parsers/SerialMIDI_Parser.hpp>
Parser for Serial MIDI streams (and BLE-MIDI).
Definition at line 13 of file SerialMIDI_Parser.hpp.
Public Member Functions | |
SerialMIDI_Parser (bool sysCommonCancelsRunningStatus=true) | |
template<class BytePuller > | |
MIDIReadEvent | pull (BytePuller &&puller) |
Parse one incoming MIDI message. | |
SysExMessage | getSysExMessage () const |
Get the latest SysEx message. | |
void | cancelRunningStatus () |
Clear the running status header for MIDI Channel messages. | |
ChannelMessage | getChannelMessage () const |
Get the latest MIDI channel voice message. | |
SysCommonMessage | getSysCommonMessage () const |
Get the latest MIDI system common message. | |
RealTimeMessage | getRealTimeMessage () const |
Get the latest MIDI real-time message. | |
Static Public Member Functions | |
static bool | isStatus (uint8_t data) |
Check if the given byte is a MIDI header/status byte. | |
static bool | isData (uint8_t data) |
Check if the given byte is a MIDI data byte. | |
Protected Member Functions | |
MIDIReadEvent | feed (uint8_t midibyte) |
Feed a new byte to the parser. | |
MIDIReadEvent | resume () |
Resume the parser with the previously stored and unhandled byte. | |
void | addSysExByte (uint8_t data) |
bool | hasSysExSpace () const |
void | startSysEx () |
void | endSysEx () |
MIDIReadEvent | handleRealTime (uint8_t midiByte) |
MIDIReadEvent | handleNonRealTimeStatus (uint8_t midiByte) |
MIDIReadEvent | handleStatus (uint8_t midiByte) |
MIDIReadEvent | handleData (uint8_t midiByte) |
void | storeByte (uint8_t midiByte) |
Store a byte to parse later. | |
bool | hasStoredByte () const |
Check whether there's a stored byte. | |
uint8_t | popStoredByte () |
Get the stored byte. Afterwards, hasStoredByte will return false. | |
Protected Attributes | |
SysExBuffer | sysexbuffer |
MIDIMessage | midimsg = {0x00, 0x00, 0x00} |
RealTimeMessage | rtmsg = {0x00} |
Private Attributes | |
bool | sysCommonCancelsRunningStatus |
Accounts for running status differences between MIDI 1.0 and BLE-MIDI. | |
bool | thirdByte = false |
Flag that remembers that the next data byte will be the third byte of a message. | |
uint8_t | currentHeader = 0 |
Current header (not necessarily running), contains the header of the message that's currently being received. | |
uint8_t | runningHeader = 0 |
Running status header. | |
uint8_t | storedByte = 0xFF |
|
inline |
Definition at line 15 of file SerialMIDI_Parser.hpp.
|
inline |
Parse one incoming MIDI message.
puller | The source of MIDI bytes. |
MIDIReadEvent::NO_MESSAGE
if puller
ran out of bytes before a complete message was parsed. Definition at line 94 of file SerialMIDI_Parser.hpp.
|
protected |
Feed a new byte to the parser.
Definition at line 199 of file SerialMIDI_Parser.cpp.
|
protected |
Resume the parser with the previously stored and unhandled byte.
Definition at line 212 of file SerialMIDI_Parser.cpp.
|
inline |
Get the latest SysEx message.
Definition at line 38 of file SerialMIDI_Parser.hpp.
Definition at line 43 of file SerialMIDI_Parser.hpp.
|
inlineprotected |
Definition at line 44 of file SerialMIDI_Parser.hpp.
|
inlineprotected |
Definition at line 45 of file SerialMIDI_Parser.hpp.
|
inlineprotected |
Definition at line 46 of file SerialMIDI_Parser.hpp.
|
protected |
Definition at line 5 of file SerialMIDI_Parser.cpp.
|
protected |
Definition at line 10 of file SerialMIDI_Parser.cpp.
|
protected |
Definition at line 85 of file SerialMIDI_Parser.cpp.
|
protected |
Definition at line 96 of file SerialMIDI_Parser.cpp.
Store a byte to parse later.
This is used when the SysEx buffer is full, for example. The byte cannot be added to the buffer now, so store it to add it the next time the parser is updated.
Definition at line 61 of file SerialMIDI_Parser.hpp.
|
inlineprotected |
Check whether there's a stored byte.
If this is the case, this byte should be parsed before reading a new byte.
Definition at line 64 of file SerialMIDI_Parser.hpp.
|
inlineprotected |
Get the stored byte. Afterwards, hasStoredByte will return false.
Definition at line 66 of file SerialMIDI_Parser.hpp.
|
inline |
Clear the running status header for MIDI Channel messages.
Internal method.
Definition at line 75 of file SerialMIDI_Parser.hpp.
|
inlineinherited |
Get the latest MIDI channel voice message.
Definition at line 19 of file MIDI_Parser.hpp.
|
inlineinherited |
Get the latest MIDI system common message.
Definition at line 21 of file MIDI_Parser.hpp.
|
inlineinherited |
Get the latest MIDI real-time message.
Definition at line 25 of file MIDI_Parser.hpp.
Check if the given byte is a MIDI header/status byte.
Definition at line 37 of file MIDI_Parser.hpp.
Check if the given byte is a MIDI data byte.
Definition at line 39 of file MIDI_Parser.hpp.
|
protected |
Definition at line 48 of file SerialMIDI_Parser.hpp.
|
private |
Accounts for running status differences between MIDI 1.0 and BLE-MIDI.
Definition at line 79 of file SerialMIDI_Parser.hpp.
Flag that remembers that the next data byte will be the third byte of a message.
Definition at line 82 of file SerialMIDI_Parser.hpp.
|
private |
Current header (not necessarily running), contains the header of the message that's currently being received.
As soon as the message is complete, it is set to zero.
Definition at line 86 of file SerialMIDI_Parser.hpp.
|
private |
Running status header.
Definition at line 88 of file SerialMIDI_Parser.hpp.
|
private |
Definition at line 90 of file SerialMIDI_Parser.hpp.
|
protectedinherited |
Definition at line 32 of file MIDI_Parser.hpp.
|
protectedinherited |
Definition at line 33 of file MIDI_Parser.hpp.