Control Surface  1.1.1
MIDI Control Surface library for Arduino
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Parsing_MIDI_Interface Class Referenceabstract

An abstract class for MIDI interfaces. More...

#include <MIDI_Interfaces/MIDI_Interface.hpp>

Inheritance diagram for Parsing_MIDI_Interface:
Collaboration diagram for Parsing_MIDI_Interface:

Public Member Functions

MIDI_ParsergetParser ()
 
ChannelMessage getChannelMessage ()
 Return the received channel message. More...
 
SysExMessage getSysExMessage () const
 Return the received system exclusive message. More...
 
uint8_t getCN () const
 Return the cable number of the received 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...
 
virtual void begin ()
 Initialize the MIDI Interface. More...
 
void send (uint8_t m, uint8_t c, uint8_t d1, uint8_t d2)
 Send a 3-byte MIDI packet. More...
 
void send (uint8_t m, uint8_t c, uint8_t d1)
 Send a 2-byte MIDI packet. More...
 
void send (SysExMessage message)
 Send a MIDI System Exclusive message. More...
 
template<size_t N>
void send (const uint8_t(&sysexdata)[N], uint8_t cn=0)
 Send a MIDI System Exclusive message. More...
 
void send (uint8_t rt, uint8_t cn=0)
 Send a single-byte MIDI message. More...
 
void sendOnCable (uint8_t m, uint8_t c, uint8_t d1, uint8_t d2, uint8_t cn)
 Send a 3-byte MIDI packet with cable number. More...
 
void sendOnCable (uint8_t m, uint8_t c, uint8_t d1, uint8_t cn)
 Send a 2-byte MIDI packet with cable number. More...
 
void sendOnCable (uint8_t r, uint8_t cn)
 Send a single-byte MIDI packet with cable number. More...
 
void sendNoteOn (MIDICNChannelAddress address, uint8_t velocity)
 Send a MIDI Note On event. More...
 
void sendNoteOff (MIDICNChannelAddress address, uint8_t velocity)
 Send a MIDI Note Off event. More...
 
void sendKP (MIDICNChannelAddress address, uint8_t pressure)
 Send a MIDI Key Pressure event. More...
 
void sendCC (MIDICNChannelAddress address, uint8_t value)
 Send a MIDI Control Change event. More...
 
void sendPC (MIDICNChannelAddress address)
 Send a MIDI Program Change event. More...
 
void sendPC (MIDICNChannel address, uint8_t value)
 Send a MIDI Program Change event. More...
 
void sendCP (MIDICNChannel address, uint8_t pressure)
 Send a MIDI Channel Pressure event. More...
 
void sendPB (MIDICNChannel address, uint16_t value)
 Send a MIDI Pitch Bend event. More...
 
void setAsDefault ()
 Set this MIDI interface as the default interface. More...
 
void setCallbacks (MIDI_Callbacks &cb)
 Set the callbacks that will be called when a MIDI message is received. More...
 
virtual void sendImpl (uint8_t m, uint8_t c, uint8_t d1, uint8_t d2, uint8_t cn)=0
 Low-level function for sending a 3-byte MIDI message. More...
 
virtual void sendImpl (uint8_t m, uint8_t c, uint8_t d1, uint8_t cn)=0
 Low-level function for sending a 2-byte MIDI message. More...
 
virtual void sendImpl (const uint8_t *data, size_t length, uint8_t cn)=0
 Low-level function for sending a system exclusive MIDI message. More...
 
virtual void sendImpl (uint8_t rt, uint8_t cn)=0
 Low-level function for sending a single-byte MIDI message. More...
 

Static Public Member Functions

static MIDI_InterfacegetDefault ()
 Return the default MIDI interface. More...
 

Protected Member Functions

 Parsing_MIDI_Interface (MIDI_Parser &parser)
 Construct a MIDI interface with the given parser. More...
 
bool dispatchMIDIEvent (MIDI_read_t event)
 

Private Member Functions

virtual MIDI_read_t read ()=0
 
void onRealtimeMessage (uint8_t message)
 
void onChannelMessage ()
 
void onSysExMessage ()
 

Private Attributes

MIDI_Parserparser
 
MIDI_Callbackscallbacks = nullptr
 

Static Private Attributes

static MIDI_InterfaceDefaultMIDI_Interface = nullptr
 

Detailed Description

An abstract class for MIDI interfaces.

Examples
SysEx-Send-Receive.ino.

Definition at line 188 of file MIDI_Interface.hpp.

Constructor & Destructor Documentation

◆ Parsing_MIDI_Interface()

Parsing_MIDI_Interface ( MIDI_Parser parser)
protected

Construct a MIDI interface with the given parser.

     Also set this interface as the default MIDI interface.
Parameters
parserThe MIDI parser to use for the interface.

Definition at line 117 of file MIDI_Interface.cpp.

Member Function Documentation

◆ getParser()

MIDI_Parser& getParser ( )
inline

Definition at line 201 of file MIDI_Interface.hpp.

◆ getChannelMessage()

ChannelMessage getChannelMessage ( )

Return the received channel message.

Definition at line 120 of file MIDI_Interface.cpp.

◆ getSysExMessage()

SysExMessage getSysExMessage ( ) const

Return the received system exclusive message.

Examples
SysEx-Send-Receive.ino.

Definition at line 124 of file MIDI_Interface.cpp.

◆ getCN()

uint8_t getCN ( ) const

Return the cable number of the received message.

Definition at line 128 of file MIDI_Interface.cpp.

◆ update()

void update ( )
overridevirtual

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

Implements MIDI_Interface.

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

Definition at line 132 of file MIDI_Interface.cpp.

◆ setCallbacks() [1/4]

void setCallbacks ( MIDI_Callbacks cb)
inlineoverridevirtual

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
SysEx-Send-Receive.ino.

Definition at line 220 of file MIDI_Interface.hpp.

◆ dispatchMIDIEvent()

bool dispatchMIDIEvent ( MIDI_read_t  event)
protected

Definition at line 143 of file MIDI_Interface.cpp.

◆ read()

virtual MIDI_read_t read ( )
privatepure virtual

◆ onRealtimeMessage()

void onRealtimeMessage ( uint8_t  message)
private

Definition at line 154 of file MIDI_Interface.cpp.

◆ onChannelMessage()

void onChannelMessage ( )
private

Definition at line 159 of file MIDI_Interface.cpp.

◆ onSysExMessage()

void onSysExMessage ( )
private

Definition at line 164 of file MIDI_Interface.cpp.

◆ setCallbacks() [2/4]

virtual void setCallbacks

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
inline

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 159 of file MIDI_Interface.hpp.

◆ begin()

virtual void begin ( )
inlinevirtualinherited

◆ send() [1/5]

void send ( uint8_t  m,
uint8_t  c,
uint8_t  d1,
uint8_t  d2 
)
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]
Examples
SysEx-Send-Receive.ino.

Definition at line 22 of file MIDI_Interface.cpp.

◆ send() [2/5]

void send ( uint8_t  m,
uint8_t  c,
uint8_t  d1 
)
inherited

Send a 2-byte MIDI packet.

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

Definition at line 26 of file MIDI_Interface.cpp.

◆ send() [3/5]

void send ( SysExMessage  message)
inherited

Send a MIDI System Exclusive message.

Definition at line 100 of file MIDI_Interface.cpp.

◆ send() [4/5]

void send ( const uint8_t(&)  sysexdata[N],
uint8_t  cn = 0 
)
inlineinherited

Send a MIDI System Exclusive message.

Definition at line 120 of file MIDI_Interface.hpp.

◆ send() [5/5]

void send ( uint8_t  rt,
uint8_t  cn = 0 
)
inherited

Send a single-byte MIDI message.

Definition at line 109 of file MIDI_Interface.cpp.

◆ sendOnCable() [1/3]

void sendOnCable ( uint8_t  m,
uint8_t  c,
uint8_t  d1,
uint8_t  d2,
uint8_t  cn 
)
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]
cnThe MIDI Cable Number. [0, 15]

Definition at line 30 of file MIDI_Interface.cpp.

◆ sendOnCable() [2/3]

void sendOnCable ( uint8_t  m,
uint8_t  c,
uint8_t  d1,
uint8_t  cn 
)
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]
cnThe MIDI Cable Number. [0, 15]

Definition at line 42 of file MIDI_Interface.cpp.

◆ sendOnCable() [3/3]

void sendOnCable ( uint8_t  r,
uint8_t  cn 
)
inherited

Send a single-byte MIDI packet with cable number.

Parameters
rThe MIDI byte to send.
cnThe MIDI Cable Number. [0, 15]

Definition at line 52 of file MIDI_Interface.cpp.

◆ sendNoteOn()

void sendNoteOn ( MIDICNChannelAddress  address,
uint8_t  velocity 
)
inherited

Send a MIDI Note On event.

Examples
Send-MIDI-Notes.ino.

Definition at line 58 of file MIDI_Interface.cpp.

◆ sendNoteOff()

void sendNoteOff ( MIDICNChannelAddress  address,
uint8_t  velocity 
)
inherited

Send a MIDI Note Off event.

Examples
Send-MIDI-Notes.ino.

Definition at line 64 of file MIDI_Interface.cpp.

◆ sendKP()

void sendKP ( MIDICNChannelAddress  address,
uint8_t  pressure 
)
inherited

Send a MIDI Key Pressure event.

Definition at line 70 of file MIDI_Interface.cpp.

◆ sendCC()

void sendCC ( MIDICNChannelAddress  address,
uint8_t  value 
)
inherited

Send a MIDI Control Change event.

Definition at line 75 of file MIDI_Interface.cpp.

◆ sendPC() [1/2]

void sendPC ( MIDICNChannelAddress  address)
inherited

Send a MIDI Program Change event.

Definition at line 85 of file MIDI_Interface.cpp.

◆ sendPC() [2/2]

void sendPC ( MIDICNChannel  address,
uint8_t  value 
)
inherited

Send a MIDI Program Change event.

Definition at line 80 of file MIDI_Interface.cpp.

◆ sendCP()

void sendCP ( MIDICNChannel  address,
uint8_t  pressure 
)
inherited

Send a MIDI Channel Pressure event.

Definition at line 90 of file MIDI_Interface.cpp.

◆ sendPB()

void sendPB ( MIDICNChannel  address,
uint16_t  value 
)
inherited

Send a MIDI Pitch Bend event.

Definition at line 95 of file MIDI_Interface.cpp.

◆ getDefault()

MIDI_Interface * getDefault ( )
staticinherited

Return the default MIDI interface.

Definition at line 18 of file MIDI_Interface.cpp.

◆ setAsDefault()

void setAsDefault ( )
inherited

Set this MIDI interface as the default interface.

Definition at line 16 of file MIDI_Interface.cpp.

◆ 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 159 of file MIDI_Interface.hpp.

◆ sendImpl() [1/4]

virtual void sendImpl ( uint8_t  m,
uint8_t  c,
uint8_t  d1,
uint8_t  d2,
uint8_t  cn 
)
pure virtualinherited

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

Implemented in BluetoothMIDI_Interface, USBMIDI_Interface, MultiMIDI_Interface< N >, StreamMIDI_Interface, and StreamDebugMIDI_Interface.

◆ sendImpl() [2/4]

virtual void sendImpl ( uint8_t  m,
uint8_t  c,
uint8_t  d1,
uint8_t  cn 
)
pure virtualinherited

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

Implemented in BluetoothMIDI_Interface, USBMIDI_Interface, MultiMIDI_Interface< N >, StreamMIDI_Interface, and StreamDebugMIDI_Interface.

◆ sendImpl() [3/4]

virtual void sendImpl ( const uint8_t *  data,
size_t  length,
uint8_t  cn 
)
pure virtualinherited

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

Implemented in BluetoothMIDI_Interface, USBMIDI_Interface, MultiMIDI_Interface< N >, StreamMIDI_Interface, and StreamDebugMIDI_Interface.

◆ sendImpl() [4/4]

virtual void sendImpl ( uint8_t  rt,
uint8_t  cn 
)
pure virtualinherited

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

Implemented in BluetoothMIDI_Interface, USBMIDI_Interface, StreamMIDI_Interface, MultiMIDI_Interface< N >, and StreamDebugMIDI_Interface.

Member Data Documentation

◆ parser

MIDI_Parser& parser
private

Definition at line 239 of file MIDI_Interface.hpp.

◆ callbacks

MIDI_Callbacks* callbacks = nullptr
private

Definition at line 240 of file MIDI_Interface.hpp.

◆ DefaultMIDI_Interface

MIDI_Interface * DefaultMIDI_Interface = nullptr
staticprivateinherited

Definition at line 182 of file MIDI_Interface.hpp.


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