5#include <AH/STL/cstddef>
6#include <AH/STL/vector>
7#include <Settings/NamespaceSettings.hpp>
134 return this->header == other.
header && this->data1 == other.
data1 &&
135 this->data2 == other.
data2 && this->cable == other.
cable;
152 header =
static_cast<uint8_t
>(type);
187 return data1 | (uint16_t(
data2) << uint16_t(7));
192 data1 = (data >> 0) & 0x7F;
193 data2 = (data >> 7) & 0x7F;
222 header |=
static_cast<uint8_t
>(type) & 0xF0;
318 template <u
int16_t N>
328 return this->length == other.
length && this->cable == other.
cable &&
329 (this->length == 0 ||
367 return this->message == other.
message && this->cable == other.
cable;
373 message =
static_cast<uint8_t
>(type);
std::remove_reference< decltype(*F(""))>::type * FlashString_t
MIDIMessageType
All possible MIDI status byte values (without channel).
@ UndefinedSysCommon1
Undefined System Common message 0xF4 (1B).
@ Stop
Stop System Real-Time message.
@ KeyPressure
Key Pressure Channel Voice message (3B).
@ TimingClock
Timing Clock System Real-Time message.
@ UndefinedRealTime1
Undefined System Real-Time message 0xF9.
@ NoteOn
Note On Channel Voice message (3B).
@ UndefinedRealTime2
Undefined System Real-Time message 0xFD.
@ ActiveSensing
Active Sensing System Real-Time message.
@ SysExStart
Start of System Exclusive.
@ NoteOff
Note Off Channel Voice message (3B).
@ TuneRequest
Tune Request System Common message (1B).
@ None
Special value that does not correspond to an actual message type.
@ ControlChange
Control Change Channel Voice message (3B).
@ SystemReset
Reset System Real-Time message.
@ MTCQuarterFrame
MIDI Time Code Quarter Frame System Common message (2B).
@ Continue
Continue System Real-Time message.
@ Start
Start System Real-Time message.
@ SongSelect
Song Select System Common message (2B).
@ ChannelPressure
Channel Pressure Channel Voice message (2B).
@ UndefinedSysCommon2
Undefined System Common message 0xF5 (1B).
@ SysExEnd
End of System Exclusive.
@ PitchBend
Pitch Bend Channel Voice message (3B).
@ SongPositionPointer
Song Position Pointer System Common message (3B).
@ ProgramChange
Program Change Channel Voice message (2B).
MIDICodeIndexNumber
MIDI USB Code Index Numbers.
FlashString_t enum_to_string(MIDIMessageType)
Print & operator<<(Print &os, SysExMessage m)
#define BEGIN_CS_NAMESPACE
A type-safe class for MIDI USB Cable numbers.
constexpr uint8_t getOneBased() const
Get the cable as an integer.
A type-safe class for MIDI channels.
constexpr uint8_t getRaw() const
Get the channel as an integer.
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
A class for saving a MIDI channel and cable number.
static constexpr auto NoteOn
void setChannel(Channel channel)
Set the MIDI channel of the message.
MIDIChannelCable getChannelCable() const
Get the MIDI channel and cable number.
void setMessageType(MIDIMessageType type)
Set the MIDI message type.
MIDIAddress getAddress() const
Get the MIDI address of this message, using data1 as the address.
MIDIMessageType getMessageType() const
Get the MIDI message type.
ChannelMessage(const MIDIMessage &msg)
Channel getChannel() const
Get the MIDI channel of the message.
static constexpr auto ProgramChange
ChannelMessage(MIDIMessageType type, Channel channel, uint8_t data1, uint8_t data2=0x00, Cable cable=Cable_1)
Constructor.
static constexpr auto KeyPressure
static constexpr auto NoteOff
bool hasTwoDataBytes() const
Check whether this message has one or two data bytes.
static constexpr auto PitchBend
static constexpr auto ChannelPressure
static constexpr auto ControlChange
void setCable(Cable cable)
Set the MIDI USB cable number of the message.
uint8_t data2
First MIDI data byte.
bool hasValidChannelMessageHeader() const
Check whether the header is a valid header for a channel message.
uint8_t header
MIDI status byte (message type and channel).
void setData1(uint8_t data)
Set the first data byte.
bool operator==(MIDIMessage other) const
Check for equality.
MIDIMessage(MIDIMessageType header, uint8_t data1, uint8_t data2, Cable cable=Cable_1)
Constructor.
void setData2(uint8_t data)
Set the second data byte.
Cable getCable() const
Get the MIDI USB cable number of the message.
void sanitize()
Make sure that the status byte has the most significant bit set and the data bytes have the most sign...
uint8_t getData1() const
Get the first data byte.
uint8_t data1
First MIDI data byte.
void setMessageType(MIDIMessageType type)
Set the MIDI message type.
MIDIMessageType getMessageType() const
Get the MIDI message type.
void setData14bit(uint16_t data)
If Data 1 and Data 2 represent a single 14-bit number, you can use this method to set that number.
Cable cable
USB MIDI cable number;.
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.
bool hasValidSystemCommonHeader() const
Check whether the header is a valid header for a System Common message.
bool operator!=(MIDIMessage other) const
Check for inequality.
MIDIMessage(uint8_t header, uint8_t data1, uint8_t data2, Cable cable=Cable_1)
Constructor.
void setCable(Cable cable)
Set the MIDI USB cable number of the message.
static constexpr auto Start
static constexpr auto UndefinedRealTime1
RealTimeMessage(uint8_t message, Cable cable=Cable_1)
Constructor.
static constexpr auto UndefinedRealTime2
bool isValid() const
Check whether the header is a valid header for a Real-Time message.
bool operator!=(RealTimeMessage other) const
Cable getCable() const
Get the MIDI USB cable number of the message.
static constexpr auto RESET
void setMessageType(MIDIMessageType type)
Set the MIDI message type.
MIDIMessageType getMessageType() const
Get the MIDI message type.
static constexpr auto TimingClock
static constexpr auto Stop
static constexpr auto Continue
RealTimeMessage(MIDIMessageType message, Cable cable=Cable_1)
Constructor.
bool operator==(RealTimeMessage other) const
static constexpr auto ActiveSensing
uint8_t getNumberOfDataBytes() const
Get the number of data bytes of this type of System Common message.
static constexpr auto UndefinedSysCommon1
SysCommonMessage(MIDIMessageType type, uint8_t data1=0x00, uint8_t data2=0x00, Cable cable=Cable_1)
Constructor.
SysCommonMessage(MIDIMessageType type, Cable cable)
Constructor.
static constexpr auto MTCQuarterFrame
SysCommonMessage(const MIDIMessage &msg)
static constexpr auto SongSelect
static constexpr auto UndefinedSysCommon2
MIDIMessageType getMessageType() const
Get the MIDI message type.
static constexpr auto SongPositionPointer
static constexpr auto TuneRequest
SysCommonMessage(MIDIMessageType type, uint8_t data1, Cable cable)
Constructor.
void setCable(Cable cable)
Set the MIDI USB cable number of the message.
SysExMessage()
Constructor.
SysExMessage(const uint8_t(&array)[N], Cable cable=Cable_1)
Constructor.
bool operator!=(SysExMessage other) const
Cable getCable() const
Get the MIDI USB cable number of the message.
bool operator==(SysExMessage other) const
static constexpr auto SysExEnd
SysExMessage(const uint8_t *data, uint16_t length, Cable cable=Cable_1)
Constructor.
bool isCompleteMessage() const
SysExMessage(const std::vector< uint8_t > &vec, Cable cable=Cable_1)
Constructor.
bool isFirstChunk() const
static constexpr auto SysExStart