Control Surface  1.2.0
MIDI Control Surface library for Arduino
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
USBMIDI_Interface Class Reference

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

#include <MIDI_Interfaces/USBMIDI_Interface.hpp>

+ Inheritance diagram for USBMIDI_Interface:
+ Collaboration diagram for USBMIDI_Interface:

Public Types

using MIDIUSBPacket_t = USBMIDI::MIDIUSBPacket_t
 
using Mutex = typename std::conditional< ThreadSafe, DefaultMutEx, EmptyMutex >::type
 
using LockGuard = typename std::conditional< ThreadSafe, DefaultLockGuard< Mutex >, EmptyLockGuard< Mutex > >::type
 

Public Member Functions

 USBMIDI_Interface ()
 Construct a new USBMIDI_Interface. More...
 
MIDIReadEvent read () override
 Try reading and parsing a single incoming MIDI message. More...
 
void update () override
 Read the MIDI interface and call the callback if a message is received. More...
 
void setCallbacks (MIDI_Callbacks *cb) override
 Set the callbacks that will be called when a MIDI message is received. More...
 
virtual void setCallbacks (MIDI_Callbacks *cb)=0
 Set the callbacks that will be called when a MIDI message is received. More...
 
void setCallbacks (MIDI_Callbacks &cb)
 Set the callbacks that will be called when a MIDI message is received. More...
 
void begin () override
 Initialize the MIDI Interface. More...
 

Static Public Member Functions

static MutexgetMutex ()
 

Protected Member Functions

bool dispatchMIDIEvent (MIDIReadEvent event)
 
void sinkMIDIfromPipe (ChannelMessage) override
 Accept an incoming MIDI Channel message. More...
 
void sinkMIDIfromPipe (SysExMessage) override
 Accept an incoming MIDI System Exclusive message. More...
 
void sinkMIDIfromPipe (RealTimeMessage) override
 Accept an incoming MIDI Real-Time message. More...
 

Protected Attributes

MIDI_Callbackscallbacks = nullptr
 
MIDIReadEvent event = MIDIReadEvent::NO_MESSAGE
 
MIDI_PipesourcePipe = nullptr
 
MIDI_PipesinkPipe = nullptr
 
Updatable< MIDI_Interface, false > * next
 
Updatable< MIDI_Interface, false > * previous
 

Static Protected Attributes

static DoublyLinkedList< Updatable< MIDI_Interface, false > > updatables
 
static Mutex mutex
 

Private Member Functions

void writeUSBPacket (uint8_t cn, uint8_t cin, uint8_t d0, uint8_t d1, uint8_t d2)
 
MIDIUSBPacket_t readUSBPacket ()
 
void flushUSB ()
 
void sendImpl (uint8_t header, uint8_t d1, uint8_t d2, uint8_t cn) override
 Low-level function for sending a 3-byte MIDI message. More...
 
void sendImpl (uint8_t header, uint8_t d1, uint8_t cn) override
 Low-level function for sending a 2-byte MIDI message. More...
 
void sendImpl (const uint8_t *data, size_t length, uint8_t cn) override
 Low-level function for sending a system exclusive MIDI message. More...
 
void sendImpl (uint8_t rt, uint8_t cn) override
 Low-level function for sending a single-byte MIDI message. More...
 
bool onRealTimeMessage ()
 
bool onChannelMessage ()
 
bool onSysExMessage ()
 
virtual void lockDownstream (cn_t cn, bool lock)
 Base case for recursive lock function. More...
 
virtual MIDI_SinkgetFinalSink ()
 Base case for recursive function. More...
 
void disconnectSourcePipesShallow ()
 Disconnect only the first pipe connected to this sink. More...
 
virtual MIDI_SourcegetInitialSource ()
 Base case for recursive function. More...
 
void disconnectSinkPipesShallow ()
 Disconnect only the first pipe connected to this source. More...
 

Private Attributes

USBMIDI_Parser parser
 

Static Private Attributes

static MIDI_InterfaceDefaultMIDI_Interface = nullptr
 

Main initialization and updating methods

static void applyToAll (const LockGuard &, void(Derived::*method)(Args &&...), Args &&... args)
 
static void applyToAll (void(Derived::*method)(Args &&...), Args &&... args)
 

Enabling and disabling updatables

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

Main initialization and updating methods

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

Sending MIDI

void send (MIDIMessageType m, Channel c, uint8_t d1, uint8_t d2, Cable cable=CABLE_1)
 Send a 3-byte MIDI packet. More...
 
void send (MIDIMessageType m, Channel c, uint8_t d1, Cable cable=CABLE_1)
 Send a 2-byte MIDI packet. More...
 
void send (ChannelMessage message)
 Send a MIDI Channel Message. More...
 
void send (SysExMessage message)
 Send a MIDI System Exclusive message. More...
 
void send (const uint8_t(&sysexdata)[N], Cable cable=CABLE_1)
 Send a MIDI System Exclusive message. More...
 
void send (RealTimeMessage message)
 Send a MIDI Real-Time message. More...
 
void send (MIDIMessageType rt, Cable cable=CABLE_1)
 Send a single-byte MIDI message. More...
 
void sendOnCable (MIDIMessageType m, Channel c, uint8_t d1, uint8_t d2, Cable cable)
 Send a 3-byte MIDI packet with cable number. More...
 
void sendOnCable (MIDIMessageType m, Channel c, uint8_t d1, Cable cable)
 Send a 2-byte MIDI packet with cable number. More...
 
void sendOnCable (MIDIMessageType rt, Cable cable)
 Send a single-byte MIDI packet with cable number. More...
 
void sendNoteOn (MIDIAddress address, uint8_t velocity)
 Send a MIDI Note On event. More...
 
void sendNoteOff (MIDIAddress address, uint8_t velocity)
 Send a MIDI Note Off event. More...
 
void sendKP (MIDIAddress address, uint8_t pressure)
 Send a MIDI Key Pressure event. More...
 
void sendCC (MIDIAddress address, uint8_t value)
 Send a MIDI Control Change event. More...
 
void sendPC (MIDIAddress address)
 Send a MIDI Program Change event. More...
 
void sendPC (MIDIChannelCN address, uint8_t value)
 Send a MIDI Program Change event. More...
 
void sendCP (MIDIChannelCN address, uint8_t pressure)
 Send a MIDI Channel Pressure event. More...
 
void sendPB (MIDIChannelCN address, uint16_t value)
 Send a MIDI Pitch Bend event. More...
 

Default MIDI Interfaces

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

MIDI Input Callbacks

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

Parsing MIDI Input

MIDI_ParsergetParser ()
 
ChannelMessage getChannelMessage () const
 Return the received channel message. More...
 
RealTimeMessage getRealTimeMessage () const
 Return the received real-time message. More...
 
SysExMessage getSysExMessage () const
 Return the received system exclusive message. More...
 

Connecting and disconnecting MIDI Pipes

void connectSourcePipe (MIDI_Pipe *source)
 Fully connect a source pipe to this sink. More...
 
void disconnectSourcePipes ()
 Disconnect all source pipes that sink to this sink (recursively). More...
 
bool disconnect (TrueMIDI_Source &source)
 Disconnect the given source from this sink. More...
 
bool hasSourcePipe () const
 Check if this sink is connected to a source pipe. More...
 

Sending data over a MIDI Pipe

void sourceMIDItoPipe (ChannelMessage)
 Send a MIDI Channel Message. More...
 
void sourceMIDItoPipe (SysExMessage)
 Send a MIDI System Exclusive message. More...
 
void sourceMIDItoPipe (RealTimeMessage)
 Send a MIDI Real-Time message. More...
 
void exclusive (cn_t cn, bool exclusive=true)
 Enter or exit exclusive mode for the given cable number. More...
 
bool canWrite (cn_t cn) const
 Check if this source can write to the sinks it connects to. More...
 

Connecting and disconnecting MIDI Pipes

bool disconnect (TrueMIDI_Sink &sink)
 Disconnect the given sink from this source. More...
 
void connectSinkPipe (MIDI_Pipe *sink)
 Fully connect a sink pipe to this source. More...
 
void disconnectSinkPipes ()
 Disconnect all sink pipes that this source sinks to (recursively). More...
 
bool hasSinkPipe () const
 Check if this source is connected to a sink pipe. More...
 

Detailed Description

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

On boards that support it, this will create a native MIDI over USB interface using the platform-specific libraries (e.g. MIDIUSB for Arduino Leonardo, or the Core usbMIDI library for Teensy).
On boards without native USB support, it'll fall back to a serial MIDI interface at the default MIDI baud rate on the UART connected to the Serial to USB chip. This can be used with custom MIDI over USB firmware for the Serial to USB chip.

Note
See MIDI over USB for more information.
Examples
1.First-Output.ino, 1.Note-LED.ino, 10.Note-FastLED-ColorMapper.ino, 2.First-Input.ino, 2.Note-Range-LEDs.ino, 4.VULEDs.ino, 5.Note-LED-PWM.ino, 6.MAX7219-NoteLED.ino, 9.Note-FastLED.ino, AbsoluteRotaryEncoder.ino, Bank-Button-Matrix.ino, Bank.ino, CCButton.ino, CCIncrementDecrementButtons.ino, CCPotentiometer-Map.ino, Control-Change-Potentiometer.ino, Custom-MIDI-Output-Element.ino, Custom-MIDI-Sender.ino, Custom-Note-LED-Input-Element-Callback-FastLED.ino, Custom-Note-LED-Input-Element-Callback.ino, Custom-Selector-Callback.ino, Dual-MIDI-Interface.ino, Encoder-Selector-Bank.ino, Mackie-Control-Universal-Reverse-Engineering.ino, ManyAddressesPCButton.ino, MCU-OLED-SSD1306-MEGA.ino, MCU-OLED-SSD1306-x2.ino, MCU-OLED-SSD1306.ino, MIDI-Controller-Finished-Example.ino, MIDI-Input-Callback.ino, MIDI-Input.ino, MIDI-Note-Callback-IR.ino, MIDI-Output.ino, MIDI_controller-97.ino, MIDI_Pipes-Routing.ino, Multiple-Control-Change-Potentiometers.ino, NoteButton.ino, NoteButtonMatrix.ino, PCButton.ino, Pitch-Bend-Potentiometer.ino, Program-Changer.ino, RotaryEncoder.ino, Send-MIDI-Notes.ino, SysEx-Send-Receive.ino, Transpose-Octave-NC-Button.ino, and Transposer.ino.

Definition at line 41 of file USBMIDI_Interface.hpp.

Member Typedef Documentation

◆ MIDIUSBPacket_t

Definition at line 48 of file USBMIDI_Interface.hpp.

◆ Mutex

using Mutex = typename std::conditional<ThreadSafe, DefaultMutEx, EmptyMutex>::type
inherited

Definition at line 36 of file Updatable.hpp.

◆ LockGuard

using LockGuard = typename std::conditional<ThreadSafe, DefaultLockGuard<Mutex>, EmptyLockGuard<Mutex> >::type
inherited

Definition at line 38 of file Updatable.hpp.

Constructor & Destructor Documentation

◆ USBMIDI_Interface()

USBMIDI_Interface ( )
inline

Construct a new USBMIDI_Interface.

Definition at line 46 of file USBMIDI_Interface.hpp.

Member Function Documentation

◆ writeUSBPacket()

void writeUSBPacket ( uint8_t  cn,
uint8_t  cin,
uint8_t  d0,
uint8_t  d1,
uint8_t  d2 
)
inlineprivate

Definition at line 62 of file USBMIDI_Interface.hpp.

◆ readUSBPacket()

MIDIUSBPacket_t readUSBPacket ( )
inlineprivate

Definition at line 66 of file USBMIDI_Interface.hpp.

◆ flushUSB()

void flushUSB ( )
inlineprivate

Definition at line 67 of file USBMIDI_Interface.hpp.

◆ sendImpl() [1/4]

void sendImpl ( uint8_t  header,
uint8_t  d1,
uint8_t  d2,
uint8_t  cn 
)
inlineoverrideprivatevirtual

Low-level function for sending a 3-byte MIDI message.

Implements MIDI_Interface.

Definition at line 70 of file USBMIDI_Interface.hpp.

◆ sendImpl() [2/4]

void sendImpl ( uint8_t  header,
uint8_t  d1,
uint8_t  cn 
)
inlineoverrideprivatevirtual

Low-level function for sending a 2-byte MIDI message.

Implements MIDI_Interface.

Definition at line 78 of file USBMIDI_Interface.hpp.

◆ sendImpl() [3/4]

void sendImpl ( const uint8_t *  data,
size_t  length,
uint8_t  cn 
)
inlineoverrideprivatevirtual

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

Implements MIDI_Interface.

Definition at line 82 of file USBMIDI_Interface.hpp.

◆ sendImpl() [4/4]

void sendImpl ( uint8_t  rt,
uint8_t  cn 
)
inlineoverrideprivatevirtual

Low-level function for sending a single-byte MIDI message.

Implements MIDI_Interface.

Definition at line 97 of file USBMIDI_Interface.hpp.

◆ read()

MIDIReadEvent read ( )
inlineoverridevirtual

Try reading and parsing a single incoming MIDI message.

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

Implements Parsing_MIDI_Interface.

Definition at line 106 of file USBMIDI_Interface.hpp.

◆ getParser()

MIDI_Parser& getParser ( )
inlineinherited

Definition at line 248 of file MIDI_Interface.hpp.

◆ getChannelMessage()

ChannelMessage getChannelMessage ( ) const
inlineinherited

Return the received channel message.

Examples
MIDI-Input.ino.

Definition at line 251 of file MIDI_Interface.hpp.

◆ getRealTimeMessage()

RealTimeMessage getRealTimeMessage ( ) const
inlineinherited

Return the received real-time message.

Examples
MIDI-Input.ino.

Definition at line 256 of file MIDI_Interface.hpp.

◆ getSysExMessage()

SysExMessage getSysExMessage ( ) const
inlineinherited

Return the received system exclusive message.

Examples
MIDI-Input.ino, and SysEx-Send-Receive.ino.

Definition at line 261 of file MIDI_Interface.hpp.

◆ update()

void update ( )
overridevirtualinherited

Read the MIDI interface and call the callback if a message is received.

Implements MIDI_Interface.

Examples
MIDI-Input.ino, MIDI-Output.ino, MIDI_Pipes-Routing.ino, Send-MIDI-Notes.ino, and SysEx-Send-Receive.ino.

Definition at line 34 of file MIDI_Interface.cpp.

◆ setCallbacks() [1/4]

void setCallbacks ( MIDI_Callbacks cb)
inlineoverridevirtualinherited

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

Parameters
cbA pointer to an object that implements the MIDI_Callbacks class.

Implements MIDI_Interface.

Examples
MIDI-Input.ino, and SysEx-Send-Receive.ino.

Definition at line 267 of file MIDI_Interface.hpp.

◆ setCallbacks() [2/4]

virtual void setCallbacks
inherited

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

Parameters
cbA pointer to an object that implements the MIDI_Callbacks class.

◆ setCallbacks() [3/4]

void setCallbacks
inlineinherited

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

Parameters
cbA reference to an object that implements the MIDI_Callbacks class.

Definition at line 192 of file MIDI_Interface.hpp.

◆ setCallbacks() [4/4]

void setCallbacks ( MIDI_Callbacks cb)
inlineinherited

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

Parameters
cbA reference to an object that implements the MIDI_Callbacks class.

Definition at line 192 of file MIDI_Interface.hpp.

◆ dispatchMIDIEvent()

bool dispatchMIDIEvent ( MIDIReadEvent  event)
protectedinherited

Definition at line 47 of file MIDI_Interface.cpp.

◆ onRealTimeMessage()

bool onRealTimeMessage ( )
privateinherited

Definition at line 57 of file MIDI_Interface.cpp.

◆ onChannelMessage()

bool onChannelMessage ( )
privateinherited

Definition at line 66 of file MIDI_Interface.cpp.

◆ onSysExMessage()

bool onSysExMessage ( )
privateinherited

Definition at line 78 of file MIDI_Interface.cpp.

◆ begin()

void begin ( )
inlineoverridevirtualinherited

◆ getDefault()

MIDI_Interface * getDefault ( )
staticinherited

Return the default MIDI interface.

Definition at line 14 of file MIDI_Interface.cpp.

◆ setAsDefault()

void setAsDefault ( )
inherited

Set this MIDI interface as the default interface.

Definition at line 12 of file MIDI_Interface.cpp.

◆ sinkMIDIfromPipe() [1/3]

void sinkMIDIfromPipe ( ChannelMessage  msg)
overrideprotectedvirtualinherited

Accept an incoming MIDI Channel message.

Implements MIDI_Sink.

Definition at line 28 of file MIDI_Interface.cpp.

◆ sinkMIDIfromPipe() [2/3]

void sinkMIDIfromPipe ( SysExMessage  msg)
overrideprotectedvirtualinherited

Accept an incoming MIDI System Exclusive message.

Implements MIDI_Sink.

Definition at line 29 of file MIDI_Interface.cpp.

◆ sinkMIDIfromPipe() [3/3]

void sinkMIDIfromPipe ( RealTimeMessage  msg)
overrideprotectedvirtualinherited

Accept an incoming MIDI Real-Time message.

Implements MIDI_Sink.

Definition at line 30 of file MIDI_Interface.cpp.

◆ connectSourcePipe()

void connectSourcePipe ( MIDI_Pipe source)
inherited

Fully connect a source pipe to this sink.

Definition at line 15 of file MIDI_Pipes.cpp.

◆ disconnectSourcePipes()

void disconnectSourcePipes ( )
inherited

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

Definition at line 24 of file MIDI_Pipes.cpp.

◆ disconnect() [1/2]

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 39 of file MIDI_Pipes.cpp.

◆ disconnect() [2/2]

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 94 of file MIDI_Pipes.cpp.

◆ hasSourcePipe()

bool hasSourcePipe ( ) const
inlineinherited

Check if this sink is connected to a source pipe.

Definition at line 94 of file MIDI_Pipes.hpp.

◆ lockDownstream()

virtual void lockDownstream ( cn_t  cn,
bool  lock 
)
inlineprivatevirtualinherited

Base case for recursive lock function.

See also
MIDI_Pipe::lockDownstream

Reimplemented in MIDI_Pipe.

Definition at line 105 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 108 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 32 of file MIDI_Pipes.cpp.

◆ sourceMIDItoPipe() [1/3]

void sourceMIDItoPipe ( ChannelMessage  msg)
inherited

Send a MIDI Channel Message.

Definition at line 132 of file MIDI_Pipes.cpp.

◆ sourceMIDItoPipe() [2/3]

void sourceMIDItoPipe ( SysExMessage  msg)
inherited

Send a MIDI System Exclusive message.

Definition at line 137 of file MIDI_Pipes.cpp.

◆ sourceMIDItoPipe() [3/3]

void sourceMIDItoPipe ( RealTimeMessage  msg)
inherited

Send a MIDI Real-Time message.

Definition at line 142 of file MIDI_Pipes.cpp.

◆ exclusive()

void exclusive ( cn_t  cn,
bool  exclusive = true 
)
inherited

Enter or exit exclusive mode for the given cable number.

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 exits exclusive mode until they can send again.

Parameters
cnCable number to set the exclusive mode for [0, 15].
exclusiveTrue to enable exclusive mode, false to disable.

Definition at line 123 of file MIDI_Pipes.cpp.

◆ canWrite()

bool canWrite ( cn_t  cn) const
inherited

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

Returns false if any of the sinks have another source that is in exclusive mode.

Parameters
cnCable number to check [0, 15].

Definition at line 128 of file MIDI_Pipes.cpp.

◆ connectSinkPipe()

void connectSinkPipe ( MIDI_Pipe sink)
inherited

Fully connect a sink pipe to this source.

Definition at line 70 of file MIDI_Pipes.cpp.

◆ disconnectSinkPipes()

void disconnectSinkPipes ( )
inherited

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

Definition at line 79 of file MIDI_Pipes.cpp.

◆ hasSinkPipe()

bool hasSinkPipe ( ) const
inlineinherited

Check if this source is connected to a sink pipe.

Definition at line 189 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 200 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 87 of file MIDI_Pipes.cpp.

◆ send() [1/7]

void send ( MIDIMessageType  m,
Channel  c,
uint8_t  d1,
uint8_t  d2,
Cable  cable = CABLE_1 
)
inherited

Send a 3-byte MIDI packet.

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. [1, 16]
Examples
SysEx-Send-Receive.ino.

Definition at line 38 of file MIDI_Interface.ipp.

◆ send() [2/7]

void send ( MIDIMessageType  m,
Channel  c,
uint8_t  d1,
Cable  cable = CABLE_1 
)
inherited

Send a 2-byte MIDI packet.

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

Definition at line 53 of file MIDI_Interface.ipp.

◆ send() [3/7]

void send ( ChannelMessage  message)
inherited

Send a MIDI Channel Message.

Definition at line 113 of file MIDI_Interface.ipp.

◆ send() [4/7]

void send ( SysExMessage  message)
inherited

Send a MIDI System Exclusive message.

Definition at line 115 of file MIDI_Interface.ipp.

◆ send() [5/7]

void send ( const uint8_t(&)  sysexdata[N],
Cable  cable = CABLE_1 
)
inlineinherited

Send a MIDI System Exclusive message.

Definition at line 118 of file MIDI_Interface.hpp.

◆ send() [6/7]

void send ( RealTimeMessage  message)
inherited

Send a MIDI Real-Time message.

Definition at line 122 of file MIDI_Interface.ipp.

◆ send() [7/7]

void send ( MIDIMessageType  rt,
Cable  cable = CABLE_1 
)
inherited

Send a single-byte MIDI message.

Definition at line 124 of file MIDI_Interface.ipp.

◆ sendOnCable() [1/3]

void sendOnCable ( MIDIMessageType  m,
Channel  c,
uint8_t  d1,
uint8_t  d2,
Cable  cable 
)
inherited

Send a 3-byte MIDI packet with cable number.

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. [1, 16]

Definition at line 69 of file MIDI_Interface.ipp.

◆ sendOnCable() [2/3]

void sendOnCable ( MIDIMessageType  m,
Channel  c,
uint8_t  d1,
Cable  cable 
)
inherited

Send a 2-byte MIDI packet with cable number.

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

Definition at line 84 of file MIDI_Interface.ipp.

◆ sendOnCable() [3/3]

void sendOnCable ( MIDIMessageType  rt,
Cable  cable 
)
inherited

Send a single-byte MIDI packet with cable number.

Parameters
rtThe MIDI byte to send.
cableThe MIDI Cable Number. [1, 16]

Definition at line 94 of file MIDI_Interface.ipp.

◆ sendNoteOn()

void sendNoteOn ( MIDIAddress  address,
uint8_t  velocity 
)
inherited

Send a MIDI Note On event.

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

Definition at line 97 of file MIDI_Interface.ipp.

◆ sendNoteOff()

void sendNoteOff ( MIDIAddress  address,
uint8_t  velocity 
)
inherited

Send a MIDI Note Off event.

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

Definition at line 99 of file MIDI_Interface.ipp.

◆ sendKP()

void sendKP ( MIDIAddress  address,
uint8_t  pressure 
)
inherited

Send a MIDI Key Pressure event.

Definition at line 101 of file MIDI_Interface.ipp.

◆ sendCC()

void sendCC ( MIDIAddress  address,
uint8_t  value 
)
inherited

Send a MIDI Control Change event.

Definition at line 103 of file MIDI_Interface.ipp.

◆ sendPC() [1/2]

void sendPC ( MIDIAddress  address)
inherited

Send a MIDI Program Change event.

Definition at line 105 of file MIDI_Interface.ipp.

◆ sendPC() [2/2]

void sendPC ( MIDIChannelCN  address,
uint8_t  value 
)
inherited

Send a MIDI Program Change event.

Definition at line 107 of file MIDI_Interface.ipp.

◆ sendCP()

void sendCP ( MIDIChannelCN  address,
uint8_t  pressure 
)
inherited

Send a MIDI Channel Pressure event.

Definition at line 109 of file MIDI_Interface.ipp.

◆ sendPB()

void sendPB ( MIDIChannelCN  address,
uint16_t  value 
)
inherited

Send a MIDI Pitch Bend event.

Definition at line 111 of file MIDI_Interface.ipp.

◆ beginAll()

static void beginAll ( )
inlinestaticinherited

Begin all enabled instances of this class.

See also
begin()

Definition at line 208 of file Updatable.hpp.

◆ updateAll()

static void updateAll ( )
inlinestaticinherited

Update all enabled instances of this class.

See also
update()

Definition at line 212 of file Updatable.hpp.

◆ getMutex()

static Mutex& getMutex ( )
inlinestaticinherited

Definition at line 79 of file Updatable.hpp.

◆ applyToAll() [1/2]

static void applyToAll ( const LockGuard ,
void(Derived::*)(Args &&...)  method,
Args &&...  args 
)
inlinestaticinherited

Definition at line 85 of file Updatable.hpp.

◆ applyToAll() [2/2]

static void applyToAll ( void(Derived::*)(Args &&...)  method,
Args &&...  args 
)
inlinestaticinherited

Definition at line 93 of file Updatable.hpp.

◆ enable() [1/5]

void enable ( const LockGuard lock)
inlineinherited

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

Definition at line 106 of file Updatable.hpp.

◆ enable() [2/5]

void enable ( )
inlineinherited

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

Definition at line 115 of file Updatable.hpp.

◆ enable() [3/5]

static void enable ( UpdatableCRTP< Updatable< MIDI_Interface, false >, false > *  element)
inlinestaticinherited

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

Definition at line 144 of file Updatable.hpp.

◆ enable() [4/5]

static void enable ( UpdatableCRTP< Updatable< MIDI_Interface, false >, false > &  element)
inlinestaticinherited

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

Definition at line 146 of file Updatable.hpp.

◆ enable() [5/5]

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 149 of file Updatable.hpp.

◆ disable() [1/5]

void disable ( const LockGuard lock)
inlineinherited

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

Definition at line 119 of file Updatable.hpp.

◆ disable() [2/5]

void disable ( )
inlineinherited

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

Definition at line 128 of file Updatable.hpp.

◆ disable() [3/5]

static void disable ( UpdatableCRTP< Updatable< MIDI_Interface, false >, false > *  element)
inlinestaticinherited

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

Definition at line 155 of file Updatable.hpp.

◆ disable() [4/5]

static void disable ( UpdatableCRTP< Updatable< MIDI_Interface, false >, false > &  element)
inlinestaticinherited

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

Definition at line 157 of file Updatable.hpp.

◆ disable() [5/5]

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 160 of file Updatable.hpp.

◆ isEnabled() [1/2]

bool isEnabled ( const LockGuard ) 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 136 of file Updatable.hpp.

◆ isEnabled() [2/2]

bool isEnabled ( )
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 141 of file Updatable.hpp.

◆ moveDown() [1/2]

void moveDown ( const LockGuard )
inlineinherited

Move down this element in the list.

Definition at line 166 of file Updatable.hpp.

◆ moveDown() [2/2]

void moveDown ( )
inlineinherited

Move down this element in the list.

Definition at line 168 of file Updatable.hpp.

Member Data Documentation

◆ parser

USBMIDI_Parser parser
private

Definition at line 51 of file USBMIDI_Interface.hpp.

◆ callbacks

MIDI_Callbacks* callbacks = nullptr
protectedinherited

Definition at line 287 of file MIDI_Interface.hpp.

◆ event

MIDIReadEvent event = MIDIReadEvent::NO_MESSAGE
protectedinherited

Definition at line 288 of file MIDI_Interface.hpp.

◆ DefaultMIDI_Interface

MIDI_Interface * DefaultMIDI_Interface = nullptr
staticprivateinherited

Definition at line 226 of file MIDI_Interface.hpp.

◆ sourcePipe

MIDI_Pipe* sourcePipe = nullptr
protectedinherited

Definition at line 117 of file MIDI_Pipes.hpp.

◆ sinkPipe

MIDI_Pipe* sinkPipe = nullptr
protectedinherited

Definition at line 209 of file MIDI_Pipes.hpp.

◆ updatables

DoublyLinkedList< Updatable< MIDI_Interface, false > > updatables
staticprotectedinherited

Definition at line 173 of file Updatable.hpp.

◆ mutex

UpdatableCRTP< Updatable< MIDI_Interface, false > , ThreadSafe >::Mutex mutex
staticprotectedinherited

Definition at line 174 of file Updatable.hpp.

◆ next

Updatable< MIDI_Interface, false > * next
protectedinherited

Definition at line 323 of file LinkedList.hpp.

◆ previous

Updatable< MIDI_Interface, false > * previous
protectedinherited

Definition at line 324 of file LinkedList.hpp.


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