Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
MIDI_Interface.cpp
Go to the documentation of this file.
1#include "MIDI_Interface.hpp"
2#include "MIDI_Callbacks.hpp"
3
5
6// -------------------------------------------------------------------------- //
7
8// Managing the default MIDI interface
9
14
16
17#ifndef ARDUINO
18#define DOWN_CAST dynamic_cast
19#else
20#define DOWN_CAST static_cast
21#endif
22
24 return DefaultMIDI_Interface == nullptr
25 ? DOWN_CAST<MIDI_Interface *>(updatables.getLast())
27}
28
30
31// -------------------------------------------------------------------------- //
32
33// Handling incoming MIDI events
34
36 sourceMIDItoPipe(message);
37 if (callbacks)
38 callbacks->onChannelMessage(*this, message);
39}
40
42 sourceMIDItoPipe(message);
43 if (callbacks)
44 callbacks->onSysExMessage(*this, message);
45}
46
52
54 sourceMIDItoPipe(message);
55 if (callbacks)
56 callbacks->onRealTimeMessage(*this, message);
57}
58
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
static DoublyLinkedList< Derived > updatables
virtual void onChannelMessage(MIDI_Interface &, ChannelMessage)
Callback for incoming MIDI Channel Messages (notes, control change, pitch bend, etc....
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.
void onSysCommonMessage(SysCommonMessage message)
Call the System Common message callback and send the message to the sink pipe.
virtual ~MIDI_Interface()
Destructor.
void setAsDefault()
Set this MIDI interface as the default interface.
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
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 sourceMIDItoPipe(ChannelMessage)
Send a MIDI Channel Message down the pipe.