Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | List of all members
MIDI_Source Class Reference

#include <MIDI_Interfaces/MIDI_Pipes.hpp>

Detailed Description

Class that can send MIDI messages to a MIDI pipe.

See also
MIDI Routing
Routing MIDI messages (MIDI tutorial)

Definition at line 160 of file MIDI_Pipes.hpp.

+ Inheritance diagram for MIDI_Source:
+ Collaboration diagram for MIDI_Source:

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 chargetStallerName () 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.
 

Connecting and disconnecting MIDI Pipes

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 disconnect (TrueMIDI_Sink &sink)
 Disconnect the given sink from this source.
 
bool disconnect (MIDI_Pipe &)=delete
 
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.
 

Public Member Functions

 MIDI_Source ()=default
 Default constructor.
 
 MIDI_Source (const MIDI_Source &)=delete
 Copy constructor (copying not allowed).
 
MIDI_Sourceoperator= (const MIDI_Source &)=delete
 Copy assignment (copying not allowed).
 
 MIDI_Source (MIDI_Source &&other)
 Move constructor.
 
MIDI_Sourceoperator= (MIDI_Source &&other)
 Move assignment.
 
virtual ~MIDI_Source ()
 Destructor.
 

Static Public Member Functions

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

Protected Attributes

MIDI_PipesinkPipe = nullptr
 

Private Member Functions

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.
 

Constructor & Destructor Documentation

◆ MIDI_Source() [1/3]

MIDI_Source ( )
default

Default constructor.

◆ MIDI_Source() [2/3]

Copy constructor (copying not allowed).

◆ MIDI_Source() [3/3]

MIDI_Source ( MIDI_Source && other)

Move constructor.

Definition at line 106 of file MIDI_Pipes.cpp.

◆ ~MIDI_Source()

~MIDI_Source ( )
virtual

Destructor.

Definition at line 131 of file MIDI_Pipes.cpp.

Member Function Documentation

◆ operator=() [1/2]

Copy assignment (copying not allowed).

◆ operator=() [2/2]

Move assignment.

Definition at line 126 of file MIDI_Pipes.cpp.

◆ sourceMIDItoPipe() [1/4]

void sourceMIDItoPipe ( ChannelMessage msg)

Send a MIDI Channel Message down the pipe.

Definition at line 133 of file MIDI_Pipes.cpp.

◆ sourceMIDItoPipe() [2/4]

void sourceMIDItoPipe ( SysExMessage msg)

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)

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)

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)

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)

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

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

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

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

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)

Fully connect a sink pipe to this source.

Definition at line 76 of file MIDI_Pipes.cpp.

◆ disconnectSinkPipes()

void disconnectSinkPipes ( )

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

Definition at line 85 of file MIDI_Pipes.cpp.

◆ disconnect() [1/2]

bool disconnect ( TrueMIDI_Sink & sink)

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() [2/2]

bool disconnect ( MIDI_Pipe & )
delete

◆ hasSinkPipe()

bool hasSinkPipe ( ) const
inline

Check if this source is connected to a sink pipe.

Definition at line 237 of file MIDI_Pipes.hpp.

◆ getSinkPipe()

MIDI_Pipe * getSinkPipe ( )
inline

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 *  )
inlineprivatevirtual

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 *  )
inlineprivatevirtual

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 ( )
inlineprivatevirtual

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 ( )
private

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.

◆ swap()

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

Definition at line 114 of file MIDI_Pipes.cpp.

Member Data Documentation

◆ sinkPipe

MIDI_Pipe* sinkPipe = nullptr
protected

Definition at line 262 of file MIDI_Pipes.hpp.


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