Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
DebugMIDI_Interface.cpp
Go to the documentation of this file.
3
4#include "PicoUSBInit.hpp"
5
7
9
10#ifdef PROGMEM
11
12const static char NoteOff[] PROGMEM = "Note Off ";
13const static char NoteOn[] PROGMEM = "Note On ";
14const static char KeyPressure[] PROGMEM = "Key Pressure ";
15const static char ControlChange[] PROGMEM = "Control Change ";
16const static char ProgramChange[] PROGMEM = "Program Change ";
17const static char ChannelPressure[] PROGMEM = "Channel Pressure ";
18const static char PitchBend[] PROGMEM = "Pitch Bend ";
19
21 reinterpret_cast<FlashString_t>(NoteOff),
22 reinterpret_cast<FlashString_t>(NoteOn),
23 reinterpret_cast<FlashString_t>(KeyPressure),
24 reinterpret_cast<FlashString_t>(ControlChange),
25 reinterpret_cast<FlashString_t>(ProgramChange),
26 reinterpret_cast<FlashString_t>(ChannelPressure),
27 reinterpret_cast<FlashString_t>(PitchBend),
28};
29
30#else
31
32const static char *MIDIStatusTypeNames[] = {
33 "Note Off ", "Note On ", "Key Pressure ",
34 "Control Change ", "Program Change ", "Channel Pressure ",
35 "Pitch Bend ",
36};
37
38#endif
39
40} // namespace DebugMIDIMessageNames
41
47
51
53 ChannelMessage msg) {
54 if (!ensure_usb_init(stream))
55 return;
56 uint8_t messageType = (msg.header >> 4) - 8;
57 if (messageType >= 7)
58 return;
59
61 if (prefix != nullptr)
62 stream << prefix << ' ';
63 if (msg.hasTwoDataBytes())
65 << F("Channel: ") << msg.getChannel().getOneBased()
66 << F("\tData 1: 0x") << hex << msg.getData1()
67 << F("\tData 2: 0x") << msg.getData2() << dec;
68 else
70 << F("Channel: ") << msg.getChannel().getOneBased()
71 << F("\tData 1: 0x") << hex << msg.getData1() << dec;
72 if (msg.getMessageType() == msg.PitchBend)
73 stream << " (" << msg.getData14bit() << ')';
74 if (msg.getCable() != Cable_1)
75 stream << F("\tCable: ") << msg.getCable().getOneBased();
76 stream << "\r\n";
77}
78
80 if (!ensure_usb_init(stream))
81 return;
83 if (prefix != nullptr)
84 stream << prefix << ' ';
85 stream << F("System Exclusive [") << msg.length
86 << (msg.isLastChunk() ? "]\t" : "+]\t")
87 << AH::HexDump(msg.data, msg.length);
88 if (msg.getCable() != Cable_1)
89 stream << F("\tCable: ") << msg.getCable().getOneBased();
90 stream << "\r\n";
91}
92
94 SysCommonMessage msg) {
95 if (!ensure_usb_init(stream))
96 return;
98 if (prefix != nullptr)
99 stream << prefix << ' ';
100 stream << F("System Common ") << msg.getMessageType() << hex;
101 if (msg.getNumberOfDataBytes() >= 1)
102 stream << F("\tData 1: 0x") << msg.getData1();
103 if (msg.getNumberOfDataBytes() >= 2)
104 stream << F("\tData 2: 0x") << msg.getData2() << dec << " ("
105 << msg.getData14bit() << ')';
106 else
107 stream << dec;
108 if (msg.getCable() != Cable_1)
109 stream << F("\tCable: ") << msg.getCable().getOneBased();
110 stream << "\r\n";
111}
112
114 if (!ensure_usb_init(stream))
115 return;
117 if (prefix != nullptr)
118 stream << prefix << ' ';
119 stream << F("Real-Time ") << msg.getMessageType();
120 if (msg.getCable() != Cable_1)
121 stream << F("\tCable: ") << msg.getCable().getOneBased();
122 stream << "\r\n";
123}
124
140
156
std::remove_reference< decltype(*F(""))>::type * FlashString_t
constexpr Cable Cable_1
Definition Cable.hpp:118
#define DEBUG_LOCK_MUTEX
Definition Debug.hpp:81
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
constexpr uint8_t getOneBased() const
Get the cable as an integer.
Definition Cable.hpp:36
constexpr uint8_t getOneBased() const
Get the channel as an integer.
Definition Channel.hpp:36
static void updateIncoming(MIDIInterface_t *iface)
Read, parse and dispatch incoming MIDI messages on the given interface.
void sendSysCommonImpl(Print &, SysCommonMessage)
void sendRealTimeImpl(Print &, RealTimeMessage)
void sendChannelMessageImpl(Print &, ChannelMessage)
void sendSysExImpl(Print &, SysExMessage)
MIDIReadEvent pull(BytePuller &&puller)
Parse one incoming MIDI 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.
void sendNowImpl() override
Low-level function for sending any buffered outgoing MIDI messages.
void sendRealTimeImpl(RealTimeMessage) override
Low-level function for sending a MIDI real-time message.
HexPuller< StreamPuller > hexstream
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.
void sendSysExImpl(SysExMessage)
void sendSysCommonImpl(SysCommonMessage)
void sendChannelMessageImpl(ChannelMessage)
void sendRealTimeImpl(RealTimeMessage)
static const char ChannelPressure[]
static const char KeyPressure[]
static const FlashString_t MIDIStatusTypeNames[]
static const char NoteOff[]
static const char ProgramChange[]
static const char PitchBend[]
static const char NoteOn[]
static const char ControlChange[]
MIDIMessageType getMessageType() const
Get the MIDI message type.
Channel getChannel() const
Get the MIDI channel of the message.
bool hasTwoDataBytes() const
Check whether this message has one or two data bytes.
static constexpr auto PitchBend
uint8_t header
MIDI status byte (message type and channel).
Cable getCable() const
Get the MIDI USB cable number of the message.
uint8_t getData1() const
Get the first data byte.
uint16_t getData14bit() const
If Data 1 and Data 2 represent a single 14-bit number, you can use this method to retrieve that numbe...
uint8_t getData2() const
Get the second data byte.
Cable getCable() const
Get the MIDI USB cable number of the message.
MIDIMessageType getMessageType() const
Get the MIDI message type.
uint8_t getNumberOfDataBytes() const
Get the number of data bytes of this type of System Common message.
MIDIMessageType getMessageType() const
Get the MIDI message type.
const uint8_t * data
Cable getCable() const
Get the MIDI USB cable number of the message.
bool isLastChunk() const