#include <MIDI_Interfaces/USBHostMIDI_Interface.hpp>
A class for MIDI interfaces sending MIDI messages to a MIDI USB device connected to a Teensy's USB host port.
Requires a Teensy 3.6 or 4.1 and the USBHost_t36 library.
This one uses the default small buffer (similar to USBHost_t36's MIDIDevice).
- See also
- USBHostMIDI_Interface_BigBuffer for a bigger buffer.
- Examples
- USBHostMIDI_Interface-Passthrough.ino.
Definition at line 40 of file USBHostMIDI_Interface.hpp.
|
| 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.
|
|
| 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.
|
|
| 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 | 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 | 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 | 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 | beginAll () |
| | Begin all enabled instances of this class.
|
| static void | updateAll () |
| | Update all enabled instances of this class.
|
◆ USBHostMIDI_Interface()
◆ sendChannelMessageImpl()
|
|
overrideprivatevirtualinherited |
Low-level function for sending a MIDI channel voice message.
Implements MIDI_Interface.
◆ sendSysCommonImpl()
|
|
overrideprivatevirtualinherited |
Low-level function for sending a MIDI system common message.
Implements MIDI_Interface.
◆ sendSysExImpl()
|
|
overrideprivatevirtualinherited |
Low-level function for sending a system exclusive MIDI message.
Implements MIDI_Interface.
◆ sendRealTimeImpl()
|
|
overrideprivatevirtualinherited |
Low-level function for sending a MIDI real-time message.
Implements MIDI_Interface.
◆ sendNowImpl()
|
|
inlineoverrideprivatevirtualinherited |
◆ handleStall() [1/2]
|
|
inlineoverrideprivatevirtualinherited |
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.
◆ handleStall() [2/2]
| 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 124 of file MIDI_Interface.hpp.
◆ getName()
| const char * getName |
( |
| ) |
const |
|
inlineoverrideprivatevirtualinherited |
◆ begin()
◆ update()
◆ 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.
◆ alwaysSendsImmediately()
| bool alwaysSendsImmediately |
( |
| ) |
const |
|
inlineinherited |
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()
| void neverSendImmediately |
( |
| ) |
|
|
inlineinherited |
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()
| void alwaysSendImmediately |
( |
| ) |
|
|
inlineinherited |
◆ 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 48 of file MIDI_Interface.cpp.
◆ setCallbacks() [1/2]
Set the callbacks that will be called when a MIDI message is received.
- Parameters
-
| cb | A pointer to the callback object. |
Definition at line 58 of file MIDI_Interface.hpp.
◆ 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]
|
|
inlineoverrideprotectedinherited |
◆ sinkMIDIfromPipe() [2/4]
|
|
inlineoverrideprotectedinherited |
Accept an incoming MIDI System Exclusive message from the source pipe.
Definition at line 93 of file MIDI_Interface.hpp.
◆ sinkMIDIfromPipe() [3/4]
|
|
inlineoverrideprotectedinherited |
Accept an incoming MIDI System Common message from the source pipe.
Definition at line 95 of file MIDI_Interface.hpp.
◆ sinkMIDIfromPipe() [4/4]
|
|
inlineoverrideprotectedinherited |
Accept an incoming MIDI Real-Time message from the source pipe.
Definition at line 97 of file MIDI_Interface.hpp.
◆ onChannelMessage()
Call the channel message callback and send the message to the sink pipe.
Definition at line 102 of file MIDI_Interface.cpp.
◆ onSysExMessage()
Call the SysEx message callback and send the message to the sink pipe.
Definition at line 104 of file MIDI_Interface.cpp.
◆ onSysCommonMessage()
Call the System Common message callback and send the message to the sink pipe.
Definition at line 107 of file MIDI_Interface.cpp.
◆ onRealTimeMessage()
Call the real-time message callback and send the message to the sink pipe.
Definition at line 110 of file MIDI_Interface.cpp.
◆ updateIncoming()
| void updateIncoming |
( |
MIDIInterface_t * | iface | ) |
|
|
staticinherited |
Read, parse and dispatch incoming MIDI messages on the given interface.
Definition at line 115 of file MIDI_Interface.hpp.
◆ dispatchIncoming()
| void dispatchIncoming |
( |
MIDIInterface_t * | iface, |
|
|
MIDIReadEvent | event ) |
|
staticinherited |
Dispatch the given type of MIDI message from the given interface.
Definition at line 118 of file MIDI_Interface.hpp.
◆ connectSourcePipe()
Fully connect a source pipe to this sink.
Definition at line 111 of file MIDI_Pipes.cpp.
◆ disconnectSourcePipes()
| void disconnectSourcePipes |
( |
| ) |
|
|
inherited |
Disconnect all source pipes that sink to this sink (recursively).
Definition at line 113 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 118 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 234 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 143 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 184 of file MIDI_Pipes.cpp.
◆ sourceMIDItoPipe() [3/4]
Send a MIDI System Common message down the pipe.
Definition at line 186 of file MIDI_Pipes.cpp.
◆ sourceMIDItoPipe() [4/4]
Send a MIDI Real-Time message down the pipe.
Definition at line 188 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 202 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 208 of file MIDI_Pipes.cpp.
◆ isStalled()
Check if this source can write to the sinks it connects to.
Definition at line 210 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 213 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 216 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 219 of file MIDI_Pipes.cpp.
◆ connectSinkPipe()
Fully connect a sink pipe to this source.
Definition at line 227 of file MIDI_Pipes.cpp.
◆ disconnectSinkPipes()
| void disconnectSinkPipes |
( |
| ) |
|
|
inherited |
Disconnect all sink pipes that this source sinks to (recursively).
Definition at line 229 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 259 of file MIDI_Pipes.cpp.
◆ send()
Send a MIDI Channel Voice message.
◆ sendChannelMessage()
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] |
◆ sendNoteOn()
| void sendNoteOn |
( |
MIDIAddress | address, |
|
|
uint8_t | velocity ) |
|
inherited |
Send a MIDI Note On event.
◆ sendNoteOff()
| void sendNoteOff |
( |
MIDIAddress | address, |
|
|
uint8_t | velocity ) |
|
inherited |
Send a MIDI Note Off event.
◆ sendKeyPressure()
| void sendKeyPressure |
( |
MIDIAddress | address, |
|
|
uint8_t | pressure ) |
|
inherited |
Send a MIDI Key Pressure event.
◆ sendControlChange()
| void sendControlChange |
( |
MIDIAddress | address, |
|
|
uint8_t | value ) |
|
inherited |
Send a MIDI Control Change event.
◆ sendProgramChange()
Send a MIDI Program Change event.
◆ sendChannelPressure()
Send a MIDI Channel Pressure event.
◆ sendPitchBend()
Send a MIDI Pitch Bend event.
◆ sendSysCommon()
Send a MIDI System Common message.
◆ sendMTCQuarterFrame()
| void sendMTCQuarterFrame |
( |
uint8_t | data, |
|
|
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.
◆ sendSongSelect()
Send a MIDI Song Select message.
◆ sendTuneRequest()
Send a MIDI Tune Request.
◆ sendSysEx()
| void sendSysEx |
( |
const uint8_t(&) | sysexdata[N], |
|
|
Cable | cable = Cable_1 ) |
|
inherited |
Send a MIDI System Exclusive message.
◆ sendRealTime()
Send a MIDI Real-Time message.
◆ sendTimingClock()
Send a MIDI Timing Clock message.
◆ sendStart()
Send a MIDI Start message.
◆ sendContinue()
Send a MIDI Continue message.
◆ sendStop()
Send a MIDI Stop message.
◆ sendActiveSensing()
Send a MIDI Active Sensing message.
◆ sendSystemReset()
Send a MIDI System Reset message.
◆ 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()
Send a MIDI Program Change event.
◆ sendCP()
Send a MIDI Channel Pressure event.
◆ sendPB()
Send a MIDI Pitch Bend event.
◆ beginAll()
◆ updateAll()
◆ enable()
Enable this updatable: insert it into the linked list of instances, so it gets updated automatically.
Definition at line 96 of file Updatable.hpp.
◆ disable()
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.
◆ 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 22 of file MIDI_Pipes.cpp.
◆ backend
The (platform-specific) backend used for MIDI over USB communication.
Definition at line 87 of file USBMIDI_Interface.hpp.
◆ parser
◆ sender
◆ alwaysSendImmediately_
| bool alwaysSendImmediately_ |
|
privateinherited |
◆ callbacks
◆ DefaultMIDI_Interface
◆ sourcePipe
◆ sinkPipe
◆ updatables
◆ next
◆ previous
The documentation for this class was generated from the following file: