Control Surface  1.2.0
MIDI Control Surface library for Arduino
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
GenericNoteCCRange< MIDIInput_t, RangeLen, NumBanks, Callback > Class Template Reference

#include <MIDI_Inputs/NoteCCRange.hpp>

+ Inheritance diagram for GenericNoteCCRange< MIDIInput_t, RangeLen, NumBanks, Callback >:
+ Collaboration diagram for GenericNoteCCRange< MIDIInput_t, RangeLen, NumBanks, Callback >:

Public Member Functions

 GenericNoteCCRange (BankConfig< NumBanks > config, MIDIAddress address, const Callback &callback)
 
uint8_t getValue (uint8_t index) const final override
 
virtual uint8_t getValue (uint8_t index) const =0
 Get the velocity or controller value for the given index in the range. More...
 
uint8_t getValue () const
 Get the velocity or controller value of the first or only note or controller. More...
 
uint8_t getValue () const
 Get the velocity or controller value of the first or only note or controller. More...
 
void begin () override
 Initialize. More...
 
void reset () override
 Reset all values to zero. More...
 
uint8_t length () const
 Get the length of the range of note/CC addresses. More...
 
setting_t getSelection () const
 Get the current bank setting. More...
 
uint8_t getBankIndex (const MIDIAddress &target, const MIDIAddress &base) const
 Calculate the bank setting of a given MIDI address, relative to a base address. More...
 

Static Public Member Functions

constexpr static uint8_t length ()
 Get the length of the range. More...
 

Public Attributes

NoteCCRangeEmptyCallback callback
 Callback that is called when a value in the active bank changes. More...
 

Protected Member Functions

bool matchBankable (uint8_t toMatch, uint8_t base) const
 Check if the given address is part of the bank relative to the base address. More...
 
bool matchBankable (const MIDIAddress &toMatch, const MIDIAddress &base) const
 Check whether a given address is part of the bank relative to the base address. More...
 
bool matchBankableInRange (uint8_t toMatch, uint8_t base, uint8_t length) const
 Check if the given address is part of the bank relative to the base address. More...
 
uint8_t getRangeIndex (MIDIAddress target, MIDIAddress base) const
 If matchBankableAddressInRange returned true, get the index of the message in the range. More...
 
bool matchBankableAddressInRange (const MIDIAddress &toMatch, const MIDIAddress &base, uint8_t length) const
 Check whether a given address is part of the bank relative to the base address and within a range with a given length. More...
 

Static Protected Member Functions

static bool inRange (uint8_t toMatch, uint8_t base, uint8_t length)
 Check whether a given address is within a range of given length starting from the given base address. More...
 

Private Member Functions

bool match (const MIDIAddress &target) const override
 Check if the address of the incoming MIDI message is within the range of addresses and in one of the banks of this element. More...
 
setting_t getSelection () const override
 
uint8_t getBankIndex (MIDIAddress target) const override
 Get the bank index from a MIDI address. More...
 
uint8_t getRangeIndex (MIDIAddress target) const override
 Get the index of the given MIDI address in the range. More...
 
void onBankSettingChange () override
 A function to be executed each time the bank setting changes. More...
 
bool updateImpl (const ChannelMessageMatcher &midimsg, const MIDIAddress &target) override
 

Static Private Member Functions

static uint8_t getValueFromMIDIMessage (const ChannelMessageMatcher &midimsg)
 Extract the "value" from a MIDI Note or Control Change message. More...
 

Private Attributes

Array< Array< uint8_t, RangeLen >, NumBanks > values
 A 2D array for saving all values of the range, for all banks. More...
 
uint8_t rangeLength
 
Bank< N > & bank
 
const BankType type
 

Detailed Description

template<class MIDIInput_t, uint8_t RangeLen, uint8_t NumBanks, class Callback = NoteCCRangeEmptyCallback>
class Bankable::GenericNoteCCRange< MIDIInput_t, RangeLen, NumBanks, Callback >

Template Parameters
RangeLenThe length of the range.
NumBanksThe size of the bank.

Definition at line 247 of file NoteCCRange.hpp.

Constructor & Destructor Documentation

◆ GenericNoteCCRange()

GenericNoteCCRange ( BankConfig< NumBanks >  config,
MIDIAddress  address,
const Callback &  callback 
)
inline

Definition at line 251 of file NoteCCRange.hpp.

Member Function Documentation

◆ match()

bool match ( const MIDIAddress target) const
inlineoverrideprivate

Check if the address of the incoming MIDI message is within the range of addresses and in one of the banks of this element.

Definition at line 262 of file NoteCCRange.hpp.

◆ getSelection() [1/2]

setting_t getSelection ( ) const
inlineoverrideprivate

Definition at line 267 of file NoteCCRange.hpp.

◆ getBankIndex() [1/2]

uint8_t getBankIndex ( MIDIAddress  target) const
inlineoverrideprivatevirtual

Get the bank index from a MIDI address.

Reimplemented from NoteCCRange< MIDIInput_t, RangeLen, NumBanks, NoteCCRangeEmptyCallback >.

Definition at line 271 of file NoteCCRange.hpp.

◆ getRangeIndex() [1/2]

uint8_t getRangeIndex ( MIDIAddress  target) const
inlineoverrideprivatevirtual

Get the index of the given MIDI address in the range.

Reimplemented from NoteCCRange< MIDIInput_t, RangeLen, NumBanks, NoteCCRangeEmptyCallback >.

Definition at line 275 of file NoteCCRange.hpp.

◆ onBankSettingChange()

void onBankSettingChange ( )
inlineoverrideprivatevirtual

A function to be executed each time the bank setting changes.

Think of an LED that indicates whether a track is muted or not. If this LED is bankable, let's say with 4 tracks per bank, 2 banks, and a base address of 3, then this LED object keeps the state of tracks 3 and 7. When the bank setting is 0, the LED displays the state of track 3, when the bank setting is 1, the LED displays the state of track 7.
To know when to update the LED, this callback is used.

Reimplemented from BankableMIDIInput< NumBanks >.

Definition at line 280 of file NoteCCRange.hpp.

◆ getValue() [1/4]

uint8_t getValue ( uint8_t  index) const
inlinefinaloverridevirtualinherited
Todo:
check index bounds

Implements INoteCCValue.

Definition at line 79 of file NoteCCRange.hpp.

◆ getValue() [2/4]

virtual uint8_t getValue
inherited

Get the velocity or controller value for the given index in the range.

◆ getValue() [3/4]

uint8_t getValue
inlineinherited

Get the velocity or controller value of the first or only note or controller.

Definition at line 82 of file NoteCCRange.hpp.

◆ getValue() [4/4]

uint8_t getValue ( ) const
inlineinherited

Get the velocity or controller value of the first or only note or controller.

Definition at line 24 of file NoteCCRange.hpp.

◆ begin()

void begin ( )
inlineoverrideinherited

Initialize.

Definition at line 85 of file NoteCCRange.hpp.

◆ reset()

void reset ( )
inlineoverrideinherited

Reset all values to zero.

Definition at line 87 of file NoteCCRange.hpp.

◆ updateImpl()

bool updateImpl ( const ChannelMessageMatcher midimsg,
const MIDIAddress target 
)
inlineoverrideprivateinherited

Definition at line 95 of file NoteCCRange.hpp.

◆ getValueFromMIDIMessage()

static uint8_t getValueFromMIDIMessage ( const ChannelMessageMatcher midimsg)
inlinestaticprivateinherited

Extract the "value" from a MIDI Note or Control Change message.

For Note On and Control Change, this is simply the second data byte, for Note Off, it's zero.

Definition at line 120 of file NoteCCRange.hpp.

◆ length() [1/2]

constexpr static uint8_t length ( )
inlinestaticconstexprinherited

Get the length of the range.

Definition at line 148 of file NoteCCRange.hpp.

◆ length() [2/2]

uint8_t length ( ) const
inlineinherited

Get the length of the range of note/CC addresses.

Definition at line 19 of file NoteCCRange.hpp.

◆ getSelection() [2/2]

setting_t getSelection ( ) const
inlineinherited

Get the current bank setting.

See also
Bank<N>::getSelection()

Definition at line 59 of file BankableMIDIInput.hpp.

◆ getBankIndex() [2/2]

uint8_t getBankIndex ( const MIDIAddress target,
const MIDIAddress base 
) const
inlineinherited

Calculate the bank setting of a given MIDI address, relative to a base address.

Parameters
targetThe MIDI address to calculate the bank setting of.
baseThe base address to compare it to (the address of bank setting 0).

Definition at line 71 of file BankableMIDIInput.hpp.

◆ matchBankable() [1/2]

bool matchBankable ( uint8_t  toMatch,
uint8_t  base 
) const
inlineprotectedinherited

Check if the given address is part of the bank relative to the base address.

Consider the following example:
A Bank with 4 tracks per bank (T), 2 bank settings (N), and a base address of 3.

0 1 2 3 4 5 6 7 8 9 10 11 12 ...
F F F T F F F T F F F F F ...

Addresses before the base adddress are not matched (0, 1, 2).
Addresses after N * T are not matched (8, 9, 10, 11, 12).
Addresses with a distance to the base address that is not a multiple of N are not matched (4, 5, 6).

Parameters
toMatchThe address to check.
baseThe base address (the address of bank setting 0).
Note
Equivalent to matchBankableInRange(toMatch, base, 1).

Definition at line 113 of file BankableMIDIInput.hpp.

◆ matchBankable() [2/2]

bool matchBankable ( const MIDIAddress toMatch,
const MIDIAddress base 
) const
inlineprotectedinherited

Check whether a given address is part of the bank relative to the base address.

Parameters
toMatchThe address to check.
baseThe base address (the address of bank setting 0).

Definition at line 174 of file BankableMIDIInput.hpp.

◆ matchBankableInRange()

bool matchBankableInRange ( uint8_t  toMatch,
uint8_t  base,
uint8_t  length 
) const
inlineprotectedinherited

Check if the given address is part of the bank relative to the base address.

Todo:
This is very hard to explain without a specific example ...
Parameters
toMatchThe address to check.
baseThe base address (the address of bank setting 0).
lengthThe length of the range.

Definition at line 132 of file BankableMIDIInput.hpp.

◆ getRangeIndex() [2/2]

uint8_t getRangeIndex ( MIDIAddress  target,
MIDIAddress  base 
) const
inlineprotectedinherited

If matchBankableAddressInRange returned true, get the index of the message in the range.

Definition at line 143 of file BankableMIDIInput.hpp.

◆ inRange()

static bool inRange ( uint8_t  toMatch,
uint8_t  base,
uint8_t  length 
)
inlinestaticprotectedinherited

Check whether a given address is within a range of given length starting from the given base address.

Parameters
toMatchThe address to check
baseThe base address, start of the range.
lengthThe length of the range.

Definition at line 161 of file BankableMIDIInput.hpp.

◆ matchBankableAddressInRange()

bool matchBankableAddressInRange ( const MIDIAddress toMatch,
const MIDIAddress base,
uint8_t  length 
) const
inlineprotectedinherited

Check whether a given address is part of the bank relative to the base address and within a range with a given length.

Parameters
toMatchThe address to check.
baseThe base address (the address of bank setting 0).
lengthThe length of the range.

Definition at line 211 of file BankableMIDIInput.hpp.

Member Data Documentation

◆ values

Array<Array<uint8_t, RangeLen>, NumBanks> values
privateinherited

A 2D array for saving all values of the range, for all banks.

Definition at line 142 of file NoteCCRange.hpp.

◆ callback

NoteCCRangeEmptyCallback callback
inherited

Callback that is called when a value in the active bank changes.

Definition at line 146 of file NoteCCRange.hpp.

◆ rangeLength

uint8_t rangeLength
privateinherited

Definition at line 27 of file NoteCCRange.hpp.

◆ bank

Bank<N>& bank
privateinherited

Definition at line 242 of file BankableMIDIInput.hpp.

◆ type

const BankType type
privateinherited

Definition at line 243 of file BankableMIDIInput.hpp.


The documentation for this class was generated from the following file:
MIDI_Notes::F
constexpr int8_t F
Definition: Notes.hpp:23