33template <
class Derived>
64 case MMT::None:
break;
73 case MMT::KeyPressure:
77 case MMT::ControlChange:
81 case MMT::ProgramChange:
85 case MMT::ChannelPressure:
94 case MMT::MTCQuarterFrame:
95 case MMT::SongPositionPointer:
97 case MMT::UndefinedSysCommon1:
98 case MMT::UndefinedSysCommon2:
99 case MMT::TuneRequest:
101 case MMT::TimingClock:
102 case MMT::UndefinedRealTime1:
106 case MMT::UndefinedRealTime2:
107 case MMT::ActiveSensing:
108 case MMT::SystemReset:
114 CRTP(Derived).onSystemExclusive(msg);
120 case MMT::None:
break;
123 case MMT::KeyPressure:
124 case MMT::ControlChange:
125 case MMT::ProgramChange:
126 case MMT::ChannelPressure:
128 case MMT::SysExStart:
break;
129 case MMT::MTCQuarterFrame:
133 case MMT::SongPositionPointer:
137 case MMT::SongSelect:
140 case MMT::UndefinedSysCommon1:
break;
141 case MMT::UndefinedSysCommon2:
break;
142 case MMT::TuneRequest:
146 case MMT::TimingClock:
147 case MMT::UndefinedRealTime1:
151 case MMT::UndefinedRealTime2:
152 case MMT::ActiveSensing:
153 case MMT::SystemReset:
161 case MMT::None:
break;
164 case MMT::KeyPressure:
165 case MMT::ControlChange:
166 case MMT::ProgramChange:
167 case MMT::ChannelPressure:
169 case MMT::SysExStart:
170 case MMT::MTCQuarterFrame:
171 case MMT::SongPositionPointer:
172 case MMT::SongSelect:
173 case MMT::UndefinedSysCommon1:
174 case MMT::UndefinedSysCommon2:
175 case MMT::TuneRequest:
176 case MMT::SysExEnd:
break;
177 case MMT::TimingClock:
CRTP(Derived).onClock(msg.
getCable());
break;
178 case MMT::UndefinedRealTime1:
break;
179 case MMT::Start:
CRTP(Derived).onStart(msg.
getCable());
break;
180 case MMT::Continue:
CRTP(Derived).onContinue(msg.
getCable());
break;
181 case MMT::Stop:
CRTP(Derived).onStop(msg.
getCable());
break;
182 case MMT::UndefinedRealTime2:
break;
183 case MMT::ActiveSensing:
186 case MMT::SystemReset:
198 template <
class T1,
class R1,
class... Args1,
199 class T2,
class R2,
class... Args2>
200 static constexpr bool same_return_type_and_arguments(R1 (T1::*)(Args1...),
201 R2 (T2::*)(Args2...)) {
202 return std::is_same<Dummy<R1, Args1...>, Dummy<R2, Args2...>>::value;
208 static_assert(std::is_base_of<FineGrainedMIDI_Callbacks, Derived>::value,
"Invalid CRTP");
#define CRTP(Derived)
Helper for the Curiously Recurring Template Pattern.
MIDIMessageType
All possible MIDI status byte values (without channel).
#define BEGIN_CS_NAMESPACE
A type-safe class for MIDI USB Cable numbers.
A type-safe class for MIDI channels.
void onChannelMessage(MIDI_Interface &, ChannelMessage msg) override
Callback for incoming MIDI Channel Messages (notes, control change, pitch bend, etc....
void onTimeCodeQuarterFrame(uint8_t data, Cable cable)
void onPitchBend(Channel channel, uint16_t bend, Cable cable)
void onSysCommonMessage(MIDI_Interface &, SysCommonMessage msg) override
Callback for incoming MIDI System Common Messages.
void onSystemReset(Cable cable)
void onContinue(Cable cable)
void onSystemExclusive(SysExMessage message)
void onActiveSensing(Cable cable)
void onProgramChange(Channel channel, uint8_t program, Cable cable)
void onNoteOff(Channel channel, uint8_t note, uint8_t velocity, Cable cable)
void onStart(Cable cable)
void onRealTimeMessage(MIDI_Interface &, RealTimeMessage msg) override
Callback for incoming MIDI Real-Time Messages.
void onNoteOn(Channel channel, uint8_t note, uint8_t velocity, Cable cable)
void onControlChange(Channel channel, uint8_t controller, uint8_t value, Cable cable)
void onSongPosition(uint16_t beats, Cable cable)
void onTuneRequest(Cable cable)
void onSongSelect(uint8_t songnumber, Cable cable)
void onKeyPressure(Channel channel, uint8_t note, uint8_t pressure, Cable cable)
void onSysExMessage(MIDI_Interface &, SysExMessage msg) override
Callback for incoming MIDI System Exclusive Messages.
void onChannelPressure(Channel channel, uint8_t pressure, Cable cable)
void onClock(Cable cable)
A class for callbacks from MIDI input.
virtual void onChannelMessage(MIDI_Interface &, ChannelMessage)
Callback for incoming MIDI Channel Messages (notes, control change, pitch bend, etc....
virtual ~MIDI_Callbacks()=default
Destructor.
virtual void onSysExMessage(MIDI_Interface &, SysExMessage)
Callback for incoming MIDI System Exclusive Messages.
virtual void onRealTimeMessage(MIDI_Interface &, RealTimeMessage)
Callback for incoming MIDI Real-Time Messages.
virtual void onSysCommonMessage(MIDI_Interface &, SysCommonMessage)
Callback for incoming MIDI System Common Messages.
An abstract class for MIDI interfaces.
MIDIMessageType getMessageType() const
Get the MIDI message type.
Channel getChannel() const
Get the MIDI channel of the message.
Cable getCable() const
Get the MIDI USB cable number of the message.
uint8_t getData1() const
Get the first data byte.
uint16_t getData14bit() const
If Data 1 and Data 2 represent a single 14-bit number, you can use this method to retrieve that numbe...
uint8_t getData2() const
Get the second data byte.
Cable getCable() const
Get the MIDI USB cable number of the message.
MIDIMessageType getMessageType() const
Get the MIDI message type.
MIDIMessageType getMessageType() const
Get the MIDI message type.