libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
midi_parser.h
Go to the documentation of this file.
1#pragma once
2#ifndef DSY_MIDI_PARSER_H
3#define DSY_MIDI_PARSER_H
4
5#include <stdint.h>
6#include <stdlib.h>
7#include "hid/MidiEvent.h"
8
9namespace daisy
10{
16{
17 public:
20
21 inline void Init() { Reset(); }
22
35
39 void Reset();
40
41 private:
42 enum ParserState
43 {
44 ParserEmpty,
45 ParserHasStatus,
46 ParserHasData0,
47 ParserSysEx,
48 };
49
50 ParserState pstate_;
51 MidiEvent incoming_message_;
52 MidiMessageType running_status_;
53
54 // Masks to check for message type, and byte content
55 const uint8_t kStatusByteMask = 0x80;
56 const uint8_t kMessageMask = 0x70;
57 const uint8_t kDataByteMask = 0x7F;
58 const uint8_t kChannelMask = 0x0F;
59 const uint8_t kSystemRealTimeMask = 0x07;
60};
61
62} // namespace daisy
63
64#endif
Definition leddriver.h:33
Utility class for parsing raw byte streams into MIDI messages.
Definition midi_parser.h:16
MidiParser()
Definition midi_parser.h:18
~MidiParser()
Definition midi_parser.h:19
void Reset()
Reset parser to default state.
bool Parse(uint8_t byte, MidiEvent *event_out)
Parse one MIDI byte. If the byte completes a parsed event, its value will be assigned to the derefere...
void Init()
Definition midi_parser.h:21
MidiMessageType
Definition MidiEvent.h:21
Hardware defines and helpers for daisy field platform.
Definition index.h:2
Definition MidiEvent.h:240