Line data Source code
1 : #pragma once 2 : 3 : #include <stddef.h> 4 : #include <stdint.h> 5 : #include <stdlib.h> 6 : 7 : #include <Def/Def.hpp> 8 : #include <Settings/SettingsWrapper.hpp> 9 : 10 : #include "MIDIReadEvent.hpp" 11 : #include "MIDI_MessageTypes.hpp" 12 : 13 : BEGIN_CS_NAMESPACE 14 : 15 : /// Base class for MIDI parsers. 16 : class MIDI_Parser { 17 : public: 18 : /// Get the latest MIDI channel voice message. 19 68 : ChannelMessage getChannelMessage() const { return ChannelMessage(midimsg); } 20 : /// Get the latest MIDI system common message. 21 23 : SysCommonMessage getSysCommonMessage() const { 22 23 : return SysCommonMessage(midimsg); 23 : } 24 : /// Get the latest MIDI real-time message. 25 12 : RealTimeMessage getRealTimeMessage() const { return rtmsg; } 26 : #if IGNORE_SYSEX 27 : /// Get the latest SysEx message. 28 : SysExMessage getSysExMessage() const { return {nullptr, 0, Cable_1}; } 29 : #endif 30 : 31 : protected: 32 : MIDIMessage midimsg = {0x00, 0x00, 0x00}; 33 : RealTimeMessage rtmsg = {0x00}; 34 : 35 : public: 36 : /// Check if the given byte is a MIDI header/status byte. 37 1010 : static bool isStatus(uint8_t data) { return data & (1 << 7); } 38 : /// Check if the given byte is a MIDI data byte. 39 : static bool isData(uint8_t data) { return (data & (1 << 7)) == 0; } 40 : }; 41 : 42 : END_CS_NAMESPACE