Control Surface master
MIDI Control Surface library for Arduino
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
USBMIDI_Sender Class Reference

#include <MIDI_Interfaces/USBMIDI_Sender.hpp>

Detailed Description

A class for sending MIDI USB messages.

Includes support for chunked MIDI USB SysEx messages.

Definition at line 13 of file USBMIDI_Sender.hpp.

+ Collaboration diagram for USBMIDI_Sender:

Public Member Functions

template<class Send >
void sendChannelMessage (ChannelMessage, Send &&send)
 Send a MIDI Channel message using the given sender. More...
 
template<class Send >
void sendSysCommonMessage (SysCommonMessage, Send &&send)
 Send a MIDI System Common message using the given sender. More...
 
template<class Send >
void sendRealTimeMessage (RealTimeMessage, Send &&send)
 Send a MIDI Real-Time message using the given sender. More...
 
template<class Send >
void sendSysEx (SysExMessage, Send &&send)
 Send a MIDI System Exclusive message using the given sender. More...
 

Private Types

using CIN = MIDICodeIndexNumber
 

Private Member Functions

template<class Send >
void sendSysExStartCont1 (const uint8_t *data, Cable cable, Send &send)
 Send a single SysEx starts or continues USB packet. More...
 
template<class Send >
void sendSysExStartCont (const uint8_t *&data, uint16_t &length, Cable cable, Send &send)
 Send as many SysEx starts or continues USB packets, such that the remaining length is 3, 2 or 1 byte. More...
 
template<class Send >
void sendSysExEnd (const uint8_t *data, uint16_t length, Cable cable, Send &send)
 Send a SysExEnd USB packet. More...
 

Private Attributes

uint8_t storedSysExData [16][3]
 Stores remainder of outgoing SysEx chunks. More...
 
uint8_t storedSysExLength [16] = {}
 Number of remaining SysEx bytes stored. More...
 

Member Typedef Documentation

◆ CIN

using CIN = MIDICodeIndexNumber
private

Definition at line 63 of file USBMIDI_Sender.hpp.

Member Function Documentation

◆ sendChannelMessage()

void sendChannelMessage ( ChannelMessage  msg,
Send &&  send 
)

Send a MIDI Channel message using the given sender.

Definition at line 67 of file USBMIDI_Sender.hpp.

◆ sendSysCommonMessage()

void sendSysCommonMessage ( SysCommonMessage  msg,
Send &&  send 
)

Send a MIDI System Common message using the given sender.

Definition at line 75 of file USBMIDI_Sender.hpp.

◆ sendRealTimeMessage()

void sendRealTimeMessage ( RealTimeMessage  msg,
Send &&  send 
)

Send a MIDI Real-Time message using the given sender.

Definition at line 92 of file USBMIDI_Sender.hpp.

◆ sendSysEx()

void sendSysEx ( SysExMessage  msg,
Send &&  send 
)

Send a MIDI System Exclusive message using the given sender.

Message may be chunked, remaining bytes are stored until next chunk is sent.

Definition at line 145 of file USBMIDI_Sender.hpp.

◆ sendSysExStartCont1()

void sendSysExStartCont1 ( const uint8_t *  data,
Cable  cable,
Send &  send 
)
private

Send a single SysEx starts or continues USB packet.

Exactly 3 bytes are sent. The data pointer is not incremented.

Definition at line 118 of file USBMIDI_Sender.hpp.

◆ sendSysExStartCont()

void sendSysExStartCont ( const uint8_t *&  data,
uint16_t &  length,
Cable  cable,
Send &  send 
)
private

Send as many SysEx starts or continues USB packets, such that the remaining length is 3, 2 or 1 byte.

The data pointer is incremented, and the length is decremented. The reason for leaving 3, 2 or 1 bytes remaining is so the message can be finished using a SysExEnd USB packet, which has to have 3, 2 or 1 bytes.

Definition at line 124 of file USBMIDI_Sender.hpp.

◆ sendSysExEnd()

void sendSysExEnd ( const uint8_t *  data,
uint16_t  length,
Cable  cable,
Send &  send 
)
private

Send a SysExEnd USB packet.

The length should be either 3, 2 or 1 bytes, and the last byte of data should be a SysExEnd byte.

Definition at line 134 of file USBMIDI_Sender.hpp.

Member Data Documentation

◆ storedSysExData

uint8_t storedSysExData[16][3]
private

Stores remainder of outgoing SysEx chunks.

Each USB packet (except the last one) should contain a multiple of 3 SysEx bytes. If the SysEx chunk size is not a multiple of 3, there will be remaining bytes that can't be sent yet, until the next chunk arrives. See the comments in the USBMIDI_Sender::sendSysEx() implementation for more details.

Definition at line 59 of file USBMIDI_Sender.hpp.

◆ storedSysExLength

uint8_t storedSysExLength[16] = {}
private

Number of remaining SysEx bytes stored.

Definition at line 61 of file USBMIDI_Sender.hpp.


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