13struct __attribute__((packed)) RawMIDIAddress {
17 uint8_t cableNumber : 4;
33 :
addresses{1, 0, channel.getRaw(), cableNumber.getRaw()} {}
88 constexpr explicit operator bool()
const {
return isValid(); }
98 return base == toMatch;
115 int deltaCableNumber = 0)
118 (uint8_t)deltaAddress,
119 (uint8_t)deltaChannel,
120 (uint8_t)deltaCableNumber,
130 static_assert(((-1) & 0x7F) == 0x7F,
131 "Negative numbers must be two's complement");
195 cableNumber.getRaw(),
215 cableNumber.getRaw(),
233 cableNumber.getRaw(),
322 constexpr explicit operator bool()
const {
return isValid(); }
332 return base == toMatch;
constexpr Channel CHANNEL_1
#define BEGIN_CS_NAMESPACE
A type-safe class for MIDI USB Cable numbers.
A type-safe class for MIDI channels.
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
constexpr bool isValid() const
Check if the MIDI address is valid.
MIDIAddress operator-(RelativeMIDIAddress rhs) const
Subtract a relative offset.
constexpr MIDIAddress(int address, Cable cableNumber)
Constructor.
constexpr uint8_t getRawChannel() const
Get the channel as an integer [0, 15].
static constexpr MIDIAddress invalid()
Return an invalid address.
static bool matchSingle(MIDIAddress toMatch, MIDIAddress base)
Check if two addresses match (are equal).
constexpr uint8_t getAddress() const
Get the address [0, 127].
MIDIAddress & operator-=(RelativeMIDIAddress rhs)
Subtract a relative offset from this address.
MIDIAddress operator+(RelativeMIDIAddress rhs) const
Add a relative offset.
constexpr uint8_t getRawCableNumber() const
Get the cable number as an integer [0, 15].
constexpr MIDIAddress(int address, MIDIChannelCable channelCN)
Constructor.
constexpr Channel getChannel() const
Get the channel [CHANNEL_1, CHANNEL_16].
constexpr MIDIAddress(int address, Channel channel=CHANNEL_1, Cable cableNumber=CABLE_1)
Constructor.
static bool matchAddressInRange(MIDIAddress toMatch, MIDIAddress base, uint8_t length)
Check if an address falls within a range of MIDI addresses, starting with address base,...
constexpr MIDIAddress(MIDIChannelCable address)
Constructor.
MIDIAddress & operator+=(RelativeMIDIAddress rhs)
Add a relative offset to this address.
constexpr bool operator!=(MIDIAddress rhs) const
Check for inequality: two addresses are not equal if and only if they are both valid addresses and ha...
constexpr Cable getCableNumber() const
Get the cable number [CABLE_1, CABLE_16].
constexpr MIDIAddress()
Default constructor, creates an invalid address.
constexpr bool operator==(MIDIAddress rhs) const
Check for equality: two addresses are equal if and only if they are both valid addresses and the MIDI...
constexpr MIDIAddress(Channel channel, Cable cableNumber=CABLE_1)
Constructor.
A class for saving a MIDI channel and cable number.
constexpr bool isValid() const
Check if the MIDI address is valid.
static constexpr MIDIChannelCable invalid()
constexpr uint8_t getRawChannel() const
Get the channel as an integer [0, 15].
constexpr MIDIChannelCable(Channel channel, Cable cableNumber=CABLE_1)
constexpr uint8_t getRawCableNumber() const
Get the cable number as an integer [0, 15].
constexpr bool operator==(MIDIChannelCable rhs) const
Check for equality: two addresses are equal if and only if they are both valid addresses and the MIDI...
constexpr Channel getChannel() const
Get the channel [1, 16].
constexpr MIDIChannelCable()
constexpr bool operator!=(MIDIChannelCable rhs) const
Check for inequality: two addresses are not equal if and only if they are both valid addresses and ha...
constexpr Cable getCableNumber() const
Get the cable number [CABLE_1, CABLE_16].
static bool matchSingle(MIDIChannelCable toMatch, MIDIChannelCable base)
Check if two addresses match (are equal).
A class for saving an offset to a MIDI address.
constexpr bool isValid() const
constexpr RelativeMIDIAddress(int deltaAddress, int deltaChannel=0, int deltaCableNumber=0)
constexpr RelativeMIDIAddress()
RelativeMIDIAddress & operator+=(RelativeMIDIAddress that)
Compound addition.