Control Surface master
MIDI Control Surface library for Arduino
DebugMIDI_Interface.cpp
Go to the documentation of this file.
3
5
7
8#ifdef PROGMEM
9
10const static char NoteOff[] PROGMEM = "Note Off ";
11const static char NoteOn[] PROGMEM = "Note On ";
12const static char KeyPressure[] PROGMEM = "Key Pressure ";
13const static char ControlChange[] PROGMEM = "Control Change ";
14const static char ProgramChange[] PROGMEM = "Program Change ";
15const static char ChannelPressure[] PROGMEM = "Channel Pressure ";
16const static char PitchBend[] PROGMEM = "Pitch Bend ";
17
19 reinterpret_cast<FlashString_t>(NoteOff),
20 reinterpret_cast<FlashString_t>(NoteOn),
21 reinterpret_cast<FlashString_t>(KeyPressure),
22 reinterpret_cast<FlashString_t>(ControlChange),
23 reinterpret_cast<FlashString_t>(ProgramChange),
24 reinterpret_cast<FlashString_t>(ChannelPressure),
25 reinterpret_cast<FlashString_t>(PitchBend),
26};
27
28#else
29
30const static char *MIDIStatusTypeNames[] = {
31 "Note Off ", "Note On ", "Key Pressure ",
32 "Control Change ", "Program Change ", "Channel Pressure ",
33 "Pitch Bend ",
34};
35
36#endif
37
38} // namespace DebugMIDIMessageNames
39
41 return parser.pull(hexstream);
42}
43
46}
47
50}
51
53 ChannelMessage msg) {
54 uint8_t messageType = (msg.header >> 4) - 8;
55 if (messageType >= 7)
56 return;
57
59 if (prefix != nullptr)
60 stream << prefix << ' ';
61 if (msg.hasTwoDataBytes())
63 << F("Channel: ") << msg.getChannel().getOneBased()
64 << F("\tData 1: 0x") << hex << msg.getData1()
65 << F("\tData 2: 0x") << msg.getData2() << dec;
66 else
68 << F("Channel: ") << msg.getChannel().getOneBased()
69 << F("\tData 1: 0x") << hex << msg.getData1() << dec;
70 if (msg.getMessageType() == msg.PITCH_BEND)
71 stream << " (" << msg.getData14bit() << ')';
72 if (msg.getCable() != CABLE_1)
73 stream << F("\tCable: ") << msg.getCable().getOneBased();
74 stream << "\r\n";
75}
76
79 if (prefix != nullptr)
80 stream << prefix << ' ';
81 stream << F("System Exclusive [") << msg.length
82 << (msg.isLastChunk() ? "]\t" : "+]\t")
83 << AH::HexDump(msg.data, msg.length);
84 if (msg.getCable() != CABLE_1)
85 stream << F("\tCable: ") << msg.getCable().getOneBased();
86 stream << "\r\n";
87}
88
90 SysCommonMessage msg) {
92 if (prefix != nullptr)
93 stream << prefix << ' ';
94 stream << F("System Common ") << msg.getMessageType() << hex;
95 if (msg.getNumberOfDataBytes() >= 1)
96 stream << F("\tData 1: 0x") << msg.getData1();
97 if (msg.getNumberOfDataBytes() >= 2)
98 stream << F("\tData 2: 0x") << msg.getData2() << dec << " ("
99 << msg.getData14bit() << ')';
100 else
101 stream << dec;
102 if (msg.getCable() != CABLE_1)
103 stream << F("\tCable: ") << msg.getCable().getOneBased();
104 stream << "\r\n";
105}
106
108 RealTimeMessage msg) {
110 if (prefix != nullptr)
111 stream << prefix << ' ';
112 stream << F("Real-Time ") << msg.getMessageType();
113 if (msg.getCable() != CABLE_1)
114 stream << F("\tCable: ") << msg.getCable().getOneBased();
115 stream << "\r\n";
116}
117
120}
123}
126}
129}
132}
133
136}
139}
142}
145}
148}
149
std::remove_reference< decltype(*F(""))>::type * FlashString_t
constexpr Cable CABLE_1
Definition: Cable.hpp:118
#define DEBUG_LOCK_MUTEX
Definition: Debug.hpp:84
MIDIReadEvent
Values returned by the MIDI reading functions.
#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.
MIDIReadEvent pull(BytePuller &&puller)
Parse one incoming MIDI message.
void sendRealTimeImpl(Stream &, RealTimeMessage)
void sendChannelMessageImpl(Stream &, ChannelMessage)
void sendSysExImpl(Stream &, SysExMessage)
void sendSysCommonImpl(Stream &, SysCommonMessage)
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.
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)
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
Print & dec(Print &printer)
Definition: PrintStream.cpp:77
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.
constexpr static auto PITCH_BEND
Channel getChannel() const
Get the MIDI channel of the message.
bool hasTwoDataBytes() const
Check whether this message has one or two data bytes.
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.
virtual void handleStall()=0
Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI so...
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