Control Surface master
MIDI Control Surface library for Arduino
Private Attributes | List of all members
MIDIAddress Class Reference

#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.

+ Collaboration diagram for MIDIAddress:

Constructors

constexpr MIDIAddress ()
 Default constructor, creates an invalid address. More...
 
constexpr MIDIAddress (int address, MIDIChannelCable channelCN)
 Constructor. More...
 
constexpr MIDIAddress (int address, Channel channel=CHANNEL_1, Cable cableNumber=CABLE_1)
 Constructor. More...
 
constexpr MIDIAddress (int address, Cable cableNumber)
 Constructor. More...
 
constexpr MIDIAddress (Channel channel, Cable cableNumber=CABLE_1)
 Constructor. More...
 
constexpr MIDIAddress (MIDIChannelCable address)
 Constructor. More...
 
constexpr static MIDIAddress invalid ()
 Return an invalid address. More...
 

Adding/subtracting offsets

MIDIAddressoperator+= (RelativeMIDIAddress rhs)
 Add a relative offset to this address. More...
 
MIDIAddressoperator-= (RelativeMIDIAddress rhs)
 Subtract a relative offset from this address. More...
 
MIDIAddress operator+ (RelativeMIDIAddress rhs) const
 Add a relative offset. More...
 
MIDIAddress operator- (RelativeMIDIAddress rhs) const
 Subtract a relative offset. More...
 

Member access

constexpr uint8_t getAddress () const
 Get the address [0, 127]. More...
 
constexpr Channel getChannel () const
 Get the channel [CHANNEL_1, CHANNEL_16]. More...
 
constexpr uint8_t getRawChannel () const
 Get the channel as an integer [0, 15]. More...
 
constexpr Cable getCableNumber () const
 Get the cable number [CABLE_1, CABLE_16]. More...
 
constexpr uint8_t getRawCableNumber () const
 Get the cable number as an integer [0, 15]. More...
 

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. More...
 
constexpr operator bool () const
 Check if the MIDI address is valid. More...
 

Base functions for address pattern matching.

static bool matchSingle (MIDIAddress toMatch, MIDIAddress base)
 Check if two addresses match (are equal). More...
 
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, with a given length. More...
 

Private Attributes

RawMIDIAddress addresses
 

Constructor & Destructor Documentation

◆ MIDIAddress() [1/6]

constexpr MIDIAddress ( )
inlineconstexpr

Default constructor, creates an invalid address.

Definition at line 147 of file MIDIAddress.hpp.

◆ MIDIAddress() [2/6]

constexpr MIDIAddress ( int  address,
MIDIChannelCable  channelCN 
)
inlineconstexpr

Constructor.

Parameters
addressThe 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].
channelCNThe MIDI Channel and the MIDI USB cable number.

Definition at line 166 of file MIDIAddress.hpp.

◆ MIDIAddress() [3/6]

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

Constructor.

Parameters
addressThe 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].
channelThe MIDI Channel.
Use the constants CHANNEL_1 through CHANNEL_16.
cableNumberThe MIDI USB cable number.
Use the constants CABLE_1 through CABLE_16.

Definition at line 189 of file MIDIAddress.hpp.

◆ MIDIAddress() [4/6]

constexpr MIDIAddress ( int  address,
Cable  cableNumber 
)
inlineconstexpr

Constructor.

Parameters
addressThe 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].
cableNumberThe MIDI USB cable number.
Use the constants CABLE_1 through CABLE_16.

Definition at line 210 of file MIDIAddress.hpp.

◆ MIDIAddress() [5/6]

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

Constructor.

Parameters
channelThe MIDI Channel.
Use the constants CHANNEL_1 through CHANNEL_16.
cableNumberThe MIDI USB cable number.
Use the constants CABLE_1 through CABLE_16.

Definition at line 228 of file MIDIAddress.hpp.

◆ MIDIAddress() [6/6]

constexpr MIDIAddress ( MIDIChannelCable  address)
inlineconstexpr

Constructor.

Parameters
addressThe MIDI Channel and the MIDI USB cable number.

Definition at line 242 of file MIDIAddress.hpp.

Member Function Documentation

◆ invalid()

constexpr static MIDIAddress invalid ( )
inlinestaticconstexpr

Return an invalid address.

Examples
One-Pot-Both-PB-and-CC.ino.

Definition at line 246 of file MIDIAddress.hpp.

◆ operator+=()

MIDIAddress & operator+= ( RelativeMIDIAddress  rhs)

Add a relative offset to this address.

Definition at line 13 of file MIDIAddress.cpp.

◆ operator-=()

MIDIAddress & operator-= ( RelativeMIDIAddress  rhs)

Subtract a relative offset from this address.

Definition at line 21 of file MIDIAddress.cpp.

◆ operator+()

MIDIAddress operator+ ( RelativeMIDIAddress  rhs) const

Add a relative offset.

Definition at line 29 of file MIDIAddress.cpp.

◆ operator-()

MIDIAddress operator- ( RelativeMIDIAddress  rhs) const

Subtract a relative offset.

Definition at line 35 of file MIDIAddress.cpp.

◆ getAddress()

constexpr uint8_t getAddress ( ) const
inlineconstexpr

Get the address [0, 127].

Definition at line 273 of file MIDIAddress.hpp.

◆ getChannel()

constexpr Channel getChannel ( ) const
inlineconstexpr

Get the channel [CHANNEL_1, CHANNEL_16].

Definition at line 276 of file MIDIAddress.hpp.

◆ getRawChannel()

constexpr uint8_t getRawChannel ( ) const
inlineconstexpr

Get the channel as an integer [0, 15].

Definition at line 278 of file MIDIAddress.hpp.

◆ getCableNumber()

constexpr Cable getCableNumber ( ) const
inlineconstexpr

Get the cable number [CABLE_1, CABLE_16].

Definition at line 281 of file MIDIAddress.hpp.

◆ getRawCableNumber()

constexpr uint8_t getRawCableNumber ( ) const
inlineconstexpr

Get the cable number as an integer [0, 15].

Definition at line 285 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.

◆ isValid()

constexpr bool isValid ( ) const
inlineconstexpr

Check if the MIDI address is valid.

Definition at line 318 of file MIDIAddress.hpp.

◆ operator bool()

constexpr operator bool ( ) const
inlineexplicitconstexpr

Check if the MIDI address is valid.

See also
isValid

Definition at line 322 of file MIDIAddress.hpp.

◆ matchSingle()

static bool matchSingle ( MIDIAddress  toMatch,
MIDIAddress  base 
)
inlinestatic

Check if two addresses match (are equal).

Definition at line 331 of file MIDIAddress.hpp.

◆ matchAddressInRange()

bool matchAddressInRange ( MIDIAddress  toMatch,
MIDIAddress  base,
uint8_t  length 
)
static

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

Return values
truetoMatch 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.
falseOtherwise.

Definition at line 41 of file MIDIAddress.cpp.

Member Data Documentation

◆ addresses

RawMIDIAddress addresses
private

Definition at line 349 of file MIDIAddress.hpp.


The documentation for this class was generated from the following files: