Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
GenericUSBMIDI_Interface< Backend > Class Template Reference

#include <MIDI_Interfaces/USBMIDI_Interface.hpp>

Detailed Description

template<class Backend>
class GenericUSBMIDI_Interface< Backend >

A class for MIDI interfaces sending MIDI messages over a USB MIDI connection.

Examples
Custom-USB-MIDI-Backend.ino.

Definition at line 17 of file USBMIDI_Interface.hpp.

+ Inheritance diagram for GenericUSBMIDI_Interface< Backend >:
+ Collaboration diagram for GenericUSBMIDI_Interface< Backend >:

Underlying USB communication

Backend backend
 The (platform-specific) backend used for MIDI over USB communication.
 

Initialization and polling

void begin () override
 Initialize.
 
void update () override
 Poll the backend (if necessary) and invoke the callbacks for any received MIDI messages, as well as sending them over the pipes connected to this interface.
 

Reading incoming MIDI messages

MIDIReadEvent read ()
 Try reading and parsing a single incoming MIDI message.
 
ChannelMessage getChannelMessage () const
 Return the received channel voice message.
 
SysCommonMessage getSysCommonMessage () const
 Return the received system common message.
 
RealTimeMessage getRealTimeMessage () const
 Return the received real-time message.
 
SysExMessage getSysExMessage () const
 Return the received system exclusive message.
 

Buffering USB packets

bool alwaysSendsImmediately () const
 Check if this USB interface always sends its USB packets immediately after sending a MIDI message.
 
void neverSendImmediately ()
 Don't send the USB packets immediately after sending a MIDI message.
 
void alwaysSendImmediately ()
 Send the USB packets immediately after sending a MIDI message.
 

Default MIDI Interfaces

void setAsDefault ()
 Set this MIDI interface as the default interface.
 
static MIDI_InterfacegetDefault ()
 Return the default MIDI interface.
 

MIDI Input Callbacks

void setCallbacks (MIDI_Callbacks *cb)
 Set the callbacks that will be called when a MIDI message is received.
 
void setCallbacks (MIDI_Callbacks &cb)
 Set the callbacks that will be called when a MIDI message is received.
 

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_PipegetSourcePipe () 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_PipegetSinkPipe ()
 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.
 
MIDIStallergetStaller () 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.
 

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.
 

Enabling and disabling updatables

void enable ()
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
void disable ()
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 
bool isEnabled () const
 Check if this updatable is enabled.
 
void moveDown ()
 Move down this element in the list.
 
static void enable (UpdatableCRTP *element)
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
static void enable (UpdatableCRTP &element)
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
template<class U , size_t N>
static void enable (U(&array)[N])
 Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
 
static void disable (UpdatableCRTP *element)
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 
static void disable (UpdatableCRTP &element)
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 
template<class U , size_t N>
static void disable (U(&array)[N])
 Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.
 

Main initialization and updating methods

static void beginAll ()
 Begin all enabled instances of this class.
 
static void updateAll ()
 Update all enabled instances of this class.
 

Classes

struct  Sender
 Functor to send USB MIDI packets. More...
 

Public Member Functions

template<class... Args>
 GenericUSBMIDI_Interface (Args &&...args)
 Construct a new GenericUSBMIDI_Interface.
 
 GenericUSBMIDI_Interface (const GenericUSBMIDI_Interface &)=delete
 
 GenericUSBMIDI_Interface (GenericUSBMIDI_Interface &&)=delete
 
GenericUSBMIDI_Interfaceoperator= (const GenericUSBMIDI_Interface &)=delete
 
GenericUSBMIDI_Interfaceoperator= (GenericUSBMIDI_Interface &&)=delete
 

Static Public Member Functions

template<class MIDIInterface_t >
static void updateIncoming (MIDIInterface_t *iface)
 Read, parse and dispatch incoming MIDI messages on the given interface.
 
template<class MIDIInterface_t >
static void dispatchIncoming (MIDIInterface_t *iface, MIDIReadEvent event)
 Dispatch the given type of MIDI message from the given interface.
 
template<class MIDIInterface_t >
static void handleStall (MIDIInterface_t *self)
 Un-stall the given MIDI interface.
 
static void swap (MIDI_Sink &a, MIDI_Sink &b)
 
static void swap (MIDI_Source &a, MIDI_Source &b)
 

Protected Member Functions

void sinkMIDIfromPipe (ChannelMessage msg) override
 Accept an incoming MIDI Channel message from the source pipe.
 
void sinkMIDIfromPipe (SysExMessage msg) override
 Accept an incoming MIDI System Exclusive message from the source pipe.
 
void sinkMIDIfromPipe (SysCommonMessage msg) override
 Accept an incoming MIDI System Common message from the source pipe.
 
void sinkMIDIfromPipe (RealTimeMessage msg) override
 Accept an incoming MIDI Real-Time message from the source pipe.
 
void onChannelMessage (ChannelMessage message)
 Call the channel message callback and send the message to the sink pipe.
 
void onSysExMessage (SysExMessage message)
 Call the SysEx message callback and send the message to the sink pipe.
 
void onSysCommonMessage (SysCommonMessage message)
 Call the System Common 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 Protected Member Functions

static const char * getNameNull (MIDIStaller *s)
 Get the staller's name for debugging purposes.
 

Protected Attributes

MIDI_PipesourcePipe = nullptr
 
MIDI_PipesinkPipe = nullptr
 
Derived * next
 
Derived * previous
 

Static Protected Attributes

static DoublyLinkedList< Derived > updatables
 

Private Member Functions

void sendChannelMessageImpl (ChannelMessage) override
 Low-level function for sending a MIDI channel voice message.
 
void sendSysCommonImpl (SysCommonMessage) override
 Low-level function for sending a MIDI system common message.
 
void sendSysExImpl (SysExMessage) override
 Low-level function for sending a system exclusive MIDI message.
 
void sendRealTimeImpl (RealTimeMessage) override
 Low-level function for sending a MIDI real-time message.
 
void sendNowImpl () override
 Low-level function for sending any buffered outgoing MIDI messages.
 
void handleStall () override
 Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI source as quickly as possible.
 
const char * getName () const override
 Get the staller's name for debugging purposes.
 
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_SinkgetFinalSink ()
 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_SourcegetInitialSource ()
 Base case for recursive function.
 
void disconnectSinkPipesShallow ()
 Disconnect only the first pipe connected to this source.
 

Private Attributes

USBMIDI_Parser parser
 Parses USB packets into MIDI messages.
 
USBMIDI_Sender sender
 Sends USB MIDI messages.
 
bool alwaysSendImmediately_ = true
 
MIDI_Callbackscallbacks = nullptr
 

Static Private Attributes

static MIDI_InterfaceDefaultMIDI_Interface = nullptr
 

Constructor & Destructor Documentation

◆ GenericUSBMIDI_Interface() [1/3]

template<class Backend >
template<class... Args>
GenericUSBMIDI_Interface ( Args &&... args)
inline

Construct a new GenericUSBMIDI_Interface.

Definition at line 23 of file USBMIDI_Interface.hpp.

◆ GenericUSBMIDI_Interface() [2/3]

template<class Backend >
GenericUSBMIDI_Interface ( const GenericUSBMIDI_Interface< Backend > & )
delete

◆ GenericUSBMIDI_Interface() [3/3]

template<class Backend >
GenericUSBMIDI_Interface ( GenericUSBMIDI_Interface< Backend > && )
delete

Member Function Documentation

◆ operator=() [1/2]

template<class Backend >
GenericUSBMIDI_Interface & operator= ( const GenericUSBMIDI_Interface< Backend > & )
delete

◆ operator=() [2/2]

template<class Backend >
GenericUSBMIDI_Interface & operator= ( GenericUSBMIDI_Interface< Backend > && )
delete

◆ sendChannelMessageImpl()

template<class Backend >
void sendChannelMessageImpl ( ChannelMessage )
overrideprivatevirtual

Low-level function for sending a MIDI channel voice message.

Implements MIDI_Interface.

◆ sendSysCommonImpl()

template<class Backend >
void sendSysCommonImpl ( SysCommonMessage )
overrideprivatevirtual

Low-level function for sending a MIDI system common message.

Implements MIDI_Interface.

◆ sendSysExImpl()

template<class Backend >
void sendSysExImpl ( SysExMessage )
overrideprivatevirtual

Low-level function for sending a system exclusive MIDI message.

Implements MIDI_Interface.

◆ sendRealTimeImpl()

template<class Backend >
void sendRealTimeImpl ( RealTimeMessage )
overrideprivatevirtual

Low-level function for sending a MIDI real-time message.

Implements MIDI_Interface.

◆ sendNowImpl()

template<class Backend >
void sendNowImpl ( )
inlineoverrideprivatevirtual

Low-level function for sending any buffered outgoing MIDI messages.

Implements MIDI_Interface.

Definition at line 39 of file USBMIDI_Interface.hpp.

◆ handleStall() [1/2]

template<class Backend >
void handleStall ( )
inlineoverrideprivatevirtual

Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI source as quickly as possible.

Implements MIDIStaller.

Definition at line 43 of file USBMIDI_Interface.hpp.

◆ getName()

template<class Backend >
const char * getName ( ) const
inlineoverrideprivatevirtual

Get the staller's name for debugging purposes.

Reimplemented from MIDIStaller.

Definition at line 45 of file USBMIDI_Interface.hpp.

◆ begin()

template<class Backend >
void begin ( )
overridevirtual

Initialize.

Implements Updatable< MIDI_Interface >.

◆ update()

template<class Backend >
void update ( )
overridevirtual

Poll the backend (if necessary) and invoke the callbacks for any received MIDI messages, as well as sending them over the pipes connected to this interface.

Implements MIDI_Interface.

◆ read()

template<class Backend >
MIDIReadEvent read ( )

Try reading and parsing a single incoming MIDI message.

Returns
Returns the type of the message read, or MIDIReadEvent::NO_MESSAGE if no MIDI message was available.

◆ getChannelMessage()

template<class Backend >
ChannelMessage getChannelMessage ( ) const

Return the received channel voice message.

◆ getSysCommonMessage()

template<class Backend >
SysCommonMessage getSysCommonMessage ( ) const

Return the received system common message.

◆ getRealTimeMessage()

template<class Backend >
RealTimeMessage getRealTimeMessage ( ) const

Return the received real-time message.

◆ getSysExMessage()

template<class Backend >
SysExMessage getSysExMessage ( ) const

Return the received system exclusive message.

◆ alwaysSendsImmediately()

template<class Backend >
bool alwaysSendsImmediately ( ) const
inline

Check if this USB interface always sends its USB packets immediately after sending a MIDI message.

The default value depends on the MIDI USB backend being used: true for the MIDIUSB library, and false for the Teensy Core USB MIDI functions (because they have a short timeout).

Definition at line 117 of file USBMIDI_Interface.hpp.

◆ neverSendImmediately()

template<class Backend >
void neverSendImmediately ( )
inline

Don't send the USB packets immediately after sending a MIDI message.

By disabling immediate transmission, packets are buffered until you call sendNow() or until a timeout is reached, so multiple MIDI messages can be transmitted in a single USB packet. This is more efficient and results in a higher maximum bandwidth, but it could increase latency when used incorrectly.

Definition at line 124 of file USBMIDI_Interface.hpp.

◆ alwaysSendImmediately()

template<class Backend >
void alwaysSendImmediately ( )
inline

Send the USB packets immediately after sending a MIDI message.

See also
neverSendImmediately()

Definition at line 127 of file USBMIDI_Interface.hpp.

◆ setAsDefault()

void setAsDefault ( )
inherited

Set this MIDI interface as the default interface.

Examples
MIDI-Monitor-OLED.ino.

Definition at line 15 of file MIDI_Interface.cpp.

◆ getDefault()

MIDI_Interface * getDefault ( )
staticinherited

Return the default MIDI interface.

If the default MIDI interface was configured explicitly using setAsDefault(), that interface is returned. If it wasn't set, or if that MIDI interface no longer exists, this function returns the newest MIDI interface, the one that was constructed most recently. If no MIDI interfaces exist, nullptr is returned.

Definition at line 23 of file MIDI_Interface.cpp.

◆ setCallbacks() [1/2]

void setCallbacks ( MIDI_Callbacks * cb)
inlineinherited

Set the callbacks that will be called when a MIDI message is received.

Parameters
cbA pointer to the callback object.
Examples
MIDI-Input-Fine-Grained-All-Callbacks.ino, MIDI-Input-Fine-Grained.ino, MIDI-Input.ino, and SysEx-Send-Receive.ino.

Definition at line 58 of file MIDI_Interface.hpp.

◆ setCallbacks() [2/2]

void setCallbacks ( MIDI_Callbacks & cb)
inlineinherited

Set the callbacks that will be called when a MIDI message is received.

Parameters
cbA reference to the callback object.

Definition at line 62 of file MIDI_Interface.hpp.

◆ sinkMIDIfromPipe() [1/4]

void sinkMIDIfromPipe ( ChannelMessage msg)
inlineoverrideprotectedvirtualinherited

Accept an incoming MIDI Channel message from the source pipe.

Implements MIDI_Sink.

Definition at line 91 of file MIDI_Interface.hpp.

◆ sinkMIDIfromPipe() [2/4]

void sinkMIDIfromPipe ( SysExMessage msg)
inlineoverrideprotectedvirtualinherited

Accept an incoming MIDI System Exclusive message from the source pipe.

Implements MIDI_Sink.

Definition at line 93 of file MIDI_Interface.hpp.

◆ sinkMIDIfromPipe() [3/4]

void sinkMIDIfromPipe ( SysCommonMessage msg)
inlineoverrideprotectedvirtualinherited

Accept an incoming MIDI System Common message from the source pipe.

Implements MIDI_Sink.

Definition at line 95 of file MIDI_Interface.hpp.

◆ sinkMIDIfromPipe() [4/4]

void sinkMIDIfromPipe ( RealTimeMessage msg)
inlineoverrideprotectedvirtualinherited

Accept an incoming MIDI Real-Time message from the source pipe.

Implements MIDI_Sink.

Definition at line 97 of file MIDI_Interface.hpp.

◆ onChannelMessage()

void onChannelMessage ( ChannelMessage message)
protectedinherited

Call the channel message callback and send the message to the sink pipe.

Definition at line 35 of file MIDI_Interface.cpp.

◆ onSysExMessage()

void onSysExMessage ( SysExMessage message)
protectedinherited

Call the SysEx message callback and send the message to the sink pipe.

Definition at line 41 of file MIDI_Interface.cpp.

◆ onSysCommonMessage()

void onSysCommonMessage ( SysCommonMessage message)
protectedinherited

Call the System Common message callback and send the message to the sink pipe.

Definition at line 47 of file MIDI_Interface.cpp.

◆ onRealTimeMessage()

void onRealTimeMessage ( RealTimeMessage message)
protectedinherited

Call the real-time message callback and send the message to the sink pipe.

Definition at line 53 of file MIDI_Interface.cpp.

◆ updateIncoming()

template<class MIDIInterface_t >
void updateIncoming ( MIDIInterface_t * iface)
staticinherited

Read, parse and dispatch incoming MIDI messages on the given interface.

Definition at line 133 of file MIDI_Interface.hpp.

◆ dispatchIncoming()

template<class MIDIInterface_t >
void dispatchIncoming ( MIDIInterface_t * iface,
MIDIReadEvent event )
staticinherited

Dispatch the given type of MIDI message from the given interface.

Definition at line 172 of file MIDI_Interface.hpp.

◆ handleStall() [2/2]

template<class MIDIInterface_t >
void handleStall ( MIDIInterface_t * self)
staticinherited

Un-stall the given MIDI interface.

Assumes the interface has been stalled because of a chunked SysEx messages. Waits until that message is finished.

Definition at line 195 of file MIDI_Interface.hpp.

◆ connectSourcePipe()

void connectSourcePipe ( MIDI_Pipe * source)
inherited

Fully connect a source pipe to this sink.

Definition at line 17 of file MIDI_Pipes.cpp.

◆ disconnectSourcePipes()

void disconnectSourcePipes ( )
inherited

Disconnect all source pipes that sink to this sink (recursively).

Definition at line 26 of file MIDI_Pipes.cpp.

◆ disconnect() [1/4]

bool disconnect ( TrueMIDI_Source & source)
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.

◆ disconnect() [2/4]

bool disconnect ( MIDI_Pipe & )
deleteinherited

◆ disconnect() [3/4]

bool disconnect ( TrueMIDI_Sink & sink)
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.

◆ disconnect() [4/4]

bool disconnect ( MIDI_Pipe & )
deleteinherited

◆ hasSourcePipe()

bool hasSourcePipe ( ) const
inlineinherited

Check if this sink is connected to a source pipe.

Definition at line 121 of file MIDI_Pipes.hpp.

◆ getSourcePipe()

MIDI_Pipe * getSourcePipe ( ) const
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.

◆ stallDownstream()

virtual void stallDownstream ( MIDIStaller * ,
MIDI_Source *  )
inlineprivatevirtualinherited

Base case for recursive stall function.

See also
MIDI_Pipe::stallDownstream

Reimplemented in MIDI_Pipe.

Definition at line 131 of file MIDI_Pipes.hpp.

◆ unstallDownstream()

virtual void unstallDownstream ( MIDIStaller * ,
MIDI_Source *  )
inlineprivatevirtualinherited

Base case for recursive un-stall function.

See also
MIDI_Pipe::unstallDownstream

Reimplemented in MIDI_Pipe.

Definition at line 134 of file MIDI_Pipes.hpp.

◆ getFinalSink()

virtual MIDI_Sink * getFinalSink ( )
inlineprivatevirtualinherited

Base case for recursive function.

See also
MIDI_Pipe::getFinalSink

Reimplemented in MIDI_Pipe.

Definition at line 137 of file MIDI_Pipes.hpp.

◆ disconnectSourcePipesShallow()

void disconnectSourcePipesShallow ( )
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.

◆ swap() [1/2]

void swap ( MIDI_Sink & a,
MIDI_Sink & b )
staticinherited

Definition at line 57 of file MIDI_Pipes.cpp.

◆ swap() [2/2]

void swap ( MIDI_Source & a,
MIDI_Source & b )
staticinherited

Definition at line 114 of file MIDI_Pipes.cpp.

◆ sourceMIDItoPipe() [1/4]

void sourceMIDItoPipe ( ChannelMessage msg)
inherited

Send a MIDI Channel Message down the pipe.

Definition at line 133 of file MIDI_Pipes.cpp.

◆ sourceMIDItoPipe() [2/4]

void sourceMIDItoPipe ( SysExMessage msg)
inherited

Send a MIDI System Exclusive message down the pipe.

Definition at line 139 of file MIDI_Pipes.cpp.

◆ sourceMIDItoPipe() [3/4]

void sourceMIDItoPipe ( SysCommonMessage msg)
inherited

Send a MIDI System Common message down the pipe.

Definition at line 145 of file MIDI_Pipes.cpp.

◆ sourceMIDItoPipe() [4/4]

void sourceMIDItoPipe ( RealTimeMessage msg)
inherited

Send a MIDI Real-Time message down the pipe.

Definition at line 151 of file MIDI_Pipes.cpp.

◆ stall()

void stall ( MIDIStaller * cause = eternal_stall)
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.

Parameters
causePointer to the reason for this stall, can be called back to un-stall the pipes.

Definition at line 158 of file MIDI_Pipes.cpp.

◆ unstall()

void unstall ( MIDIStaller * cause = eternal_stall)
inherited

Un-stall the pipes connected to this source, so other sources are allowed to send again.

Parameters
causePointer 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.

◆ isStalled()

bool isStalled ( ) const
inherited

Check if this source can write to the sinks it connects to.

Definition at line 170 of file MIDI_Pipes.cpp.

◆ getStaller()

MIDIStaller * getStaller ( ) const
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.

◆ getStallerName()

const char * getStallerName ( ) const
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.

◆ handleStallers()

void handleStallers ( ) const
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.

◆ connectSinkPipe()

void connectSinkPipe ( MIDI_Pipe * sink)
inherited

Fully connect a sink pipe to this source.

Definition at line 76 of file MIDI_Pipes.cpp.

◆ disconnectSinkPipes()

void disconnectSinkPipes ( )
inherited

Disconnect all sink pipes that this source sinks to (recursively).

Definition at line 85 of file MIDI_Pipes.cpp.

◆ hasSinkPipe()

bool hasSinkPipe ( ) const
inlineinherited

Check if this source is connected to a sink pipe.

Definition at line 237 of file MIDI_Pipes.hpp.

◆ getSinkPipe()

MIDI_Pipe * getSinkPipe ( )
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.

◆ stallUpstream()

virtual void stallUpstream ( MIDIStaller * ,
MIDI_Sink *  )
inlineprivatevirtualinherited

Base case for recursive stall function.

See also
MIDI_Pipe::stallUpstream

Reimplemented in MIDI_Pipe.

Definition at line 247 of file MIDI_Pipes.hpp.

◆ unstallUpstream()

virtual void unstallUpstream ( MIDIStaller * ,
MIDI_Sink *  )
inlineprivatevirtualinherited

Base case for recursive un-stall function.

See also
MIDI_Pipe::unstallUpstream

Reimplemented in MIDI_Pipe.

Definition at line 250 of file MIDI_Pipes.hpp.

◆ getInitialSource()

virtual MIDI_Source * getInitialSource ( )
inlineprivatevirtualinherited

Base case for recursive function.

See also
MIDI_Pipe::getInitialSource

Reimplemented in MIDI_Pipe.

Definition at line 253 of file MIDI_Pipes.hpp.

◆ disconnectSinkPipesShallow()

void disconnectSinkPipesShallow ( )
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.

◆ send() [1/4]

void send ( ChannelMessage message)
inherited

Send a MIDI Channel Voice message.

◆ send() [2/4]

void send ( SysCommonMessage message)
inherited

Send a MIDI System Common message.

◆ send() [3/4]

void send ( SysExMessage message)
inherited

Send a MIDI System Exclusive message.

◆ send() [4/4]

void send ( RealTimeMessage message)
inherited

Send a MIDI Real-Time message.

◆ sendChannelMessage() [1/2]

void sendChannelMessage ( MIDIMessageType m,
Channel c,
uint8_t d1,
uint8_t d2,
Cable cable = Cable_1 )
inherited

Send a 3-byte MIDI Channel Voice message.

Parameters
mMIDI message type. [0x80, 0xE0]
cThe MIDI channel. [1, 16]
d1The first data byte. [0, 127]
d2The second data byte. [0, 127]
cableThe MIDI Cable Number. [Cable_1, Cable_16]

◆ sendChannelMessage() [2/2]

void sendChannelMessage ( MIDIMessageType m,
Channel c,
uint8_t d1,
Cable cable = Cable_1 )
inherited

Send a 2-byte MIDI Channel Voice message.

Parameters
mMIDI message type. [0x80, 0xE0]
cThe MIDI channel. [1, 16]
d1The first data byte. [0, 127]
cableThe MIDI Cable Number. [1, 16]

◆ sendNoteOn()

void sendNoteOn ( MIDIAddress address,
uint8_t velocity )
inherited

Send a MIDI Note On event.

Examples
MIDI-Output.ino, Send-All-MIDI-Messages.ino, and Send-MIDI-Notes.ino.

◆ sendNoteOff()

void sendNoteOff ( MIDIAddress address,
uint8_t velocity )
inherited

Send a MIDI Note Off event.

Examples
MIDI-Output.ino, Send-All-MIDI-Messages.ino, and Send-MIDI-Notes.ino.

◆ sendKeyPressure()

void sendKeyPressure ( MIDIAddress address,
uint8_t pressure )
inherited

Send a MIDI Key Pressure event.

Examples
Send-All-MIDI-Messages.ino.

◆ sendControlChange()

void sendControlChange ( MIDIAddress address,
uint8_t value )
inherited

Send a MIDI Control Change event.

Examples
Send-All-MIDI-Messages.ino.

◆ sendProgramChange() [1/2]

void sendProgramChange ( MIDIAddress address)
inherited

Send a MIDI Program Change event.

Examples
Send-All-MIDI-Messages.ino.

◆ sendProgramChange() [2/2]

void sendProgramChange ( MIDIChannelCable address,
uint8_t value )
inherited

Send a MIDI Program Change event.

◆ sendChannelPressure()

void sendChannelPressure ( MIDIChannelCable address,
uint8_t pressure )
inherited

Send a MIDI Channel Pressure event.

Examples
Send-All-MIDI-Messages.ino.

◆ sendPitchBend()

void sendPitchBend ( MIDIChannelCable address,
uint16_t value )
inherited

Send a MIDI Pitch Bend event.

Examples
Send-All-MIDI-Messages.ino.

◆ sendSysCommon() [1/3]

void sendSysCommon ( MIDIMessageType m,
Cable cable = Cable_1 )
inherited

Send a MIDI System Common message.

◆ sendSysCommon() [2/3]

void sendSysCommon ( MIDIMessageType m,
uint8_t data1,
Cable cable = Cable_1 )
inherited

Send a MIDI System Common message.

◆ sendSysCommon() [3/3]

void sendSysCommon ( MIDIMessageType m,
uint8_t data1,
uint8_t data2,
Cable cable = Cable_1 )
inherited

Send a MIDI System Common message.

◆ sendMTCQuarterFrame() [1/2]

void sendMTCQuarterFrame ( uint8_t data,
Cable cable = Cable_1 )
inherited

Send a MIDI Time Code Quarter Frame.

Examples
Send-All-MIDI-Messages.ino.

◆ sendMTCQuarterFrame() [2/2]

void sendMTCQuarterFrame ( uint8_t messageType,
uint8_t values,
Cable cable = Cable_1 )
inherited

Send a MIDI Time Code Quarter Frame.

◆ sendSongPositionPointer()

void sendSongPositionPointer ( uint16_t spp,
Cable cable = Cable_1 )
inherited

Send a MIDI Song Position Pointer message.

Examples
Send-All-MIDI-Messages.ino.

◆ sendSongSelect()

void sendSongSelect ( uint8_t song,
Cable cable = Cable_1 )
inherited

Send a MIDI Song Select message.

Examples
Send-All-MIDI-Messages.ino.

◆ sendTuneRequest()

void sendTuneRequest ( Cable cable = Cable_1)
inherited

Send a MIDI Tune Request.

Examples
Send-All-MIDI-Messages.ino.

◆ sendSysEx() [1/2]

void sendSysEx ( const uint8_t(&) sysexdata[N],
Cable cable = Cable_1 )
inherited

Send a MIDI System Exclusive message.

Examples
Send-All-MIDI-Messages.ino, and SysEx-Send-Receive.ino.

◆ sendSysEx() [2/2]

void sendSysEx ( const uint8_t * data,
uint16_t length,
Cable cable = Cable_1 )
inherited

Send a MIDI System Exclusive message.

◆ sendRealTime() [1/2]

void sendRealTime ( MIDIMessageType rt,
Cable cable = Cable_1 )
inherited

Send a MIDI Real-Time message.

◆ sendRealTime() [2/2]

void sendRealTime ( uint8_t rt,
Cable cable = Cable_1 )
inherited

Send a MIDI Real-Time message.

◆ sendTimingClock()

void sendTimingClock ( Cable cable = Cable_1)
inherited

Send a MIDI Timing Clock message.

Examples
Send-All-MIDI-Messages.ino.

◆ sendStart()

void sendStart ( Cable cable = Cable_1)
inherited

Send a MIDI Start message.

Examples
Send-All-MIDI-Messages.ino.

◆ sendContinue()

void sendContinue ( Cable cable = Cable_1)
inherited

Send a MIDI Continue message.

Examples
Send-All-MIDI-Messages.ino.

◆ sendStop()

void sendStop ( Cable cable = Cable_1)
inherited

Send a MIDI Stop message.

Examples
Send-All-MIDI-Messages.ino.

◆ sendActiveSensing()

void sendActiveSensing ( Cable cable = Cable_1)
inherited

Send a MIDI Active Sensing message.

Examples
Send-All-MIDI-Messages.ino.

◆ sendSystemReset()

void sendSystemReset ( Cable cable = Cable_1)
inherited

Send a MIDI System Reset message.

Examples
Send-All-MIDI-Messages.ino.

◆ sendNow()

void sendNow ( )
inherited

Causes all buffered messages to be sent immediately.

Note
Doesn't necessarily wait until all data has been sent, it just triggers the transmission, so everything will be transmitted as soon as possible.

◆ sendKP()

void sendKP ( MIDIAddress address,
uint8_t pressure )
inherited

Send a MIDI Key Pressure event.

◆ sendCC()

void sendCC ( MIDIAddress address,
uint8_t value )
inherited

Send a MIDI Control Change event.

◆ sendPC() [1/2]

void sendPC ( MIDIAddress address)
inherited

Send a MIDI Program Change event.

◆ sendPC() [2/2]

void sendPC ( MIDIChannelCable address,
uint8_t value )
inherited

Send a MIDI Program Change event.

◆ sendCP()

void sendCP ( MIDIChannelCable address,
uint8_t pressure )
inherited

Send a MIDI Channel Pressure event.

◆ sendPB()

void sendPB ( MIDIChannelCable address,
uint16_t value )
inherited

Send a MIDI Pitch Bend event.

◆ beginAll()

static void beginAll ( )
inlinestaticinherited

Begin all enabled instances of this class.

See also
begin()
Examples
BLEMIDI-Adapter.ino, MIDI-Monitor.ino, and USBMIDI-Adapter.ino.

Definition at line 182 of file Updatable.hpp.

◆ updateAll()

static void updateAll ( )
inlinestaticinherited

Update all enabled instances of this class.

See also
update()
Examples
BLEMIDI-Adapter.ino, MIDI-Monitor.ino, and USBMIDI-Adapter.ino.

Definition at line 186 of file Updatable.hpp.

◆ enable() [1/4]

template<class Derived >
void enable ( )
inlineinherited

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 96 of file Updatable.hpp.

◆ enable() [2/4]

template<class Derived >
static void enable ( UpdatableCRTP< Derived > * element)
inlinestaticinherited

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 125 of file Updatable.hpp.

◆ enable() [3/4]

template<class Derived >
static void enable ( UpdatableCRTP< Derived > & element)
inlinestaticinherited

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 127 of file Updatable.hpp.

◆ enable() [4/4]

template<class Derived >
template<class U , size_t N>
static void enable ( U(&) array[N])
inlinestaticinherited

Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.

Definition at line 130 of file Updatable.hpp.

◆ disable() [1/4]

template<class Derived >
void disable ( )
inlineinherited

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 106 of file Updatable.hpp.

◆ disable() [2/4]

template<class Derived >
static void disable ( UpdatableCRTP< Derived > * element)
inlinestaticinherited

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 136 of file Updatable.hpp.

◆ disable() [3/4]

template<class Derived >
static void disable ( UpdatableCRTP< Derived > & element)
inlinestaticinherited

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 138 of file Updatable.hpp.

◆ disable() [4/4]

template<class Derived >
template<class U , size_t N>
static void disable ( U(&) array[N])
inlinestaticinherited

Disable this updatable: remove it from the linked list of instances, so it no longer gets updated automatically.

Definition at line 141 of file Updatable.hpp.

◆ isEnabled()

template<class Derived >
bool isEnabled ( ) const
inlineinherited

Check if this updatable is enabled.

Note
Assumes that the updatable is not added to a different linked list by the user.

Definition at line 120 of file Updatable.hpp.

◆ moveDown()

template<class Derived >
void moveDown ( )
inlineinherited

Move down this element in the list.

Definition at line 147 of file Updatable.hpp.

◆ getNameNull()

const char * getNameNull ( MIDIStaller * s)
staticinherited

Get the staller's name for debugging purposes.

Correctly deals with null pointers or eternal stallers.

Definition at line 357 of file MIDI_Pipes.cpp.

Member Data Documentation

◆ backend

template<class Backend >
Backend backend

The (platform-specific) backend used for MIDI over USB communication.

Definition at line 87 of file USBMIDI_Interface.hpp.

◆ parser

template<class Backend >
USBMIDI_Parser parser
private

Parses USB packets into MIDI messages.

Definition at line 103 of file USBMIDI_Interface.hpp.

◆ sender

template<class Backend >
USBMIDI_Sender sender
private

Sends USB MIDI messages.

Definition at line 105 of file USBMIDI_Interface.hpp.

◆ alwaysSendImmediately_

template<class Backend >
bool alwaysSendImmediately_ = true
private
See also
neverSendImmediately()

Definition at line 107 of file USBMIDI_Interface.hpp.

◆ callbacks

MIDI_Callbacks* callbacks = nullptr
privateinherited

Definition at line 126 of file MIDI_Interface.hpp.

◆ DefaultMIDI_Interface

MIDI_Interface * DefaultMIDI_Interface = nullptr
staticprivateinherited

Definition at line 129 of file MIDI_Interface.hpp.

◆ sourcePipe

MIDI_Pipe* sourcePipe = nullptr
protectedinherited

Definition at line 146 of file MIDI_Pipes.hpp.

◆ sinkPipe

MIDI_Pipe* sinkPipe = nullptr
protectedinherited

Definition at line 262 of file MIDI_Pipes.hpp.

◆ updatables

template<class Derived >
DoublyLinkedList< Derived > updatables
staticprotectedinherited

Definition at line 152 of file Updatable.hpp.

◆ next

Derived * next
protectedinherited

Definition at line 320 of file LinkedList.hpp.

◆ previous

Derived * previous
protectedinherited

Definition at line 321 of file LinkedList.hpp.


The documentation for this class was generated from the following file: