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;
119 int deltaCableNumber = 0)
122 static_cast<uint8_t>(deltaAddress),
123 static_cast<uint8_t>(deltaChannel),
124 static_cast<uint8_t>(deltaCableNumber),
134 static_assert(((-1) & 0x7F) == 0x7F,
135 "Negative numbers must be two's complement");
173 static_cast<uint8_t>(address),
197 static_cast<uint8_t>(address),
199 cableNumber.getRaw(),
217 static_cast<uint8_t>(address),
219 cableNumber.getRaw(),
237 cableNumber.getRaw(),
328 constexpr explicit operator bool()
const {
return isValid(); }
338 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, Channel channel=Channel_1, Cable cableNumber=Cable_1)
Constructor.
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.
constexpr MIDIChannelCable getChannelCable() const
Get the channel and cable number.
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(Channel channel, 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...
A class for saving a MIDI channel and cable number.
constexpr bool isValid() const
Check if the MIDI address is valid.
constexpr MIDIChannelCable(RawMIDIAddress addresses)
static constexpr MIDIChannelCable invalid()
constexpr uint8_t getRawChannel() const
Get the channel as an integer [0, 15].
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 MIDIChannelCable(Channel channel, Cable cableNumber=Cable_1)
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.