Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
DebugMIDI_Interface.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "MIDI_Interface.hpp"
8#include <Settings/SettingsWrapper.hpp>
9
11
16 protected:
19 void sendSysExImpl(Print &, SysExMessage);
20 void sendRealTimeImpl(Print &, RealTimeMessage);
21 void sendNowImpl(Print &) {}
22
23 public:
25
27 void setPrefix(const char *prefix) { this->prefix = prefix; }
28 const char *getPrefix() const { return prefix; }
29
30 private:
31 const char *prefix = nullptr;
32};
33
41 public MIDI_Sender<StreamDebugMIDI_Output>,
42 public TrueMIDI_Sink {
43 public:
44 StreamDebugMIDI_Output(Print &stream, const char *prefix = nullptr)
46
47 Print &getStream() const { return stream; }
48
49 protected:
54 void sendNowImpl();
55
56#if !DISABLE_PIPES
57 void sinkMIDIfromPipe(ChannelMessage m) override { send(m); }
58 void sinkMIDIfromPipe(SysExMessage m) override { send(m); }
61#endif
62
63 Print &stream;
64
66};
67
68class MIDIOutputOnly : public AH::UpdatableCRTP<MIDIOutputOnly> {
69 public:
70 virtual ~MIDIOutputOnly() = default;
71 virtual void begin() = 0;
73};
74
85template <typename T>
88 public:
101 const char *prefix = nullptr)
105 : SerialDebugMIDI_Output(serial, AH::defaultBaudRate, prefix) {}
106
110 void begin() override { static_cast<T &>(getStream()).begin(baud); }
111
112 private:
113 const unsigned long baud;
114};
115
144
154class USBDebugMIDI_Output : public SerialDebugMIDI_Output<decltype(Serial)> {
155 public:
165 const char *prefix = nullptr)
170};
171
179 public MIDI_Interface {
180 public:
189 StreamDebugMIDI_Interface(Stream &stream, const char *prefix = nullptr)
191
193
198
213
214 void update() override;
215
216 protected:
217 // MIDI send implementations
219 void sendSysCommonImpl(SysCommonMessage) override;
220 void sendSysExImpl(SysExMessage) override;
221 void sendRealTimeImpl(RealTimeMessage) override;
222 void sendNowImpl() override;
223
224 private:
225#if !DISABLE_PIPES
226 void handleStall() override { MIDI_Interface::handleStall(this); }
227#ifdef DEBUG_OUT
228 const char *getName() const override { return "dbg"; }
229#endif
230#endif
231
232 private:
235};
236
247template <typename T>
249 public:
262 unsigned long baud = AH::defaultBaudRate,
263 const char *prefix = nullptr)
268
272 void begin() override { static_cast<T &>(getStream()).begin(baud); }
273
274 private:
275 const unsigned long baud;
276};
277
307
318 : public SerialDebugMIDI_Interface<decltype(Serial)> {
319 public:
329 const char *prefix = nullptr)
334};
335
MIDIReadEvent
Values returned by the MIDI reading functions.
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A super class for object that have to be updated regularly.
Definition Updatable.hpp:28
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over a HardwareS...
HardwareSerialDebugMIDI_Interface(HardwareSerial &serial, unsigned long baud=AH::defaultBaudRate, const char *prefix=nullptr)
Construct a new Debug MIDI Interface on the given HardwareSerial interface with the given baud rate.
HardwareSerialDebugMIDI_Interface(HardwareSerial &serial, const char *prefix)
A class for debug MIDI outputs sending human-readable MIDI messages over a HardwareSerial port.
HardwareSerialDebugMIDI_Output(HardwareSerial &serial, const char *prefix)
HardwareSerialDebugMIDI_Output(HardwareSerial &serial, unsigned long baud=AH::defaultBaudRate, const char *prefix=nullptr)
Construct a new Debug MIDI Output on the given HardwareSerial interface with the given baud rate.
CharPuller puller
Definition HexPuller.hpp:66
virtual void begin()=0
virtual ~MIDIOutputOnly()=default
An abstract class for MIDI interfaces.
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.
Statically polymorphic template for classes that send MIDI messages.
void send(ChannelMessage message)
Send a MIDI Channel Voice message.
Receives MIDI messages from a MIDI pipe.
A class that implements MIDI debug send functions.
void sendSysCommonImpl(Print &, SysCommonMessage)
PrintDebugMIDI_Base(const char *prefix)
void sendRealTimeImpl(Print &, RealTimeMessage)
const char * getPrefix() const
void setPrefix(const char *prefix)
Set the prefix to be printed before each message.
void sendChannelMessageImpl(Print &, ChannelMessage)
void sendSysExImpl(Print &, SysExMessage)
A wrapper class for debug MIDI interfaces sending and receiving human-readable MIDI messages over a S...
SerialDebugMIDI_Interface(T &serial, unsigned long baud=AH::defaultBaudRate, const char *prefix=nullptr)
Construct a new Debug MIDI Interface on the given Serial interface with the given baud rate.
void begin() override
Start the Serial interface at the predefined baud rate.
SerialDebugMIDI_Interface(T &serial, const char *prefix)
A wrapper class for debug MIDI outputs sending human-readable MIDI messages over a Serial port of cla...
SerialDebugMIDI_Output(T &serial, unsigned long baud=AH::defaultBaudRate, const char *prefix=nullptr)
Construct a new Debug MIDI Output on the given Serial interface with the given baud rate.
void begin() override
Start the Serial interface at the predefined baud rate.
SerialDebugMIDI_Output(T &serial, const char *prefix)
Parser for Serial MIDI streams (and BLE-MIDI).
SysExMessage getSysExMessage() const
Get the latest SysEx message.
A class for MIDI interfaces sending and receiving human-readable MIDI messages over a Stream.
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.
void sendNowImpl() override
Low-level function for sending any buffered outgoing MIDI messages.
SysCommonMessage getSysCommonMessage() const
Return the received system common message.
void sendRealTimeImpl(RealTimeMessage) override
Low-level function for sending a MIDI real-time message.
const char * getName() const override
Get the staller's name for debugging purposes.
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.
SysExMessage getSysExMessage() const
Return the received system exclusive message.
StreamDebugMIDI_Interface(Stream &stream, const char *prefix=nullptr)
Construct a debug MIDI interface on the given Stream.
A class for MIDI outputs sending human-readable MIDI messages over a Stream.
void sinkMIDIfromPipe(SysExMessage m) override
Accept an incoming MIDI System Exclusive message.
void sinkMIDIfromPipe(ChannelMessage m) override
Accept an incoming MIDI Channel message.
StreamDebugMIDI_Output(Print &stream, const char *prefix=nullptr)
void sendSysExImpl(SysExMessage)
void sinkMIDIfromPipe(RealTimeMessage m) override
Accept an incoming MIDI Real-Time message.
void sendSysCommonImpl(SysCommonMessage)
void sendChannelMessageImpl(ChannelMessage)
void sendRealTimeImpl(RealTimeMessage)
void sinkMIDIfromPipe(SysCommonMessage m) override
Accept an incoming MIDI System Common message.
Stream & stream
A class for debug MIDI interfaces sending and receiving human-readable MIDI messages over the USB CDC...
USBDebugMIDI_Interface(const char *prefix)
USBDebugMIDI_Interface(unsigned long baud=AH::defaultBaudRate, const char *prefix=nullptr)
Construct a USBDebugMIDI_Interface with the given baud rate.
A class for debug MIDI outputs sending human-readable MIDI messages over the USB CDC connection.
USBDebugMIDI_Output(const char *prefix)
USBDebugMIDI_Output(unsigned long baud=AH::defaultBaudRate, const char *prefix=nullptr)
Construct a USBDebugMIDI_Output with the given baud rate.
PrintStream library
Definition Array.hpp:10
constexpr unsigned long defaultBaudRate
The default baud rate for debug output.
An array wrapper for easy copying, comparing, and iterating.
Definition Array.hpp:32
virtual void handleStall()=0
Call back that should finish any MIDI messages that are in progress, and un-stall the pipe or MIDI so...