Control Surface master
MIDI Control Surface library for Arduino
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
USBMIDI_Parser Class Reference

#include <MIDI_Parsers/USBMIDI_Parser.hpp>

Detailed Description

Parser for MIDI over USB packets.

Definition at line 26 of file USBMIDI_Parser.hpp.

+ Inheritance diagram for USBMIDI_Parser:
+ Collaboration diagram for USBMIDI_Parser:

Public Types

using MIDIUSBPacket_t = AH::Array< uint8_t, 4 >
 

Public Member Functions

template<class BytePuller >
MIDIReadEvent pull (BytePuller &&puller)
 Parse one incoming MIDI message. More...
 
SysExMessage getSysExMessage () const
 Get the latest SysEx message. More...
 
ChannelMessage getChannelMessage () const
 Get the latest MIDI channel voice message. More...
 
SysCommonMessage getSysCommonMessage () const
 Get the latest MIDI system common message. More...
 
RealTimeMessage getRealTimeMessage () const
 Get the latest MIDI real-time message. More...
 

Static Public Member Functions

static bool isStatus (uint8_t data)
 Check if the given byte is a MIDI header/status byte. More...
 
static bool isData (uint8_t data)
 Check if the given byte is a MIDI data byte. More...
 

Protected Member Functions

MIDIReadEvent feed (MIDIUSBPacket_t packet)
 Feed a new packet to the parser. More...
 
MIDIReadEvent resume ()
 Resume the parser with the previously stored and unhandled packet. More...
 
MIDIReadEvent handleChannelMessage (MIDIUSBPacket_t packet, Cable cable)
 
MIDIReadEvent handleSingleByte (MIDIUSBPacket_t packet, Cable cable)
 
MIDIReadEvent handleSysExStartCont (MIDIUSBPacket_t packet, Cable cable)
 
template<uint8_t NumBytes>
MIDIReadEvent handleSysExEnd (MIDIUSBPacket_t packet, Cable cable)
 
MIDIReadEvent handleSysCommon (MIDIUSBPacket_t packet, Cable cable)
 
void startSysEx (Cable cable)
 
void endSysEx (Cable cable)
 
void endSysExChunk (Cable cable)
 
bool hasSysExSpace (Cable cable, uint8_t amount) const
 
void addSysExByte (Cable cable, uint8_t data)
 
void addSysExBytes (Cable cable, const uint8_t *data, uint8_t len)
 
bool receivingSysEx (Cable cable) const
 
void storePacket (MIDIUSBPacket_t packet)
 
bool hasStoredPacket () const
 
MIDIUSBPacket_t popStoredPacket ()
 
template<>
MIDIReadEvent handleSysExEnd (MIDIUSBPacket_t packet, Cable cable)
 

Protected Attributes

Cable activeCable = CABLE_1
 
MIDIMessage midimsg = {0x00, 0x00, 0x00}
 
RealTimeMessage rtmsg = {0x00}
 

Private Attributes

SysExBuffer sysexbuffers [16] = {}
 
MIDIUSBPacket_t storedPacket = {{ 0x00 }}
 

Member Typedef Documentation

◆ MIDIUSBPacket_t

using MIDIUSBPacket_t = AH::Array<uint8_t, 4>

Definition at line 28 of file USBMIDI_Parser.hpp.

Member Function Documentation

◆ pull()

MIDIReadEvent pull ( BytePuller &&  puller)
inline

Parse one incoming MIDI message.

Parameters
pullerThe source of MIDI USB packets.
Returns
The type of MIDI message available, or MIDIReadEvent::NO_MESSAGE if puller ran out of packets before a complete message was parsed.

Definition at line 105 of file USBMIDI_Parser.hpp.

◆ feed()

MIDIReadEvent feed ( MIDIUSBPacket_t  packet)
protected

Feed a new packet to the parser.

Definition at line 139 of file USBMIDI_Parser.cpp.

◆ resume()

MIDIReadEvent resume ( )
protected

Resume the parser with the previously stored and unhandled packet.

Definition at line 175 of file USBMIDI_Parser.cpp.

◆ getSysExMessage()

SysExMessage getSysExMessage ( ) const
inline

Get the latest SysEx message.

Definition at line 50 of file USBMIDI_Parser.hpp.

◆ handleChannelMessage()

MIDIReadEvent handleChannelMessage ( MIDIUSBPacket_t  packet,
Cable  cable 
)
protected

Definition at line 6 of file USBMIDI_Parser.cpp.

◆ handleSingleByte()

MIDIReadEvent handleSingleByte ( MIDIUSBPacket_t  packet,
Cable  cable 
)
protected

Definition at line 131 of file USBMIDI_Parser.cpp.

◆ handleSysExStartCont()

MIDIReadEvent handleSysExStartCont ( MIDIUSBPacket_t  packet,
Cable  cable 
)
protected

Definition at line 15 of file USBMIDI_Parser.cpp.

◆ handleSysExEnd() [1/2]

MIDIReadEvent handleSysExEnd ( MIDIUSBPacket_t  packet,
Cable  cable 
)
protected

Definition at line 46 of file USBMIDI_Parser.cpp.

◆ handleSysCommon()

MIDIReadEvent handleSysCommon ( MIDIUSBPacket_t  packet,
Cable  cable 
)
protected

Definition at line 121 of file USBMIDI_Parser.cpp.

◆ startSysEx()

void startSysEx ( Cable  cable)
inlineprotected

Definition at line 69 of file USBMIDI_Parser.hpp.

◆ endSysEx()

void endSysEx ( Cable  cable)
inlineprotected

Definition at line 70 of file USBMIDI_Parser.hpp.

◆ endSysExChunk()

void endSysExChunk ( Cable  cable)
inlineprotected

Definition at line 74 of file USBMIDI_Parser.hpp.

◆ hasSysExSpace()

bool hasSysExSpace ( Cable  cable,
uint8_t  amount 
) const
inlineprotected

Definition at line 75 of file USBMIDI_Parser.hpp.

◆ addSysExByte()

void addSysExByte ( Cable  cable,
uint8_t  data 
)
inlineprotected

Definition at line 78 of file USBMIDI_Parser.hpp.

◆ addSysExBytes()

void addSysExBytes ( Cable  cable,
const uint8_t *  data,
uint8_t  len 
)
inlineprotected

Definition at line 81 of file USBMIDI_Parser.hpp.

◆ receivingSysEx()

bool receivingSysEx ( Cable  cable) const
inlineprotected

Definition at line 84 of file USBMIDI_Parser.hpp.

◆ storePacket()

void storePacket ( MIDIUSBPacket_t  packet)
inlineprotected

Definition at line 88 of file USBMIDI_Parser.hpp.

◆ hasStoredPacket()

bool hasStoredPacket ( ) const
inlineprotected

Definition at line 89 of file USBMIDI_Parser.hpp.

◆ popStoredPacket()

MIDIUSBPacket_t popStoredPacket ( )
inlineprotected

Definition at line 90 of file USBMIDI_Parser.hpp.

◆ handleSysExEnd() [2/2]

MIDIReadEvent handleSysExEnd ( MIDIUSBPacket_t  packet,
Cable  cable 
)
protected

Definition at line 83 of file USBMIDI_Parser.cpp.

◆ getChannelMessage()

ChannelMessage getChannelMessage ( ) const
inlineinherited

Get the latest MIDI channel voice message.

Definition at line 19 of file MIDI_Parser.hpp.

◆ getSysCommonMessage()

SysCommonMessage getSysCommonMessage ( ) const
inlineinherited

Get the latest MIDI system common message.

Definition at line 21 of file MIDI_Parser.hpp.

◆ getRealTimeMessage()

RealTimeMessage getRealTimeMessage ( ) const
inlineinherited

Get the latest MIDI real-time message.

Definition at line 25 of file MIDI_Parser.hpp.

◆ isStatus()

static bool isStatus ( uint8_t  data)
inlinestaticinherited

Check if the given byte is a MIDI header/status byte.

Definition at line 37 of file MIDI_Parser.hpp.

◆ isData()

static bool isData ( uint8_t  data)
inlinestaticinherited

Check if the given byte is a MIDI data byte.

Definition at line 39 of file MIDI_Parser.hpp.

Member Data Documentation

◆ activeCable

Cable activeCable = CABLE_1
protected

Definition at line 96 of file USBMIDI_Parser.hpp.

◆ sysexbuffers

SysExBuffer sysexbuffers[16] = {}
private

Definition at line 99 of file USBMIDI_Parser.hpp.

◆ storedPacket

MIDIUSBPacket_t storedPacket = {{ 0x00 }}
private

Definition at line 100 of file USBMIDI_Parser.hpp.

◆ midimsg

MIDIMessage midimsg = {0x00, 0x00, 0x00}
protectedinherited

Definition at line 32 of file MIDI_Parser.hpp.

◆ rtmsg

RealTimeMessage rtmsg = {0x00}
protectedinherited

Definition at line 33 of file MIDI_Parser.hpp.


The documentation for this class was generated from the following files: