Arduino MIDI Library  Version 5.0.1
midi_Defs.h
Go to the documentation of this file.
1 
28 #pragma once
29 
30 #include "midi_Namespace.h"
31 
32 #if ARDUINO
33 #include <Arduino.h>
34 #else
35 #include <inttypes.h>
36 typedef uint8_t byte;
37 #endif
38 
40 
41 // -----------------------------------------------------------------------------
42 
43 #define MIDI_CHANNEL_OMNI 0
44 #define MIDI_CHANNEL_OFF 17 // and over
45 
46 #define MIDI_PITCHBEND_MIN -8192
47 #define MIDI_PITCHBEND_MAX 8191
48 
51 static const uint16_t ActiveSensingTimeout = 300;
52 
53 // -----------------------------------------------------------------------------
54 // Type definitions
55 
56 typedef byte StatusByte;
57 typedef byte DataByte;
58 typedef byte Channel;
59 typedef byte FilterMode;
60 
61 // -----------------------------------------------------------------------------
62 // Errors
63 static const uint8_t ErrorParse = 0;
64 static const uint8_t ErrorActiveSensingTimeout = 1;
65 static const uint8_t WarningSplitSysEx = 2;
66 
67 // -----------------------------------------------------------------------------
68 // Aliasing
69 
70 using ErrorCallback = void (*)(int8_t);
71 using NoteOffCallback = void (*)(Channel channel, byte note, byte velocity);
72 using NoteOnCallback = void (*)(Channel channel, byte note, byte velocity);
73 using AfterTouchPolyCallback = void (*)(Channel channel, byte note, byte velocity);
74 using ControlChangeCallback = void (*)(Channel channel, byte, byte);
75 using ProgramChangeCallback = void (*)(Channel channel, byte);
76 using AfterTouchChannelCallback = void (*)(Channel channel, byte);
77 using PitchBendCallback = void (*)(Channel channel, int);
78 using SystemExclusiveCallback = void (*)(byte * array, unsigned size);
79 using TimeCodeQuarterFrameCallback = void (*)(byte data);
80 using SongPositionCallback = void (*)(unsigned beats);
81 using SongSelectCallback = void (*)(byte songnumber);
82 using TuneRequestCallback = void (*)(void);
83 using ClockCallback = void (*)(void);
84 using StartCallback = void (*)(void);
85 using TickCallback = void (*)(void);
86 using ContinueCallback = void (*)(void);
87 using StopCallback = void (*)(void);
88 using ActiveSensingCallback = void (*)(void);
89 using SystemResetCallback = void (*)(void);
90 
91 // -----------------------------------------------------------------------------
92 
94 enum MidiType: uint8_t
95 {
96  InvalidType = 0x00,
97  NoteOff = 0x80,
98  NoteOn = 0x90,
99  AfterTouchPoly = 0xA0,
100  ControlChange = 0xB0,
101  ProgramChange = 0xC0,
103  PitchBend = 0xE0,
107  SongPosition = 0xF2,
108  SongSelect = 0xF3,
109  Undefined_F4 = 0xF4,
110  Undefined_F5 = 0xF5,
111  TuneRequest = 0xF6,
113  Clock = 0xF8,
114  Undefined_F9 = 0xF9,
116  Start = 0xFA,
117  Continue = 0xFB,
118  Stop = 0xFC,
119  Undefined_FD = 0xFD,
120  ActiveSensing = 0xFE,
121  SystemReset = 0xFF,
122 };
123 
124 // -----------------------------------------------------------------------------
125 
127 struct Thru
128 {
129  enum Mode
130  {
131  Off = 0,
132  Full = 1,
135  };
136 };
137 
138 // -----------------------------------------------------------------------------
139 
145 {
146  // High resolution Continuous Controllers MSB (+32 for LSB) ----------------
150  // CC3 undefined
155  Balance = 8,
156  // CC9 undefined
157  Pan = 10,
161  // CC14 undefined
162  // CC15 undefined
167 
169 
170  // Switches ----------------------------------------------------------------
171  Sustain = 64,
173  Sostenuto = 66,
174  SoftPedal = 67,
175  Legato = 68,
176  Hold = 69,
177 
178  // Low resolution continuous controllers -----------------------------------
194  // CC85 to CC90 undefined
195  Effects1 = 91,
196  Effects2 = 92,
197  Effects3 = 93,
198  Effects4 = 94,
199  Effects5 = 95,
202  NRPNLSB = 98,
203  NRPNMSB = 99,
204  RPNLSB = 100,
205  RPNMSB = 101,
206 
207  // Channel Mode messages ---------------------------------------------------
208  AllSoundOff = 120,
211  AllNotesOff = 123,
212  OmniModeOff = 124,
213  OmniModeOn = 125,
214  MonoModeOn = 126,
215  PolyModeOn = 127
216 };
217 
218 struct RPN
219 {
221  {
228  NullFunction = (0x7f << 7) + 0x7f,
229  };
230 };
231 
RPN::RegisteredParameterNumbers
RegisteredParameterNumbers
Definition: midi_Defs.h:221
Undefined_F4
@ Undefined_F4
Definition: midi_Defs.h:109
GeneralPurposeController7
@ GeneralPurposeController7
Definition: midi_Defs.h:191
Clock
@ Clock
System Real Time - Timing Clock.
Definition: midi_Defs.h:113
ModulationWheel
@ ModulationWheel
Definition: midi_Defs.h:148
SongSelectCallback
void(*)(byte songnumber) SongSelectCallback
Definition: midi_Defs.h:81
ChannelVolume
@ ChannelVolume
Definition: midi_Defs.h:154
GeneralPurposeController5
@ GeneralPurposeController5
Definition: midi_Defs.h:189
SystemReset
@ SystemReset
System Real Time - System Reset.
Definition: midi_Defs.h:121
SystemExclusive
@ SystemExclusive
System Exclusive.
Definition: midi_Defs.h:104
Legato
@ Legato
Definition: midi_Defs.h:175
NoteOnCallback
void(*)(Channel channel, byte note, byte velocity) NoteOnCallback
Definition: midi_Defs.h:72
TuneRequest
@ TuneRequest
System Common - Tune Request.
Definition: midi_Defs.h:111
Thru::Mode
Mode
Definition: midi_Defs.h:130
Balance
@ Balance
Definition: midi_Defs.h:155
Effects2
@ Effects2
Tremolo depth.
Definition: midi_Defs.h:196
ErrorActiveSensingTimeout
static const uint8_t ErrorActiveSensingTimeout
Definition: midi_Defs.h:64
PitchBendCallback
void(*)(Channel channel, int) PitchBendCallback
Definition: midi_Defs.h:77
EffectControl1
@ EffectControl1
Definition: midi_Defs.h:159
ProgramChangeCallback
void(*)(Channel channel, byte) ProgramChangeCallback
Definition: midi_Defs.h:75
ActiveSensingTimeout
static const uint16_t ActiveSensingTimeout
Definition: midi_Defs.h:51
WarningSplitSysEx
static const uint8_t WarningSplitSysEx
Definition: midi_Defs.h:65
SoundController9
@ SoundController9
Synth: Vibrato Delay FX: Flange/Chorus On/Off.
Definition: midi_Defs.h:187
Effects1
@ Effects1
Reverb send level.
Definition: midi_Defs.h:195
DataEntryLSB
@ DataEntryLSB
Definition: midi_Defs.h:168
StartCallback
void(*)(void) StartCallback
Definition: midi_Defs.h:84
PortamentoControl
@ PortamentoControl
Definition: midi_Defs.h:193
byte
uint8_t byte
Definition: midi_Defs.h:36
PolyModeOn
@ PolyModeOn
Definition: midi_Defs.h:215
Undefined_F5
@ Undefined_F5
Definition: midi_Defs.h:110
Effects3
@ Effects3
Chorus send level.
Definition: midi_Defs.h:197
SoftPedal
@ SoftPedal
Definition: midi_Defs.h:174
Portamento
@ Portamento
Definition: midi_Defs.h:172
OmniModeOn
@ OmniModeOn
Definition: midi_Defs.h:213
SongPositionCallback
void(*)(unsigned beats) SongPositionCallback
Definition: midi_Defs.h:80
GeneralPurposeController8
@ GeneralPurposeController8
Definition: midi_Defs.h:192
ProgramChange
@ ProgramChange
Channel Message - Program Change.
Definition: midi_Defs.h:101
END_MIDI_NAMESPACE
#define END_MIDI_NAMESPACE
Definition: midi_Namespace.h:32
Start
@ Start
System Real Time - Start.
Definition: midi_Defs.h:116
RPN::NullFunction
@ NullFunction
Definition: midi_Defs.h:228
InvalidType
@ InvalidType
For notifying errors.
Definition: midi_Defs.h:96
AfterTouchPolyCallback
void(*)(Channel channel, byte note, byte velocity) AfterTouchPolyCallback
Definition: midi_Defs.h:73
DataIncrement
@ DataIncrement
Definition: midi_Defs.h:200
SystemExclusiveStart
@ SystemExclusiveStart
System Exclusive Start.
Definition: midi_Defs.h:105
Thru::Off
@ Off
Thru disabled (nothing passes through).
Definition: midi_Defs.h:131
Undefined_F9
@ Undefined_F9
Definition: midi_Defs.h:114
ExpressionController
@ ExpressionController
Definition: midi_Defs.h:158
AllNotesOff
@ AllNotesOff
Definition: midi_Defs.h:211
MonoModeOn
@ MonoModeOn
Definition: midi_Defs.h:214
ErrorCallback
void(*)(int8_t) ErrorCallback
Definition: midi_Defs.h:70
AfterTouchPoly
@ AfterTouchPoly
Channel Message - Polyphonic AfterTouch.
Definition: midi_Defs.h:99
Effects4
@ Effects4
Celeste depth.
Definition: midi_Defs.h:198
FilterMode
byte FilterMode
Definition: midi_Defs.h:59
ActiveSensingCallback
void(*)(void) ActiveSensingCallback
Definition: midi_Defs.h:88
Sustain
@ Sustain
Definition: midi_Defs.h:171
SoundController10
@ SoundController10
Synth: Undefined FX: Special Effects On/Off.
Definition: midi_Defs.h:188
Thru::SameChannel
@ SameChannel
Only the messages on the Input Channel will be sent back.
Definition: midi_Defs.h:133
TuneRequestCallback
void(*)(void) TuneRequestCallback
Definition: midi_Defs.h:82
TimeCodeQuarterFrame
@ TimeCodeQuarterFrame
System Common - MIDI Time Code Quarter Frame.
Definition: midi_Defs.h:106
Undefined_FD
@ Undefined_FD
Definition: midi_Defs.h:119
TimeCodeQuarterFrameCallback
void(*)(byte data) TimeCodeQuarterFrameCallback
Definition: midi_Defs.h:79
SoundController1
@ SoundController1
Synth: Sound Variation FX: Exciter On/Off.
Definition: midi_Defs.h:179
BankSelect
@ BankSelect
Definition: midi_Defs.h:147
RPN::SelectTuningProgram
@ SelectTuningProgram
Definition: midi_Defs.h:225
StatusByte
byte StatusByte
Definition: midi_Defs.h:56
ErrorParse
static const uint8_t ErrorParse
Definition: midi_Defs.h:63
GeneralPurposeController4
@ GeneralPurposeController4
Definition: midi_Defs.h:166
AfterTouchChannelCallback
void(*)(Channel channel, byte) AfterTouchChannelCallback
Definition: midi_Defs.h:76
Effects5
@ Effects5
Phaser depth.
Definition: midi_Defs.h:199
GeneralPurposeController2
@ GeneralPurposeController2
Definition: midi_Defs.h:164
RPNLSB
@ RPNLSB
Registered Parameter Number (LSB)
Definition: midi_Defs.h:204
midi_Namespace.h
MIDI Library for the Arduino - Namespace declaration.
ContinueCallback
void(*)(void) ContinueCallback
Definition: midi_Defs.h:86
NoteOn
@ NoteOn
Channel Message - Note On.
Definition: midi_Defs.h:98
Pan
@ Pan
Definition: midi_Defs.h:157
Continue
@ Continue
System Real Time - Continue.
Definition: midi_Defs.h:117
NoteOff
@ NoteOff
Channel Message - Note Off.
Definition: midi_Defs.h:97
OmniModeOff
@ OmniModeOff
Definition: midi_Defs.h:212
BreathController
@ BreathController
Definition: midi_Defs.h:149
SystemExclusiveCallback
void(*)(byte *array, unsigned size) SystemExclusiveCallback
Definition: midi_Defs.h:78
SystemResetCallback
void(*)(void) SystemResetCallback
Definition: midi_Defs.h:89
ClockCallback
void(*)(void) ClockCallback
Definition: midi_Defs.h:83
RPN::SelectTuningBank
@ SelectTuningBank
Definition: midi_Defs.h:226
RPN
Definition: midi_Defs.h:219
StopCallback
void(*)(void) StopCallback
Definition: midi_Defs.h:87
SoundController8
@ SoundController8
Synth: Vibrato Depth FX: Pitch Transpose On/Off.
Definition: midi_Defs.h:186
SoundController7
@ SoundController7
Synth: Vibrato Rate FX: Delay On/Off.
Definition: midi_Defs.h:185
GeneralPurposeController3
@ GeneralPurposeController3
Definition: midi_Defs.h:165
SongSelect
@ SongSelect
System Common - Song Select.
Definition: midi_Defs.h:108
ActiveSensing
@ ActiveSensing
System Real Time - Active Sensing.
Definition: midi_Defs.h:120
RPN::ChannelFineTuning
@ ChannelFineTuning
Definition: midi_Defs.h:223
MidiType
MidiType
Definition: midi_Defs.h:95
Thru::DifferentChannel
@ DifferentChannel
All the messages but the ones on the Input Channel will be sent back.
Definition: midi_Defs.h:134
BEGIN_MIDI_NAMESPACE
#define BEGIN_MIDI_NAMESPACE
Definition: midi_Namespace.h:31
PitchBend
@ PitchBend
Channel Message - Pitch Bend.
Definition: midi_Defs.h:103
SoundController5
@ SoundController5
Synth: Brightness FX: Expander On/Off.
Definition: midi_Defs.h:183
Channel
byte Channel
Definition: midi_Defs.h:58
GeneralPurposeController6
@ GeneralPurposeController6
Definition: midi_Defs.h:190
RPN::PitchBendSensitivity
@ PitchBendSensitivity
Definition: midi_Defs.h:222
Sostenuto
@ Sostenuto
Definition: midi_Defs.h:173
Thru::Full
@ Full
Fully enabled Thru (every incoming message is sent back).
Definition: midi_Defs.h:132
RPN::ChannelCoarseTuning
@ ChannelCoarseTuning
Definition: midi_Defs.h:224
Stop
@ Stop
System Real Time - Stop.
Definition: midi_Defs.h:118
FootController
@ FootController
Definition: midi_Defs.h:151
Tick
@ Tick
System Real Time - Timing Tick (1 tick = 10 milliseconds)
Definition: midi_Defs.h:115
ControlChange
@ ControlChange
Channel Message - Control Change / Channel Mode.
Definition: midi_Defs.h:100
Thru
Definition: midi_Defs.h:128
ControlChangeCallback
void(*)(Channel channel, byte, byte) ControlChangeCallback
Definition: midi_Defs.h:74
MidiControlChangeNumber
MidiControlChangeNumber
Enumeration of Control Change command numbers. See the detailed controllers numbers & description her...
Definition: midi_Defs.h:145
SoundController3
@ SoundController3
Synth: Release Time FX: Distortion On/Off.
Definition: midi_Defs.h:181
NRPNLSB
@ NRPNLSB
Non-Registered Parameter Number (LSB)
Definition: midi_Defs.h:202
GeneralPurposeController1
@ GeneralPurposeController1
Definition: midi_Defs.h:163
SystemExclusiveEnd
@ SystemExclusiveEnd
System Exclusive End.
Definition: midi_Defs.h:112
SongPosition
@ SongPosition
System Common - Song Position Pointer.
Definition: midi_Defs.h:107
TickCallback
void(*)(void) TickCallback
Definition: midi_Defs.h:85
RPN::ModulationDepthRange
@ ModulationDepthRange
Definition: midi_Defs.h:227
RPNMSB
@ RPNMSB
Registered Parameter Number (MSB)
Definition: midi_Defs.h:205
SoundController2
@ SoundController2
Synth: Harmonic Content FX: Compressor On/Off.
Definition: midi_Defs.h:180
SoundController6
@ SoundController6
Synth: Decay Time FX: Reverb On/Off.
Definition: midi_Defs.h:184
ResetAllControllers
@ ResetAllControllers
Definition: midi_Defs.h:209
DataDecrement
@ DataDecrement
Definition: midi_Defs.h:201
AfterTouchChannel
@ AfterTouchChannel
Channel Message - Channel (monophonic) AfterTouch.
Definition: midi_Defs.h:102
AllSoundOff
@ AllSoundOff
Definition: midi_Defs.h:208
NRPNMSB
@ NRPNMSB
Non-Registered Parameter Number (MSB)
Definition: midi_Defs.h:203
NoteOffCallback
void(*)(Channel channel, byte note, byte velocity) NoteOffCallback
Definition: midi_Defs.h:71
DataEntryMSB
@ DataEntryMSB
Definition: midi_Defs.h:153
EffectControl2
@ EffectControl2
Definition: midi_Defs.h:160
Hold
@ Hold
Definition: midi_Defs.h:176
PortamentoTime
@ PortamentoTime
Definition: midi_Defs.h:152
SoundController4
@ SoundController4
Synth: Attack Time FX: EQ On/Off.
Definition: midi_Defs.h:182
LocalControl
@ LocalControl
Definition: midi_Defs.h:210
DataByte
byte DataByte
Definition: midi_Defs.h:57