#include <Control_Surface/Control_Surface_Class.hpp>
This class ensures initialization, updating, and interaction between all other classes, it's the glue that holds everything together.
Definition at line 26 of file Control_Surface_Class.hpp.
MIDI Input Callbacks | |
using | ChannelMessageCallback = bool (*)(ChannelMessage) |
Callback function type for channel messages. | |
using | SysExMessageCallback = bool (*)(SysExMessage) |
Callback function type for SysEx messages. | |
using | SysCommonMessageCallback = bool (*)(SysCommonMessage) |
Callback function type for System Common messages. | |
using | RealTimeMessageCallback = bool (*)(RealTimeMessage) |
Callback function type for Real-Time messages. | |
void | setMIDIInputCallbacks (ChannelMessageCallback channelMessageCallback, SysExMessageCallback sysExMessageCallback, SysCommonMessageCallback sysCommonMessageCallback, RealTimeMessageCallback realTimeMessageCallback) |
Set the MIDI input callbacks. | |
Singleton boilerplate | |
Control_Surface_ (Control_Surface_ const &)=delete | |
Copying is not allowed. | |
Control_Surface_ & | operator= (Control_Surface_ const &)=delete |
Copying is not allowed. | |
static Control_Surface_ & | getInstance () |
Return the static Control_Surface_ instance (Control_Surface_ is a singleton.) | |
Control_Surface_ ()=default | |
Control_Surface_ is a singleton, so the constructor is private. | |
Sending MIDI Channel Voice messages | |
void | send (ChannelMessage message) |
Send a MIDI Channel Voice message. | |
void | sendChannelMessage (MIDIMessageType m, Channel c, uint8_t d1, uint8_t d2, Cable cable=Cable_1) |
Send a 3-byte MIDI Channel Voice message. | |
void | sendChannelMessage (MIDIMessageType m, Channel c, uint8_t d1, Cable cable=Cable_1) |
Send a 2-byte MIDI Channel Voice message. | |
void | sendNoteOn (MIDIAddress address, uint8_t velocity) |
Send a MIDI Note On event. | |
void | sendNoteOff (MIDIAddress address, uint8_t velocity) |
Send a MIDI Note Off event. | |
void | sendKeyPressure (MIDIAddress address, uint8_t pressure) |
Send a MIDI Key Pressure event. | |
void | sendControlChange (MIDIAddress address, uint8_t value) |
Send a MIDI Control Change event. | |
void | sendProgramChange (MIDIAddress address) |
Send a MIDI Program Change event. | |
void | sendProgramChange (MIDIChannelCable address, uint8_t value) |
Send a MIDI Program Change event. | |
void | sendChannelPressure (MIDIChannelCable address, uint8_t pressure) |
Send a MIDI Channel Pressure event. | |
void | sendPitchBend (MIDIChannelCable address, uint16_t value) |
Send a MIDI Pitch Bend event. | |
Sending MIDI System Common messages | |
void | send (SysCommonMessage message) |
Send a MIDI System Common message. | |
void | sendSysCommon (MIDIMessageType m, Cable cable=Cable_1) |
Send a MIDI System Common message. | |
void | sendSysCommon (MIDIMessageType m, uint8_t data1, Cable cable=Cable_1) |
Send a MIDI System Common message. | |
void | sendSysCommon (MIDIMessageType m, uint8_t data1, uint8_t data2, Cable cable=Cable_1) |
Send a MIDI System Common message. | |
void | sendMTCQuarterFrame (uint8_t data, Cable cable=Cable_1) |
Send a MIDI Time Code Quarter Frame. | |
void | sendMTCQuarterFrame (uint8_t messageType, uint8_t values, Cable cable=Cable_1) |
Send a MIDI Time Code Quarter Frame. | |
void | sendSongPositionPointer (uint16_t spp, Cable cable=Cable_1) |
Send a MIDI Song Position Pointer message. | |
void | sendSongSelect (uint8_t song, Cable cable=Cable_1) |
Send a MIDI Song Select message. | |
void | sendTuneRequest (Cable cable=Cable_1) |
Send a MIDI Tune Request. | |
Sending MIDI System Exclusive messages | |
void | send (SysExMessage message) |
Send a MIDI System Exclusive message. | |
void | sendSysEx (const uint8_t(&sysexdata)[N], Cable cable=Cable_1) |
Send a MIDI System Exclusive message. | |
void | sendSysEx (const uint8_t *data, uint16_t length, Cable cable=Cable_1) |
Send a MIDI System Exclusive message. | |
Sending MIDI Real-Time messages | |
void | send (RealTimeMessage message) |
Send a MIDI Real-Time message. | |
void | sendRealTime (MIDIMessageType rt, Cable cable=Cable_1) |
Send a MIDI Real-Time message. | |
void | sendRealTime (uint8_t rt, Cable cable=Cable_1) |
Send a MIDI Real-Time message. | |
void | sendTimingClock (Cable cable=Cable_1) |
Send a MIDI Timing Clock message. | |
void | sendStart (Cable cable=Cable_1) |
Send a MIDI Start message. | |
void | sendContinue (Cable cable=Cable_1) |
Send a MIDI Continue message. | |
void | sendStop (Cable cable=Cable_1) |
Send a MIDI Stop message. | |
void | sendActiveSensing (Cable cable=Cable_1) |
Send a MIDI Active Sensing message. | |
void | sendSystemReset (Cable cable=Cable_1) |
Send a MIDI System Reset message. | |
Flushing the MIDI send buffer | |
void | sendNow () |
Causes all buffered messages to be sent immediately. | |
Deprecated | |
void | sendKP (MIDIAddress address, uint8_t pressure) |
Send a MIDI Key Pressure event. | |
void | sendCC (MIDIAddress address, uint8_t value) |
Send a MIDI Control Change event. | |
void | sendPC (MIDIAddress address) |
Send a MIDI Program Change event. | |
void | sendPC (MIDIChannelCable address, uint8_t value) |
Send a MIDI Program Change event. | |
void | sendCP (MIDIChannelCable address, uint8_t pressure) |
Send a MIDI Channel Pressure event. | |
void | sendPB (MIDIChannelCable address, uint16_t value) |
Send a MIDI Pitch Bend event. | |
Connecting and disconnecting MIDI Pipes | |
void | connectSourcePipe (MIDI_Pipe *source) |
Fully connect a source pipe to this sink. | |
void | disconnectSourcePipes () |
Disconnect all source pipes that sink to this sink (recursively). | |
bool | disconnect (TrueMIDI_Source &source) |
Disconnect the given source from this sink. | |
bool | disconnect (MIDI_Pipe &)=delete |
bool | hasSourcePipe () const |
Check if this sink is connected to a source pipe. | |
MIDI_Pipe * | getSourcePipe () const |
Get a pointer to the pipe this sink is connected to, or nullptr if not connected. | |
Connecting and disconnecting MIDI Pipes | |
bool | disconnect (TrueMIDI_Sink &sink) |
Disconnect the given sink from this source. | |
bool | disconnect (MIDI_Pipe &)=delete |
void | connectSinkPipe (MIDI_Pipe *sink) |
Fully connect a sink pipe to this source. | |
void | disconnectSinkPipes () |
Disconnect all sink pipes that this source sinks to (recursively). | |
bool | hasSinkPipe () const |
Check if this source is connected to a sink pipe. | |
MIDI_Pipe * | getSinkPipe () |
Get a pointer to the pipe this source is connected to, or nullptr if not connected. | |
Sending data over a MIDI Pipe | |
void | sourceMIDItoPipe (ChannelMessage) |
Send a MIDI Channel Message down the pipe. | |
void | sourceMIDItoPipe (SysExMessage) |
Send a MIDI System Exclusive message down the pipe. | |
void | sourceMIDItoPipe (SysCommonMessage) |
Send a MIDI System Common message down the pipe. | |
void | sourceMIDItoPipe (RealTimeMessage) |
Send a MIDI Real-Time message down the pipe. | |
Stalling the sink pipes and exclusive access | |
void | stall (MIDIStaller *cause=eternal_stall) |
Stall this MIDI source. | |
void | unstall (MIDIStaller *cause=eternal_stall) |
Un-stall the pipes connected to this source, so other sources are allowed to send again. | |
bool | isStalled () const |
Check if this source can write to the sinks it connects to. | |
MIDIStaller * | getStaller () const |
Get a pointer to whatever is causing this MIDI source to be stalled. | |
const char * | getStallerName () const |
Get the name of whatever is causing this MIDI source to be stalled. | |
void | handleStallers () const |
Give the code that is stalling the MIDI sink pipes the opportunity to do its job and un-stall the pipes. | |
Public Member Functions | |
void | begin () |
Initialize the Control_Surface. | |
void | loop () |
Update all MIDI elements, send MIDI events and read MIDI input. | |
bool | connectDefaultMIDI_Interface () |
Connect Control Surface to the default MIDI interface. | |
void | disconnectMIDI_Interfaces () |
Disconnect Control Surface from the MIDI interfaces it's connected to. | |
void | updateMidiInput () |
Update all MIDI interfaces to receive new MIDI events. | |
void | updateInputs () |
Update all MIDIInputElements. | |
void | beginDisplays () |
Initialize all displays that have at least one display element. | |
void | updateDisplays () |
Clear, draw and display all displays that contain display elements that have changed. | |
Static Public Member Functions | |
static void | swap (MIDI_Sink &a, MIDI_Sink &b) |
static void | swap (MIDI_Source &a, MIDI_Source &b) |
Protected Attributes | |
MIDI_Pipe * | sourcePipe = nullptr |
MIDI_Pipe * | sinkPipe = nullptr |
Private Member Functions | |
void | sendChannelMessageImpl (ChannelMessage) |
Low-level function for sending a MIDI channel voice message. | |
void | sendSysCommonImpl (SysCommonMessage) |
Low-level function for sending a MIDI system common message. | |
void | sendSysExImpl (SysExMessage) |
Low-level function for sending a system exclusive MIDI message. | |
void | sendRealTimeImpl (RealTimeMessage) |
Low-level function for sending a MIDI real-time message. | |
void | sendNowImpl () |
Low-level function for sending any buffered outgoing MIDI messages. | |
void | sinkMIDIfromPipe (ChannelMessage msg) override |
Accept an incoming MIDI Channel message. | |
void | sinkMIDIfromPipe (SysExMessage msg) override |
Accept an incoming MIDI System Exclusive message. | |
void | sinkMIDIfromPipe (SysCommonMessage msg) override |
Accept an incoming MIDI System Common message. | |
void | sinkMIDIfromPipe (RealTimeMessage msg) override |
Accept an incoming MIDI Real-Time message. | |
virtual void | stallDownstream (MIDIStaller *, MIDI_Source *) |
Base case for recursive stall function. | |
virtual void | unstallDownstream (MIDIStaller *, MIDI_Source *) |
Base case for recursive un-stall function. | |
virtual MIDI_Sink * | getFinalSink () |
Base case for recursive function. | |
void | disconnectSourcePipesShallow () |
Disconnect only the first pipe connected to this sink. | |
virtual void | stallUpstream (MIDIStaller *, MIDI_Sink *) |
Base case for recursive stall function. | |
virtual void | unstallUpstream (MIDIStaller *, MIDI_Sink *) |
Base case for recursive un-stall function. | |
virtual MIDI_Source * | getInitialSource () |
Base case for recursive function. | |
void | disconnectSinkPipesShallow () |
Disconnect only the first pipe connected to this source. | |
Private Attributes | |
Timer< micros > | displayTimer = {1000000UL / MAX_FPS} |
A timer to know when to refresh the displays. | |
ChannelMessageCallback | channelMessageCallback = nullptr |
SysExMessageCallback | sysExMessageCallback = nullptr |
SysCommonMessageCallback | sysCommonMessageCallback = nullptr |
RealTimeMessageCallback | realTimeMessageCallback = nullptr |
MIDI_Pipe | inpipe |
MIDI_Pipe | outpipe |
using ChannelMessageCallback = bool (*)(ChannelMessage) |
Callback function type for channel messages.
Return true if handling is done in the user-provided callback, false if Control_Surface
should handle the message.
Definition at line 113 of file Control_Surface_Class.hpp.
using SysExMessageCallback = bool (*)(SysExMessage) |
Callback function type for SysEx messages.
Return true if handling is done in the user-provided callback, false if Control_Surface
should handle the message.
Definition at line 117 of file Control_Surface_Class.hpp.
using SysCommonMessageCallback = bool (*)(SysCommonMessage) |
Callback function type for System Common messages.
Return true if handling is done in the user-provided callback, false if Control_Surface
should handle the message.
Definition at line 121 of file Control_Surface_Class.hpp.
using RealTimeMessageCallback = bool (*)(RealTimeMessage) |
Callback function type for Real-Time messages.
Return true if handling is done in the user-provided callback, false if Control_Surface
should handle the message.
Definition at line 125 of file Control_Surface_Class.hpp.
|
delete |
Copying is not allowed.
|
privatedefault |
Control_Surface_ is a singleton, so the constructor is private.
|
delete |
Copying is not allowed.
|
static |
Return the static Control_Surface_ instance (Control_Surface_ is a singleton.)
Definition at line 17 of file Control_Surface_Class.cpp.
void begin | ( | ) |
Initialize the Control_Surface.
Definition at line 22 of file Control_Surface_Class.cpp.
void loop | ( | ) |
Update all MIDI elements, send MIDI events and read MIDI input.
Definition at line 71 of file Control_Surface_Class.cpp.
bool connectDefaultMIDI_Interface | ( | ) |
Connect Control Surface to the default MIDI interface.
Definition at line 47 of file Control_Surface_Class.cpp.
void disconnectMIDI_Interfaces | ( | ) |
Disconnect Control Surface from the MIDI interfaces it's connected to.
Definition at line 64 of file Control_Surface_Class.cpp.
void updateMidiInput | ( | ) |
Update all MIDI interfaces to receive new MIDI events.
Definition at line 81 of file Control_Surface_Class.cpp.
void updateInputs | ( | ) |
Update all MIDIInputElements.
Definition at line 271 of file Control_Surface_Class.cpp.
void beginDisplays | ( | ) |
Initialize all displays that have at least one display element.
Definition at line 281 of file Control_Surface_Class.cpp.
void updateDisplays | ( | ) |
Clear, draw and display all displays that contain display elements that have changed.
Definition at line 302 of file Control_Surface_Class.cpp.
|
private |
Low-level function for sending a MIDI channel voice message.
Definition at line 113 of file Control_Surface_Class.cpp.
|
private |
Low-level function for sending a MIDI system common message.
Definition at line 119 of file Control_Surface_Class.cpp.
|
private |
Low-level function for sending a system exclusive MIDI message.
Definition at line 116 of file Control_Surface_Class.cpp.
|
private |
Low-level function for sending a MIDI real-time message.
Definition at line 122 of file Control_Surface_Class.cpp.
|
inlineprivate |
Low-level function for sending any buffered outgoing MIDI messages.
Definition at line 86 of file Control_Surface_Class.hpp.
|
overrideprivatevirtual |
Accept an incoming MIDI Channel message.
Implements MIDI_Sink.
Definition at line 144 of file Control_Surface_Class.cpp.
|
overrideprivatevirtual |
Accept an incoming MIDI System Exclusive message.
Implements MIDI_Sink.
Definition at line 231 of file Control_Surface_Class.cpp.
|
overrideprivatevirtual |
Accept an incoming MIDI System Common message.
Implements MIDI_Sink.
Definition at line 247 of file Control_Surface_Class.cpp.
|
overrideprivatevirtual |
Accept an incoming MIDI Real-Time message.
Implements MIDI_Sink.
Definition at line 259 of file Control_Surface_Class.cpp.
|
inline |
Set the MIDI input callbacks.
Definition at line 129 of file Control_Surface_Class.hpp.
|
inherited |
Send a MIDI Channel Voice message.
|
inherited |
Send a MIDI System Common message.
|
inherited |
Send a MIDI System Exclusive message.
|
inherited |
Send a MIDI Real-Time message.
|
inherited |
Send a 3-byte MIDI Channel Voice message.
m | MIDI message type. [0x80, 0xE0] |
c | The MIDI channel. [1, 16] |
d1 | The first data byte. [0, 127] |
d2 | The second data byte. [0, 127] |
cable | The MIDI Cable Number. [Cable_1, Cable_16] |
|
inherited |
Send a 2-byte MIDI Channel Voice message.
m | MIDI message type. [0x80, 0xE0] |
c | The MIDI channel. [1, 16] |
d1 | The first data byte. [0, 127] |
cable | The MIDI Cable Number. [1, 16] |
|
inherited |
Send a MIDI Note On event.
|
inherited |
Send a MIDI Note Off event.
|
inherited |
Send a MIDI Key Pressure event.
|
inherited |
Send a MIDI Control Change event.
|
inherited |
Send a MIDI Program Change event.
|
inherited |
Send a MIDI Program Change event.
|
inherited |
Send a MIDI Channel Pressure event.
|
inherited |
Send a MIDI Pitch Bend event.
|
inherited |
Send a MIDI System Common message.
|
inherited |
Send a MIDI System Common message.
|
inherited |
Send a MIDI System Common message.
Send a MIDI Time Code Quarter Frame.
Send a MIDI Time Code Quarter Frame.
Send a MIDI Song Position Pointer message.
Send a MIDI Song Select message.
Send a MIDI System Exclusive message.
Send a MIDI System Exclusive message.
|
inherited |
Send a MIDI Real-Time message.
|
inherited |
Causes all buffered messages to be sent immediately.
|
inherited |
Send a MIDI Key Pressure event.
|
inherited |
Send a MIDI Control Change event.
|
inherited |
Send a MIDI Program Change event.
|
inherited |
Send a MIDI Program Change event.
|
inherited |
Send a MIDI Channel Pressure event.
|
inherited |
Send a MIDI Pitch Bend event.
|
inherited |
Fully connect a source pipe to this sink.
Definition at line 17 of file MIDI_Pipes.cpp.
|
inherited |
Disconnect all source pipes that sink to this sink (recursively).
Definition at line 26 of file MIDI_Pipes.cpp.
|
inherited |
Disconnect the given source from this sink.
Leaves other sources connected. Returns true if the source was found and disconnected, false if the given source was not a direct or indirect source to this sink.
Definition at line 41 of file MIDI_Pipes.cpp.
|
deleteinherited |
|
inherited |
Disconnect the given sink from this source.
Leaves other sinks connected. Returns true if the sink was found and disconnected, false if the given sink was not a direct or indirect sink of this source.
Definition at line 100 of file MIDI_Pipes.cpp.
|
deleteinherited |
|
inlineinherited |
Check if this sink is connected to a source pipe.
Definition at line 121 of file MIDI_Pipes.hpp.
|
inlineinherited |
Get a pointer to the pipe this sink is connected to, or nullptr
if not connected.
Definition at line 124 of file MIDI_Pipes.hpp.
|
inlineprivatevirtualinherited |
Base case for recursive stall function.
Reimplemented in MIDI_Pipe.
Definition at line 131 of file MIDI_Pipes.hpp.
|
inlineprivatevirtualinherited |
Base case for recursive un-stall function.
Reimplemented in MIDI_Pipe.
Definition at line 134 of file MIDI_Pipes.hpp.
|
inlineprivatevirtualinherited |
Base case for recursive function.
Reimplemented in MIDI_Pipe.
Definition at line 137 of file MIDI_Pipes.hpp.
|
privateinherited |
Disconnect only the first pipe connected to this sink.
Leaves the other pipes connected to the original pipe, which doesn't have a sink anymore when this function finishes. Used to disconnect a MIDI_Pipe while preserving the connections of its “through” inputs.
Definition at line 34 of file MIDI_Pipes.cpp.
Definition at line 57 of file MIDI_Pipes.cpp.
|
staticinherited |
Definition at line 114 of file MIDI_Pipes.cpp.
|
inherited |
Send a MIDI Channel Message down the pipe.
Definition at line 133 of file MIDI_Pipes.cpp.
|
inherited |
Send a MIDI System Exclusive message down the pipe.
Definition at line 139 of file MIDI_Pipes.cpp.
|
inherited |
Send a MIDI System Common message down the pipe.
Definition at line 145 of file MIDI_Pipes.cpp.
|
inherited |
Send a MIDI Real-Time message down the pipe.
Definition at line 151 of file MIDI_Pipes.cpp.
|
inherited |
Stall this MIDI source.
This means that this becomes the only source that can sink to the sinks connected to this source. Other sources have to wait until this source un-stalls the pipe before they can send again.
cause | Pointer to the reason for this stall, can be called back to un-stall the pipes. |
Definition at line 158 of file MIDI_Pipes.cpp.
|
inherited |
Un-stall the pipes connected to this source, so other sources are allowed to send again.
cause | Pointer to the reason for the stall (this has to be the same one that was used to stall). |
Definition at line 164 of file MIDI_Pipes.cpp.
|
inherited |
Check if this source can write to the sinks it connects to.
Definition at line 170 of file MIDI_Pipes.cpp.
|
inherited |
Get a pointer to whatever is causing this MIDI source to be stalled.
There could be multiple stallers, this function just returns one.
Definition at line 176 of file MIDI_Pipes.cpp.
|
inherited |
Get the name of whatever is causing this MIDI source to be stalled.
There could be multiple stallers, this function just returns one.
Definition at line 182 of file MIDI_Pipes.cpp.
|
inherited |
Give the code that is stalling the MIDI sink pipes the opportunity to do its job and un-stall the pipes.
Definition at line 186 of file MIDI_Pipes.cpp.
|
inherited |
Fully connect a sink pipe to this source.
Definition at line 76 of file MIDI_Pipes.cpp.
|
inherited |
Disconnect all sink pipes that this source sinks to (recursively).
Definition at line 85 of file MIDI_Pipes.cpp.
|
inlineinherited |
Check if this source is connected to a sink pipe.
Definition at line 237 of file MIDI_Pipes.hpp.
|
inlineinherited |
Get a pointer to the pipe this source is connected to, or nullptr
if not connected.
Definition at line 240 of file MIDI_Pipes.hpp.
|
inlineprivatevirtualinherited |
Base case for recursive stall function.
Reimplemented in MIDI_Pipe.
Definition at line 247 of file MIDI_Pipes.hpp.
|
inlineprivatevirtualinherited |
Base case for recursive un-stall function.
Reimplemented in MIDI_Pipe.
Definition at line 250 of file MIDI_Pipes.hpp.
|
inlineprivatevirtualinherited |
Base case for recursive function.
Reimplemented in MIDI_Pipe.
Definition at line 253 of file MIDI_Pipes.hpp.
|
privateinherited |
Disconnect only the first pipe connected to this source.
Leaves the other pipes connected to the original pipe, which doesn't have a source anymore when this function finishes. Used to disconnect a MIDI_Pipe while preserving the connections of its “through” outputs.
Definition at line 93 of file MIDI_Pipes.cpp.
A timer to know when to refresh the displays.
Definition at line 104 of file Control_Surface_Class.hpp.
|
private |
Definition at line 142 of file Control_Surface_Class.hpp.
|
private |
Definition at line 143 of file Control_Surface_Class.hpp.
|
private |
Definition at line 144 of file Control_Surface_Class.hpp.
|
private |
Definition at line 145 of file Control_Surface_Class.hpp.
|
private |
Definition at line 147 of file Control_Surface_Class.hpp.
|
private |
Definition at line 147 of file Control_Surface_Class.hpp.
|
protectedinherited |
Definition at line 146 of file MIDI_Pipes.hpp.
|
protectedinherited |
Definition at line 262 of file MIDI_Pipes.hpp.