libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
MidiEvent.h
Go to the documentation of this file.
1// TODO: make this adjustable
2#define SYSEX_BUFFER_LEN 128
3
4namespace daisy
5{
34
47
60
73
83
84
179{
181};
203{
205};
210{
212};
217{
219};
232{
234};
235
236
240{
241 // Newer ish.
250
253 {
255 m.channel = channel;
256 m.note = data[0];
257 m.velocity = data[1];
258 return m;
259 }
260
263 {
265 m.channel = channel;
266 m.note = data[0];
267 m.velocity = data[1];
268 return m;
269 }
270
273 {
275 m.channel = channel;
276 m.note = data[0];
277 m.pressure = data[1];
278 return m;
279 }
280
283 {
285 m.channel = channel;
286 m.control_number = data[0];
287 m.value = data[1];
288 return m;
289 }
290
293 {
295 m.channel = channel;
296 m.program = data[0];
297 return m;
298 }
299
302 {
304 m.channel = channel;
305 m.pressure = data[0];
306 return m;
307 }
308
311 {
313 m.channel = channel;
314 m.value = ((uint16_t)data[1] << 7) + (data[0] - 8192);
315 return m;
316 }
317
319 {
321
322 m.channel = channel;
323 m.event_type = (ChannelModeType)(data[0] - 120);
324 m.value = data[1];
325
326 return m;
327 }
328
330 {
332 m.length = sysex_message_len;
333 for(int i = 0; i < SYSEX_BUFFER_LEN; i++)
334 {
335 m.data[i] = 0;
336 if(i < m.length)
337 {
338 m.data[i] = sysex_data[i];
339 }
340 }
341 return m;
342 }
344 {
346 m.message_type = (data[0] & 0x70) >> 4;
347 m.value = data[0] & 0x0f;
348 return m;
349 }
351 {
353 m.position = ((uint16_t)data[1] << 7) | data[0];
354 return m;
355 }
357 {
359 m.song = data[0];
360 return m;
361 }
363 {
365 m.channel = channel;
366 return m;
367 }
369 {
371 m.channel = channel;
372 m.value = data[1];
373 return m;
374 }
376 {
378 m.channel = channel;
379 m.local_control_off = data[1] == 0;
380 m.local_control_on = data[1] == 127;
381 return m;
382 }
384 {
386 m.channel = channel;
387 return m;
388 }
390 {
392 m.channel = channel;
393 return m;
394 }
396 {
398 m.channel = channel;
399 return m;
400 }
402 {
404 m.channel = channel;
405 m.num_channels = data[1];
406 return m;
407 }
409 {
411 m.channel = channel;
412 return m;
413 }
414
415 static const char* GetTypeAsString(MidiEvent& msg)
416 {
417 switch(msg.type)
418 {
419 case NoteOff: return "NoteOff";
420 case NoteOn: return "NoteOn";
421 case PolyphonicKeyPressure: return "PolyKeyPres.";
422 case ControlChange: return "CC";
423 case ProgramChange: return "Prog. Change";
424 case ChannelPressure: return "Chn. Pressure";
425 case PitchBend: return "PitchBend";
426 case SystemCommon: return "Sys. Common";
427 case SystemRealTime: return "Sys. Realtime";
428 case ChannelMode: return "Chn. Mode";
429 default: return "Unknown";
430 }
431 }
432};
433
// End midi_events
435
// End midi
437} //namespace daisy
#define SYSEX_BUFFER_LEN
Definition MidiEvent.h:2
Definition leddriver.h:33
SystemRealTimeType
Definition MidiEvent.h:49
SystemCommonType
Definition MidiEvent.h:36
MidiMessageType
Definition MidiEvent.h:21
ChannelModeType
Definition MidiEvent.h:62
@ Continue
Definition MidiEvent.h:53
@ SRTUndefined0
Definition MidiEvent.h:51
@ Reset
Definition MidiEvent.h:57
@ ActiveSensing
Definition MidiEvent.h:56
@ Start
Definition MidiEvent.h:52
@ SystemRealTimeLast
Definition MidiEvent.h:58
@ Stop
Definition MidiEvent.h:54
@ SRTUndefined1
Definition MidiEvent.h:55
@ TimingClock
Definition MidiEvent.h:50
@ SCUndefined1
Definition MidiEvent.h:42
@ MTCQuarterFrame
Definition MidiEvent.h:38
@ SongSelect
Definition MidiEvent.h:40
@ SystemExclusive
Definition MidiEvent.h:37
@ TuneRequest
Definition MidiEvent.h:43
@ SysExEnd
Definition MidiEvent.h:44
@ SystemCommonLast
Definition MidiEvent.h:45
@ SongPositionPointer
Definition MidiEvent.h:39
@ SCUndefined0
Definition MidiEvent.h:41
@ ControlChange
Definition MidiEvent.h:25
@ NoteOff
Definition MidiEvent.h:22
@ PolyphonicKeyPressure
Definition MidiEvent.h:24
@ SystemCommon
Definition MidiEvent.h:29
@ ProgramChange
Definition MidiEvent.h:26
@ MessageLast
Definition MidiEvent.h:32
@ PitchBend
Definition MidiEvent.h:28
@ SystemRealTime
Definition MidiEvent.h:30
@ ChannelPressure
Definition MidiEvent.h:27
@ NoteOn
Definition MidiEvent.h:23
@ ChannelMode
Definition MidiEvent.h:31
@ ResetAllControllers
Definition MidiEvent.h:64
@ PolyModeOn
Definition MidiEvent.h:70
@ LocalControl
Definition MidiEvent.h:65
@ AllNotesOff
Definition MidiEvent.h:66
@ AllSoundOff
Definition MidiEvent.h:63
@ OmniModeOn
Definition MidiEvent.h:68
@ ChannelModeLast
Definition MidiEvent.h:71
@ OmniModeOff
Definition MidiEvent.h:67
@ MonoModeOn
Definition MidiEvent.h:69
Hardware defines and helpers for daisy field platform.
Definition index.h:2
Definition MidiEvent.h:203
int channel
Definition MidiEvent.h:204
Definition MidiEvent.h:179
int channel
Definition MidiEvent.h:180
Definition MidiEvent.h:140
int16_t value
Definition MidiEvent.h:143
ChannelModeType event_type
Definition MidiEvent.h:142
int channel
Definition MidiEvent.h:141
Definition MidiEvent.h:124
int channel
Definition MidiEvent.h:125
uint8_t pressure
Definition MidiEvent.h:126
Definition MidiEvent.h:107
uint8_t value
Definition MidiEvent.h:110
uint8_t control_number
Definition MidiEvent.h:109
int channel
Definition MidiEvent.h:108
Definition MidiEvent.h:194
bool local_control_off
Definition MidiEvent.h:196
int channel
Definition MidiEvent.h:195
bool local_control_on
Definition MidiEvent.h:197
Definition MidiEvent.h:157
uint8_t message_type
Definition MidiEvent.h:158
uint8_t value
Definition MidiEvent.h:159
Definition MidiEvent.h:240
ChannelModeEvent AsChannelMode()
Definition MidiEvent.h:318
PolyphonicKeyPressureEvent AsPolyphonicKeyPressure()
Definition MidiEvent.h:272
PolyModeOnEvent AsPolyModeOn()
Definition MidiEvent.h:408
SystemExclusiveEvent AsSystemExclusive()
Definition MidiEvent.h:329
int channel
Definition MidiEvent.h:243
MTCQuarterFrameEvent AsMTCQuarterFrame()
Definition MidiEvent.h:343
AllSoundOffEvent AsAllSoundOff()
Definition MidiEvent.h:362
SongPositionPointerEvent AsSongPositionPointer()
Definition MidiEvent.h:350
uint8_t sysex_message_len
Definition MidiEvent.h:246
SystemRealTimeType srt_type
Definition MidiEvent.h:248
uint8_t sysex_data[128]
Definition MidiEvent.h:245
ChannelModeType cm_type
Definition MidiEvent.h:249
AllNotesOffEvent AsAllNotesOff()
Definition MidiEvent.h:383
SystemCommonType sc_type
Definition MidiEvent.h:247
ControlChangeEvent AsControlChange()
Definition MidiEvent.h:282
static const char * GetTypeAsString(MidiEvent &msg)
Definition MidiEvent.h:415
OmniModeOnEvent AsOmniModeOn()
Definition MidiEvent.h:395
LocalControlEvent AsLocalControl()
Definition MidiEvent.h:375
ChannelPressureEvent AsChannelPressure()
Definition MidiEvent.h:301
ProgramChangeEvent AsProgramChange()
Definition MidiEvent.h:292
SongSelectEvent AsSongSelect()
Definition MidiEvent.h:356
ResetAllControllersEvent AsResetAllControllers()
Definition MidiEvent.h:368
NoteOffEvent AsNoteOff()
Definition MidiEvent.h:252
uint8_t data[2]
Definition MidiEvent.h:244
OmniModeOffEvent AsOmniModeOff()
Definition MidiEvent.h:389
MidiMessageType type
Definition MidiEvent.h:242
MonoModeOnEvent AsMonoModeOn()
Definition MidiEvent.h:401
NoteOnEvent AsNoteOn()
Definition MidiEvent.h:262
PitchBendEvent AsPitchBend()
Definition MidiEvent.h:310
Definition MidiEvent.h:224
uint8_t num_channels
Definition MidiEvent.h:226
int channel
Definition MidiEvent.h:225
Definition MidiEvent.h:78
int channel
Definition MidiEvent.h:79
uint8_t note
Definition MidiEvent.h:80
uint8_t velocity
Definition MidiEvent.h:81
Definition MidiEvent.h:89
uint8_t velocity
Definition MidiEvent.h:92
int channel
Definition MidiEvent.h:90
uint8_t note
Definition MidiEvent.h:91
Definition MidiEvent.h:210
int channel
Definition MidiEvent.h:211
Definition MidiEvent.h:217
int channel
Definition MidiEvent.h:218
Definition MidiEvent.h:132
int channel
Definition MidiEvent.h:133
int16_t value
Definition MidiEvent.h:134
Definition MidiEvent.h:232
int channel
Definition MidiEvent.h:233
Definition MidiEvent.h:98
uint8_t pressure
Definition MidiEvent.h:101
uint8_t note
Definition MidiEvent.h:100
int channel
Definition MidiEvent.h:99
Definition MidiEvent.h:116
int channel
Definition MidiEvent.h:117
uint8_t program
Definition MidiEvent.h:118
Definition MidiEvent.h:186
int channel
Definition MidiEvent.h:187
uint8_t value
Definition MidiEvent.h:188
Definition MidiEvent.h:165
uint16_t position
Definition MidiEvent.h:166
Definition MidiEvent.h:172
uint8_t song
Definition MidiEvent.h:173
Definition MidiEvent.h:149
int length
Definition MidiEvent.h:150
uint8_t data[128]
Definition MidiEvent.h:151