2 #include "RingBuffer.h"
9 enum midi_parser_status {
10 MIDI_PARSER_DELAY = -3,
12 MIDI_PARSER_ERROR = -1,
14 MIDI_PARSER_HEADER = 1,
15 MIDI_PARSER_TRACK = 2,
16 MIDI_PARSER_TRACK_MIDI = 3,
17 MIDI_PARSER_TRACK_META = 4,
18 MIDI_PARSER_TRACK_SYSEX = 5,
21 enum midi_file_format {
22 MIDI_FILE_FORMAT_SINGLE_TRACK = 0,
23 MIDI_FILE_FORMAT_MULTIPLE_TRACKS = 1,
24 MIDI_FILE_FORMAT_MULTIPLE_SONGS = 2,
34 int16_t time_division;
47 MIDI_STATUS_NOTE_OFF = 0x8,
48 MIDI_STATUS_NOTE_ON = 0x9,
49 MIDI_STATUS_NOTE_AT = 0xA,
51 MIDI_STATUS_PGM_CHANGE = 0xC,
52 MIDI_STATUS_CHANNEL_AT = 0xD,
53 MIDI_STATUS_PITCH_BEND = 0xE,
60 MIDI_META_SEQ_NUM = 0x00,
61 MIDI_META_TEXT = 0x01,
62 MIDI_META_COPYRIGHT = 0x02,
63 MIDI_META_TRACK_NAME = 0x03,
64 MIDI_META_INSTRUMENT_NAME = 0x04,
65 MIDI_META_LYRICS = 0x05,
66 MIDI_META_MAKER = 0x06,
67 MIDI_META_CUE_POINT = 0x07,
68 MIDI_META_CHANNEL_PREFIX = 0x20,
69 MIDI_META_END_OF_TRACK = 0x2F,
70 MIDI_META_SET_TEMPO = 0x51,
71 MIDI_META_SMPTE_OFFSET = 0x54,
72 MIDI_META_TIME_SIGNATURE = 0x58,
73 MIDI_META_KEY_SIGNATURE = 0x59,
74 MIDI_META_SEQ_SPECIFIC = 0x7F,
93 operator bool() {
return status != 0; }
103 const uint8_t *bytes;
113 const uint8_t *bytes;
122 this->status = status;
124 enum midi_parser_status status;
125 enum midi_parser_status status_internal;
126 enum midi_status buffered_status;
127 unsigned buffered_channel;
136 uint64_t tempo = 1000;
143 int64_t timeInTicks() {
147 uint64_t timeInMs() {
148 if (vtime_ms!=0)
return vtime_ms;
149 float ticks_per_quarter = header.time_division!=0 ? header.time_division: 48;
150 float us_per_quarter = tempo;
151 float us_per_tick = us_per_quarter / ticks_per_quarter;
152 float milliseconds = timeInTicks() * us_per_tick / 1000;
RingBuffer that supports extensive peek operations to access and compare the next values.
Definition: RingBuffer.h:16
MIDI Event Information.
Definition: MidiFileParserState.h:80
MIDI Parser State Information.
Definition: MidiFileParserState.h:119
MIDI Sysex Event Information.
Definition: MidiFileParserState.h:109
Definition: MidiFileParserState.h:90
uint64_t time_ms
cummulated time in milliseconds
Definition: MidiFileParserState.h:92
MIDI Track Information.
Definition: MidiFileParserState.h:40