Control Surface  1.2.0
MIDI Control Surface library for Arduino
USBMIDI_Parser.hpp
Go to the documentation of this file.
1 #include "MIDI_Parser.hpp"
2 #include "SysExBuffer.hpp"
4 
5 #ifdef MIDI_NUM_CABLES
6 #define USB_MIDI_NUMBER_OF_CABLES MIDI_NUM_CABLES
7 #elif defined(USB_MIDI4_SERIAL) || defined(USB_MIDI4)
8 #define USB_MIDI_NUMBER_OF_CABLES 4
9 #elif defined(USB_MIDI16_AUDIO_SERIAL) || defined(USB_MIDI16_SERIAL) || \
10  defined(USB_MIDI16)
11 // TODO: || defined(USB_EVERYTHING)
12 #define USB_MIDI_NUMBER_OF_CABLES 16
13 #else
14 #define USB_MIDI_NUMBER_OF_CABLES 1
15 #endif
16 
18 
19 class USBMIDI_Parser : public MIDI_Parser {
20  public:
21  MIDIReadEvent parse(uint8_t *packet);
22 
23 #if !IGNORE_SYSEX
24  SysExMessage getSysExMessage() const override {
25  return {sysexbuffers[activeSysExCN].getBuffer(),
27  }
28 #endif
29 
30  protected:
31 #if !IGNORE_SYSEX
32  void startSysEx(uint8_t CN) { sysexbuffers[CN].start(); }
33  void endSysEx(uint8_t CN) {
34  sysexbuffers[CN].end();
35  activeSysExCN = CN;
36  }
37  bool addSysExByte(uint8_t CN, uint8_t data) {
38  return sysexbuffers[CN].add(data);
39  }
40  bool receivingSysEx(uint8_t CN) const {
41  return sysexbuffers[CN].isReceiving();
42  }
43 #endif
44 
45  uint8_t activeSysExCN = 0;
46 
47  private:
48 #if !IGNORE_SYSEX
50 #endif
51 };
52 
AH::Array::end
T * end()
Get a pointer to the memory beyond the array.
Definition: Array.hpp:88
USBMIDI_Parser::startSysEx
void startSysEx(uint8_t CN)
Definition: USBMIDI_Parser.hpp:32
SysExMessage
Definition: MIDI_MessageTypes.hpp:138
USBMIDI_Parser::parse
MIDIReadEvent parse(uint8_t *packet)
Definition: USBMIDI_Parser.cpp:7
USBMIDI_Parser::endSysEx
void endSysEx(uint8_t CN)
Definition: USBMIDI_Parser.hpp:33
USBMIDI_Parser::sysexbuffers
Array< SysExBuffer, 1 > sysexbuffers
Definition: USBMIDI_Parser.hpp:49
MIDI_Parser
Definition: MIDI_Parser.hpp:22
SysExBuffer.hpp
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
USBMIDI_Parser::receivingSysEx
bool receivingSysEx(uint8_t CN) const
Definition: USBMIDI_Parser.hpp:40
USBMIDI_Parser::getSysExMessage
SysExMessage getSysExMessage() const override
Get the latest SysEx message.
Definition: USBMIDI_Parser.hpp:24
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
USBMIDI_Parser::addSysExByte
bool addSysExByte(uint8_t CN, uint8_t data)
Definition: USBMIDI_Parser.hpp:37
Array.hpp
USBMIDI_Parser
Definition: USBMIDI_Parser.hpp:19
AH::Array
An array wrapper for easy copying, comparing, and iterating.
Definition: Array.hpp:36
MIDIReadEvent
MIDIReadEvent
Result of the MIDI interface read methods.
Definition: MIDI_Parser.hpp:15
USBMIDI_Parser::activeSysExCN
uint8_t activeSysExCN
Definition: USBMIDI_Parser.hpp:45
MIDI_Parser.hpp