Nanomidi
Simple stream-based MIDI message encoder and decoder
messages.h
Go to the documentation of this file.
1 /*
2  * This file is part of nanomidi.
3  *
4  * Copyright (C) 2018 Adam Heinrich <adam@adamh.cz>
5  *
6  * Nanomidi is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Nanomidi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with nanomidi. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef NANOMIDI_MESSAGES_H
21 #define NANOMIDI_MESSAGES_H
22 
23 #include <stddef.h>
24 #include <stdint.h>
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
38 enum midi_type {
53 
62 
75 
80 };
81 
83 struct midi_message {
87  uint8_t channel;
88 
90  union data {
93  struct note_on {
94  uint8_t note;
95  uint8_t velocity;
96  } note_on;
97 
99  struct note_off {
100  uint8_t note;
101  uint8_t velocity;
102  } note_off;
103 
106  uint8_t note;
107  uint8_t pressure;
109 
111  struct control_change {
112  uint8_t controller;
113  uint8_t value;
114  } control_change;
115 
117  struct program_change {
118  uint8_t program;
119  } program_change;
120 
123  uint8_t pressure;
125 
127  struct pitch_bend {
128  uint16_t value;
129  } pitch_bend;
130 
133  uint8_t value; /*< Time code value (0-127) */
135 
137  struct song_position {
138  uint16_t position;
139  } song_position;
140 
142  struct song_select {
143  uint8_t song;
144  } song_select;
145 
149  struct sysex {
150  const void *data;
151  size_t length;
152  } sysex;
153  } data;
154 };
155 
158 #ifdef __cplusplus
159 }
160 #endif
161 
162 #endif /* NANOMIDI_MESSAGES_H */
Representation of MIDI_TYPE_SYSEX.
Definition: messages.h:149
struct midi_message::data::program_change program_change
Representation of MIDI_TYPE_CONTROL_CHANGE.
Definition: messages.h:111
Channel Mode: Pitch Bend Change.
Definition: messages.h:52
MIDI message data structure.
Definition: messages.h:83
uint8_t pressure
Pressure value (0-127)
Definition: messages.h:123
uint8_t note
Note code (0-127)
Definition: messages.h:100
Representation of MIDI_TYPE_TIME_CODE_QUARTER_FRAME.
Definition: messages.h:132
Channel Mode: Program Change.
Definition: messages.h:48
struct midi_message::data::sysex sysex
uint16_t position
Song position pointer (0-16383)
Definition: messages.h:138
uint8_t velocity
Note velocity (1-127)
Definition: messages.h:95
System Common: MIDI Time Code Quarter Time.
Definition: messages.h:55
System Real Time: Continue.
Definition: messages.h:68
Channel Mode: Note On.
Definition: messages.h:42
uint8_t value
Definition: messages.h:133
Representation of MIDI_TYPE_SONG_SELECT.
Definition: messages.h:142
System Real Time: Timing Clock.
Definition: messages.h:64
Representation of MIDI_TYPE_CHANNEL_PRESSURE.
Definition: messages.h:122
struct midi_message::data::time_code_quarter_frame time_code_quarter_frame
uint16_t value
Pitch bend change value (0-16383)
Definition: messages.h:128
Alias for MIDI_TYPE_SYSEX.
Definition: messages.h:79
struct midi_message::data::note_on note_on
System Real Time: Active Sensing.
Definition: messages.h:72
Channel Mode: Channel Pressure (Aftertouch)
Definition: messages.h:50
Representation of MIDI_TYPE_NOTE_ON.
Definition: messages.h:93
System Real Time: Stop.
Definition: messages.h:70
union midi_message::data data
MIDI message data representation.
struct midi_message::data::song_select song_select
System Common: Tune Request.
Definition: messages.h:61
System Real Time: System Reset.
Definition: messages.h:74
const void * data
Pointer to SysEx data.
Definition: messages.h:150
Representation of MIDI_TYPE_NOTE_OFF.
Definition: messages.h:99
System Common: Song Select.
Definition: messages.h:59
Channel Mode: Polyphonic Pressure (Aftertouch)
Definition: messages.h:44
Channel Mode: Control Change.
Definition: messages.h:46
uint8_t velocity
Note velocity (0-127)
Definition: messages.h:101
size_t length
Length of data in bytes.
Definition: messages.h:151
uint8_t program
Program number (0-127)
Definition: messages.h:118
struct midi_message::data::polyphonic_pressure polyphonic_pressure
midi_type
MIDI message types.
Definition: messages.h:38
uint8_t note
Note code (0-127)
Definition: messages.h:94
Representation of MIDI_TYPE_PITCH_BEND.
Definition: messages.h:127
struct midi_message::data::note_off note_off
struct midi_message::data::pitch_bend pitch_bend
Representation of MIDI_TYPE_SONG_POSITION.
Definition: messages.h:137
struct midi_message::data::song_position song_position
struct midi_message::data::control_change control_change
Representation of MIDI_TYPE_PROGRAM_CHANGE.
Definition: messages.h:117
uint8_t pressure
Pressure value (0-127)
Definition: messages.h:107
Channel Mode: Note Off.
Definition: messages.h:40
System Exclusive Message (SysEx)
Definition: messages.h:77
struct midi_message::data::channel_pressure channel_pressure
uint8_t controller
Control number (0-127)
Definition: messages.h:112
uint8_t song
Song number (0-127)
Definition: messages.h:143
Representation of MIDI_TYPE_POLYPHONIC_PRESSURE.
Definition: messages.h:105
uint8_t note
Note code (0-127)
Definition: messages.h:106
uint8_t channel
Channel (1-16) for Channel Mode Messages, 0 for other messages.
Definition: messages.h:87
System Real Time: Start.
Definition: messages.h:66
enum midi_type type
MIDI message type.
Definition: messages.h:85
uint8_t value
Control value (0-127)
Definition: messages.h:113
System Common: Song Position Pointer.
Definition: messages.h:57
MIDI message data representation.
Definition: messages.h:90