Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
SerialMIDI_Interface.cpp
Go to the documentation of this file.
3
4#include "PicoUSBInit.hpp"
5
7
8// -------------------------------------------------------------------------- //
9
10// Reading MIDI
11
17
19
20// -------------------------------------------------------------------------- //
21
22// Retrieving the received messages
23
27
31
35
39
40// -------------------------------------------------------------------------- //
41
42// Sending MIDI
43
45 if (!ensure_usb_init(stream))
46 return;
47 stream.write(msg.header);
48 stream.write(msg.data1);
49 if (msg.hasTwoDataBytes())
50 stream.write(msg.data2);
51}
52
54 if (!ensure_usb_init(stream))
55 return;
56 stream.write(msg.header);
57 if (msg.getNumberOfDataBytes() >= 1)
58 stream.write(msg.data1);
59 if (msg.getNumberOfDataBytes() >= 2)
60 stream.write(msg.data2);
61}
62
64 if (!ensure_usb_init(stream))
65 return;
66 stream.write(msg.data, msg.length);
67}
68
70 if (!ensure_usb_init(stream))
71 return;
72 stream.write(msg.message);
73}
74
MIDIReadEvent
Values returned by the MIDI reading functions.
@ NO_MESSAGE
No new messages were received.
When using the earlephilhower/arduino-pico core with the TinyUSB backend, calling Serial....
#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.
RealTimeMessage getRealTimeMessage() const
Get the latest MIDI real-time message.
SysCommonMessage getSysCommonMessage() const
Get the latest MIDI system common message.
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 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.
uint8_t getNumberOfDataBytes() const
Get the number of data bytes of this type of System Common message.
const uint8_t * data