Control Surface main
MIDI Control Surface library for Arduino
SerialMIDI_Interface.cpp
Go to the documentation of this file.
3
5
6// -------------------------------------------------------------------------- //
7
8// Reading MIDI
9
12}
13
15
17
18// -------------------------------------------------------------------------- //
19
20// Retrieving the received messages
21
24}
25
28}
29
32}
33
35 return parser.getSysExMessage();
36}
37
38// -------------------------------------------------------------------------- //
39
40// Sending MIDI
41
43 stream.write(msg.header);
44 stream.write(msg.data1);
45 if (msg.hasTwoDataBytes())
46 stream.write(msg.data2);
47}
48
50 stream.write(msg.header);
51 if (msg.getNumberOfDataBytes() >= 1)
52 stream.write(msg.data1);
53 if (msg.getNumberOfDataBytes() >= 2)
54 stream.write(msg.data2);
55}
56
58 stream.write(msg.data, msg.length);
59}
60
62 stream.write(msg.message);
63}
64
MIDIReadEvent
Values returned by the MIDI reading functions.
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
static void updateIncoming(MIDIInterface_t *iface)
Read, parse and dispatch incoming MIDI messages on the given interface.
ChannelMessage getChannelMessage() const
Get the latest MIDI channel voice message.
Definition: MIDI_Parser.hpp:19
RealTimeMessage getRealTimeMessage() const
Get the latest MIDI real-time message.
Definition: MIDI_Parser.hpp:25
SysCommonMessage getSysCommonMessage() const
Get the latest MIDI system common message.
Definition: MIDI_Parser.hpp:21
MIDIReadEvent pull(BytePuller &&puller)
Parse one incoming MIDI message.
SysExMessage getSysExMessage() const
Get the latest SysEx message.
ChannelMessage getChannelMessage() const
Return the received channel voice message.
RealTimeMessage getRealTimeMessage() const
Return the received real-time message.
void sendChannelMessageImpl(ChannelMessage) override
Low-level function for sending a MIDI channel voice message.
void handleStall() override
Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI so...
void update() override
Read the MIDI interface and call the callback if a message was received.
SysCommonMessage getSysCommonMessage() const
Return the received system common message.
void sendRealTimeImpl(RealTimeMessage) override
Low-level function for sending a MIDI real-time message.
void sendSysExImpl(SysExMessage) override
Low-level function for sending a system exclusive MIDI message.
void sendSysCommonImpl(SysCommonMessage) override
Low-level function for sending a MIDI system common message.
MIDIReadEvent read()
Try reading and parsing a single incoming MIDI message.
SysExMessage getSysExMessage() const
Return the received system exclusive message.
Helper that pulls bytes out of an Arduino stream.
bool hasTwoDataBytes() const
Check whether this message has one or two data bytes.
uint8_t data2
First MIDI data byte.
uint8_t header
MIDI status byte (message type and channel).
uint8_t data1
First MIDI data byte.
virtual void handleStall()=0
Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI so...
uint8_t getNumberOfDataBytes() const
Get the number of data bytes of this type of System Common message.
const uint8_t * data