114 template <
class MIDIInterface_t>
117 template <
class MIDIInterface_t>
122 template <
class MIDIInterface_t>
132template <
class MIDIInterface_t>
138 event = self->read();
144 if (self->getStaller() == self)
146 int16_t size_rem = 512 * 3 / 4;
147 bool chunked =
false;
151 size_rem -= self->getSysExMessage().length;
154 size_rem -= self->getSysExMessage().length;
161 event = self->read();
171template <
class MIDIInterface_t>
176 self->onChannelMessage(self->getChannelMessage());
180 self->onSysExMessage(self->getSysExMessage());
183 self->onSysCommonMessage(self->getSysCommonMessage());
186 self->onRealTimeMessage(self->getRealTimeMessage());
194template <
class MIDIInterface_t>
196 const char *staller_name = self->getStallerName();
197 DEBUGFN(F(
"Handling stall. Cause: ") << staller_name);
200 unsigned long startTime = millis();
205 startTime = millis();
209 DEBUGFN(F(
"Warning: Unable to un-stall pipes. Cause: ") << staller_name);
210 static_cast<void>(staller_name);
MIDIReadEvent
Values returned by the MIDI reading functions.
@ CHANNEL_MESSAGE
A MIDI Channel message was received.
@ SYSEX_CHUNK
An incomplete System Exclusive message.
@ SYSCOMMON_MESSAGE
A MIDI System Common message was received.
@ NO_MESSAGE
No new messages were received.
@ SYSEX_MESSAGE
A MIDI System Exclusive message was received.
@ REALTIME_MESSAGE
A MIDI Real-Time message was received.
#define BEGIN_CS_NAMESPACE
constexpr unsigned long SYSEX_CHUNK_TIMEOUT
Timeout in milliseconds to wait for a SysEx chunk to complete.
A super class for object that have to be updated regularly.
A class for callbacks from MIDI input.
An abstract class for MIDI interfaces.
void onSysCommonMessage(SysCommonMessage message)
Call the System Common message callback and send the message to the sink pipe.
virtual void sendSysCommonImpl(SysCommonMessage)=0
Low-level function for sending a MIDI system common message.
virtual void sendRealTimeImpl(RealTimeMessage)=0
Low-level function for sending a MIDI real-time message.
virtual void sendNowImpl()=0
Low-level function for sending any buffered outgoing MIDI messages.
void sinkMIDIfromPipe(SysCommonMessage msg) override
Accept an incoming MIDI System Common message from the source pipe.
virtual ~MIDI_Interface()
Destructor.
virtual void sendChannelMessageImpl(ChannelMessage)=0
Low-level function for sending a MIDI channel voice message.
virtual void sendSysExImpl(SysExMessage)=0
Low-level function for sending a system exclusive MIDI message.
void sinkMIDIfromPipe(RealTimeMessage msg) override
Accept an incoming MIDI Real-Time message from the source pipe.
void begin() override
Initialize the MIDI Interface.
static void dispatchIncoming(MIDIInterface_t *iface, MIDIReadEvent event)
Dispatch the given type of MIDI message from the given interface.
void setAsDefault()
Set this MIDI interface as the default interface.
void sinkMIDIfromPipe(ChannelMessage msg) override
Accept an incoming MIDI Channel message from the source pipe.
MIDI_Callbacks * callbacks
void onSysExMessage(SysExMessage message)
Call the SysEx message callback and send the message to the sink pipe.
void onRealTimeMessage(RealTimeMessage message)
Call the real-time message callback and send the message to the sink pipe.
static MIDI_Interface * DefaultMIDI_Interface
static void updateIncoming(MIDIInterface_t *iface)
Read, parse and dispatch incoming MIDI messages on the given interface.
void setCallbacks(MIDI_Callbacks *cb)
Set the callbacks that will be called when a MIDI message is received.
void onChannelMessage(ChannelMessage message)
Call the channel message callback and send the message to the sink pipe.
static MIDI_Interface * getDefault()
Return the default MIDI interface.
void sinkMIDIfromPipe(SysExMessage msg) override
Accept an incoming MIDI System Exclusive message from the source pipe.
void update() override=0
Read the MIDI interface and call the callback if a message was received.
MIDI_Interface(MIDI_Interface &&)=default
Statically polymorphic template for classes that send MIDI messages.
void send(ChannelMessage message)
Send a MIDI Channel Voice message.
#define DEBUGFN(x)
Print an expression and its function (function name and line number) to the debug output if debugging...
Struct that can cause a MIDI_Pipe to be stalled.
virtual void handleStall()=0
Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI so...
A struct that is both a TrueMIDI_Sink and a TrueMIDI_Source.