#include <MIDI_Interfaces/GenericBLEMIDI_Interface.hpp>
template<class Backend>
class GenericBLEMIDI_Interface< Backend >
Bluetooth Low Energy MIDI Interface.
Definition at line 16 of file GenericBLEMIDI_Interface.hpp.
|
BLESettings | ble_settings |
| BLE backend configuration option.
|
|
void | setName (const char *name) |
| Set the BLE device name.
|
|
void | setTimeout (std::chrono::milliseconds timeout) |
| Set the timeout, the number of milliseconds to buffer the outgoing MIDI messages.
|
|
|
void | begin () override |
| Initialize the BLE hardware and start advertising as a MIDI over BLE peripheral.
|
|
void | end () |
|
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.
|
|
bool | isConnected () const |
| Returns true if a BLE central is currently connected.
|
|
|
void | stall (MIDIStaller *cause=eternal_stall) |
| Stall this MIDI source.
|
|
void | unstall (MIDIStaller *cause=eternal_stall) |
| Un-stall the pipes connected to this source, so other sources are allowed to send again.
|
|
bool | isStalled () const |
| Check if this source can write to the sinks it connects to.
|
|
MIDIStaller * | getStaller () const |
| Get a pointer to whatever is causing this MIDI source to be stalled.
|
|
const char * | getStallerName () const |
| Get the name of whatever is causing this MIDI source to be stalled.
|
|
void | handleStallers () const |
| Give the code that is stalling the MIDI sink pipes the opportunity to do its job and un-stall the pipes.
|
|
|
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.
|
|
|
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.
|
|
|
void | sendNow () |
| Causes all buffered messages to be sent immediately.
|
|
|
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.
|
|
|
static void | beginAll () |
| Begin all enabled instances of this class.
|
|
static void | updateAll () |
| Update all enabled instances of this class.
|
|
|
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) |
|
|
Backend | backend |
| Low-level BLE backend for sending and receiving MIDI over BLE packets.
|
|
◆ GenericBLEMIDI_Interface()
template<class Backend >
template<class... Args>
◆ sendImpl()
template<class Backend >
template<class L , class F >
void sendImpl |
( |
L & | lck, |
|
|
F | add_to_buffer ) |
|
private |
◆ sendChannelMessageImpl()
Low-level function for sending a MIDI channel voice message.
Implements MIDI_Interface.
◆ sendSysCommonImpl()
Low-level function for sending a MIDI system common message.
Implements MIDI_Interface.
◆ sendSysExImpl()
Low-level function for sending a system exclusive MIDI message.
Implements MIDI_Interface.
◆ sendRealTimeImpl()
Low-level function for sending a MIDI real-time message.
Implements MIDI_Interface.
◆ sendNowImpl()
Low-level function for sending any buffered outgoing MIDI messages.
Implements MIDI_Interface.
◆ handleStall() [1/2]
template<class Backend >
|
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 34 of file GenericBLEMIDI_Interface.hpp.
◆ getName()
template<class Backend >
const char * getName |
( |
| ) |
const |
|
inlineoverrideprivatevirtual |
◆ begin()
◆ end()
◆ update()
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.
Definition at line 52 of file GenericBLEMIDI_Interface.hpp.
◆ isConnected()
template<class Backend >
bool isConnected |
( |
| ) |
const |
|
inline |
Returns true if a BLE central is currently connected.
- Note
- This is useful for e.g. turning on/off an LED or showing a message to the user, but it's not all that useful for anything else, because the connection could be terminated at any moment.
Definition at line 57 of file GenericBLEMIDI_Interface.hpp.
◆ 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()
Return the received channel voice message.
◆ getSysCommonMessage()
Return the received system common message.
◆ getRealTimeMessage()
Return the received real-time message.
◆ getSysExMessage()
Return the received system exclusive message.
◆ getTimestamp()
template<class Backend >
uint16_t getTimestamp |
( |
| ) |
const |
Get the BLE-MIDI timestamp of the latest MIDI message.
- Note
- Invalid for SysEx chunks (except the last chunk of a message).
◆ setName()
template<class Backend >
void setName |
( |
const char * | name | ) |
|
Set the BLE device name.
Must be called before begin(). Length is limited by the size of the BLE advertising packets.
◆ setTimeout()
template<class Backend >
void setTimeout |
( |
std::chrono::milliseconds | timeout | ) |
|
|
inline |
Set the timeout, the number of milliseconds to buffer the outgoing MIDI messages.
A shorter timeout usually results in lower latency, but also causes more overhead, because more packets might be required.
Definition at line 100 of file GenericBLEMIDI_Interface.hpp.
◆ setAsDefault()
◆ getDefault()
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]
◆ setCallbacks() [2/2]
Set the callbacks that will be called when a MIDI message is received.
- Parameters
-
cb | A reference to the callback object. |
Definition at line 62 of file MIDI_Interface.hpp.
◆ sinkMIDIfromPipe() [1/4]
|
inlineoverrideprotectedvirtualinherited |
◆ sinkMIDIfromPipe() [2/4]
|
inlineoverrideprotectedvirtualinherited |
◆ sinkMIDIfromPipe() [3/4]
|
inlineoverrideprotectedvirtualinherited |
◆ sinkMIDIfromPipe() [4/4]
|
inlineoverrideprotectedvirtualinherited |
◆ onChannelMessage()
Call the channel message callback and send the message to the sink pipe.
Definition at line 35 of file MIDI_Interface.cpp.
◆ onSysExMessage()
Call the SysEx message callback and send the message to the sink pipe.
Definition at line 41 of file MIDI_Interface.cpp.
◆ onSysCommonMessage()
Call the System Common message callback and send the message to the sink pipe.
Definition at line 47 of file MIDI_Interface.cpp.
◆ onRealTimeMessage()
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()
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]
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]
◆ disconnect() [3/4]
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]
◆ 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()
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()
|
inlineprivatevirtualinherited |
◆ unstallDownstream()
|
inlineprivatevirtualinherited |
◆ getFinalSink()
|
inlineprivatevirtualinherited |
◆ 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]
◆ swap() [2/2]
◆ sourceMIDItoPipe() [1/4]
◆ sourceMIDItoPipe() [2/4]
Send a MIDI System Exclusive message down the pipe.
Definition at line 139 of file MIDI_Pipes.cpp.
◆ sourceMIDItoPipe() [3/4]
Send a MIDI System Common message down the pipe.
Definition at line 145 of file MIDI_Pipes.cpp.
◆ sourceMIDItoPipe() [4/4]
Send a MIDI Real-Time message down the pipe.
Definition at line 151 of file MIDI_Pipes.cpp.
◆ 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
-
cause | Pointer to the reason for this stall, can be called back to un-stall the pipes. |
Definition at line 158 of file MIDI_Pipes.cpp.
◆ unstall()
Un-stall the pipes connected to this source, so other sources are allowed to send again.
- Parameters
-
cause | Pointer to the reason for the stall (this has to be the same one that was used to stall). |
Definition at line 164 of file MIDI_Pipes.cpp.
◆ isStalled()
Check if this source can write to the sinks it connects to.
Definition at line 170 of file MIDI_Pipes.cpp.
◆ getStaller()
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()
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()
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()
|
inlineprivatevirtualinherited |
◆ unstallUpstream()
|
inlineprivatevirtualinherited |
◆ getInitialSource()
|
inlineprivatevirtualinherited |
◆ 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]
Send a MIDI Channel Voice message.
◆ send() [2/4]
Send a MIDI System Common message.
◆ send() [3/4]
Send a MIDI System Exclusive message.
◆ send() [4/4]
Send a MIDI Real-Time message.
◆ sendChannelMessage() [1/2]
Send a 3-byte MIDI Channel Voice message.
- Parameters
-
m | MIDI message type. [0x80, 0xE0] |
c | The MIDI channel. [1, 16] |
d1 | The first data byte. [0, 127] |
d2 | The second data byte. [0, 127] |
cable | The MIDI Cable Number. [Cable_1, Cable_16] |
◆ sendChannelMessage() [2/2]
Send a 2-byte MIDI Channel Voice message.
- Parameters
-
m | MIDI message type. [0x80, 0xE0] |
c | The MIDI channel. [1, 16] |
d1 | The first data byte. [0, 127] |
cable | The MIDI Cable Number. [1, 16] |
◆ sendNoteOn()
void sendNoteOn |
( |
MIDIAddress | address, |
|
|
uint8_t | velocity ) |
|
inherited |
◆ sendNoteOff()
void sendNoteOff |
( |
MIDIAddress | address, |
|
|
uint8_t | velocity ) |
|
inherited |
◆ sendKeyPressure()
void sendKeyPressure |
( |
MIDIAddress | address, |
|
|
uint8_t | pressure ) |
|
inherited |
◆ sendControlChange()
void sendControlChange |
( |
MIDIAddress | address, |
|
|
uint8_t | value ) |
|
inherited |
◆ sendProgramChange() [1/2]
◆ sendProgramChange() [2/2]
Send a MIDI Program Change event.
◆ sendChannelPressure()
◆ sendPitchBend()
◆ sendSysCommon() [1/3]
Send a MIDI System Common message.
◆ sendSysCommon() [2/3]
Send a MIDI System Common message.
◆ sendSysCommon() [3/3]
Send a MIDI System Common message.
◆ sendMTCQuarterFrame() [1/2]
void sendMTCQuarterFrame |
( |
uint8_t | data, |
|
|
Cable | cable = Cable_1 ) |
|
inherited |
◆ 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 |
◆ sendSongSelect()
◆ sendTuneRequest()
◆ sendSysEx() [1/2]
void sendSysEx |
( |
const uint8_t(&) | sysexdata[N], |
|
|
Cable | cable = Cable_1 ) |
|
inherited |
◆ 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]
Send a MIDI Real-Time message.
◆ sendRealTime() [2/2]
Send a MIDI Real-Time message.
◆ sendTimingClock()
◆ sendStart()
◆ sendContinue()
◆ sendStop()
◆ sendActiveSensing()
◆ sendSystemReset()
◆ sendNow()
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()
Send a MIDI Key Pressure event.
◆ sendCC()
Send a MIDI Control Change event.
◆ sendPC() [1/2]
Send a MIDI Program Change event.
◆ sendPC() [2/2]
Send a MIDI Program Change event.
◆ sendCP()
Send a MIDI Channel Pressure event.
◆ sendPB()
Send a MIDI Pitch Bend event.
◆ beginAll()
◆ updateAll()
static void updateAll |
( |
| ) |
|
|
inlinestaticinherited |
◆ enable() [1/4]
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]
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]
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]
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]
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]
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()
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()
Move down this element in the list.
Definition at line 147 of file Updatable.hpp.
◆ getNameNull()
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.
◆ incomingMessage
template<class Backend >
Backend::IncomingMIDIMessage incomingMessage |
|
private |
◆ ble_settings
◆ backend
◆ callbacks
◆ DefaultMIDI_Interface
◆ sourcePipe
◆ sinkPipe
◆ updatables
◆ next
◆ previous
The documentation for this class was generated from the following file: