Control Surface new-input MIDI Control Surface library for Arduino

#include <Def/MIDIAddress.hpp>

## Detailed Description

A type-safe utility class for saving a MIDI address consisting of a 7-bit address, a 4-bit channel, and a 4-bit cable number.

A MIDI address can be marked "invalid". The MIDI sending functions (MIDI_Sender) will never send messages addressed to invalid addresses.

See MIDI Tutorial: MIDI addresses for a tutorial on how to use MIDI addresses.

Examples
Custom-MIDI-Output-Element-Bankable.ino, Custom-MIDI-Output-Element.ino, Custom-MIDI-Sender.ino, Custom-Note-LED-Input-Element-Callback-FastLED.ino, Custom-Note-LED-Input-Element-Callback.ino, MCP23017-RotaryEncoder-Interrupts.ino, MCP23017-RotaryEncoder-No-Interrupts.ino, MIDI-Output.ino, Send-All-MIDI-Messages.ino, and Send-MIDI-Notes.ino.

Definition at line 141 of file MIDIAddress.hpp.

## Constructors

Default constructor, creates an invalid address.

Constructor. More...

Constructor. More...

Constructor. More...

constexpr MIDIAddress (Channel channel, Cable cableNumber=CABLE_1)
Constructor. More...

Constructor. More...

Subtract a relative offset from this address.

Subtract a relative offset.

## Member access

constexpr Channel getChannel () const
Get the channel [CHANNEL_1, CHANNEL_16].

constexpr uint8_t getRawChannel () const
Get the channel as an integer [0, 15].

constexpr Cable getCableNumber () const
Get the cable number [CABLE_1, CABLE_16].

constexpr uint8_t getRawCableNumber () const
Get the cable number as an integer [0, 15].

## Checks

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 address, MIDI channel and MIDI USB cable number are equal. More...

constexpr bool operator!= (MIDIAddress rhs) const
Check for inequality: two addresses are not equal if and only if they are both valid addresses and have a MIDI address, MIDI channel or MIDI USB cable number that differs. More...

constexpr bool isValid () const
Check if the MIDI address is valid.

constexpr operator bool () const
Check if the MIDI address is valid. More...

## Base functions for address pattern matching.

Check if two addresses match (are equal).

Check if an address falls within a range of MIDI addresses, starting with address base, with a given length. More...

## Constructor & Destructor Documentation

inlineconstexpr

Constructor.

Parameters
 address The 7-bit MIDI address. Depending on the message type, this can be the MIDI note number, the number of the MIDI Control Change Controller, etc. Must be a number in the range [0, 127]. channelCN The MIDI Channel and the MIDI USB cable number.

Definition at line 166 of file MIDIAddress.hpp.

 constexpr MIDIAddress ( int address, Channel channel = CHANNEL_1, Cable cableNumber = CABLE_1 )
inlineconstexpr

Constructor.

Parameters
 address The 7-bit MIDI address. Depending on the message type, this can be the MIDI note number, the number of the MIDI Control Change Controller, etc. Must be a number in the range [0, 127]. channel The MIDI Channel. Use the constants CHANNEL_1 through CHANNEL_16. cableNumber The MIDI USB cable number. Use the constants CABLE_1 through CABLE_16.

Definition at line 189 of file MIDIAddress.hpp.

inlineconstexpr

Constructor.

Parameters
 address The 7-bit MIDI address. Depending on the message type, this can be the MIDI note number, the number of the MIDI Control Change Controller, etc. Must be a number in the range [0, 127]. cableNumber The MIDI USB cable number. Use the constants CABLE_1 through CABLE_16.

Definition at line 210 of file MIDIAddress.hpp.

 constexpr MIDIAddress ( Channel channel, Cable cableNumber = CABLE_1 )
inlineconstexpr

Constructor.

Parameters
 channel The MIDI Channel. Use the constants CHANNEL_1 through CHANNEL_16. cableNumber The MIDI USB cable number. Use the constants CABLE_1 through CABLE_16.

Definition at line 228 of file MIDIAddress.hpp.

inlineconstexpr

Constructor.

Parameters
 address The MIDI Channel and the MIDI USB cable number.

Definition at line 242 of file MIDIAddress.hpp.

## ◆ operator==()

 constexpr bool operator== ( MIDIAddress rhs ) const
inlineconstexpr

Check for equality: two addresses are equal if and only if they are both valid addresses and the MIDI address, MIDI channel and MIDI USB cable number are equal.

Note
Invalid addresses are not equal nor inequal.

Definition at line 299 of file MIDIAddress.hpp.

## ◆ operator!=()

 constexpr bool operator!= ( MIDIAddress rhs ) const
inlineconstexpr

Check for inequality: two addresses are not equal if and only if they are both valid addresses and have a MIDI address, MIDI channel or MIDI USB cable number that differs.

Note
Invalid addresses are not equal nor inequal.

Definition at line 310 of file MIDIAddress.hpp.

## ◆ operator bool()

 constexpr operator bool ( ) const
inlineexplicitconstexpr

Check if the MIDI address is valid.

isValid

Definition at line 322 of file MIDIAddress.hpp.

Check if an address falls within a range of MIDI addresses, starting with address base, with a given length.
 true toMatch and base are both valid addresses, the MIDI address is within the given range, and the MIDI Channel and MIDI USB Cable Number of toMatch and base are the same. false Otherwise.