Control Surface  1.2.0
MIDI Control Surface library for Arduino
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Private Attributes | List of all members
BankableMIDIInput< N > Class Template Reference

A base class for all MIDIInputElements that can be banked. More...

#include <Banks/BankableMIDIInput.hpp>

+ Collaboration diagram for BankableMIDIInput< N >:

Public Member Functions

virtual ~BankableMIDIInput ()
 Destructor: remove element from the bank. 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...
 

Protected Member Functions

 BankableMIDIInput (Bank< N > &bank, BankType type)
 Create a new BankableMIDIInput object, and add it to the bank. More...
 
 BankableMIDIInput (BankConfig< N > config)
 Create a new BankableMIDIInput object, and add it to the bank. More...
 
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 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 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 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

virtual void onBankSettingChange ()
 A function to be executed each time the bank setting changes. More...
 

Private Attributes

Bank< N > & bank
 
const BankType type
 

Detailed Description

template<setting_t N>
class BankableMIDIInput< N >

A base class for all MIDIInputElements that can be banked.

Note
These elements must be updated when the bank setting is changed, so they are added to a linked list of the bank.
Template Parameters
NThe number of banks.

Definition at line 21 of file BankableMIDIInput.hpp.

Constructor & Destructor Documentation

◆ BankableMIDIInput() [1/2]

BankableMIDIInput ( Bank< N > &  bank,
BankType  type 
)
inlineprotected

Create a new BankableMIDIInput object, and add it to the bank.

Parameters
bankThe bank to add this element to.
typeWhat address type to change (address, channel or cable number).

Definition at line 33 of file BankableMIDIInput.hpp.

◆ BankableMIDIInput() [2/2]

BankableMIDIInput ( BankConfig< N >  config)
inlineprotected

Create a new BankableMIDIInput object, and add it to the bank.

Parameters
configThe bank and address type to change.
See also
BankableMIDIInput::BankableMIDIInput(Bank<N> &, BankType)

Definition at line 45 of file BankableMIDIInput.hpp.

◆ ~BankableMIDIInput()

virtual ~BankableMIDIInput ( )
inlinevirtual

Destructor: remove element from the bank.

Definition at line 52 of file BankableMIDIInput.hpp.

Member Function Documentation

◆ getSelection()

setting_t getSelection ( ) const
inline

Get the current bank setting.

See also
Bank<N>::getSelection()

Definition at line 59 of file BankableMIDIInput.hpp.

◆ getBankIndex()

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

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
inlineprotected

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.

◆ matchBankableInRange()

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

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()

uint8_t getRangeIndex ( MIDIAddress  target,
MIDIAddress  base 
) const
inlineprotected

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 
)
inlinestaticprotected

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.

◆ matchBankable() [2/2]

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

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.

◆ matchBankableAddressInRange()

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

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.

◆ onBankSettingChange()

virtual void onBankSettingChange ( )
inlineprivatevirtual

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 in GenericNoteCCRange< MIDIInput_t, RangeLen, NumBanks, Callback >, GenericNoteCCRange< MIDIInputElementCC, RangeLen, BankSize, NoteCCFastLEDCallback< DefaultColorMapper > >, GenericNoteCCRange< MIDIInputElementNote, 1, BankSize, NoteCCLEDPWM< 1 > >, GenericNoteCCRange< MIDIInputElementNote, 1, BankSize, NoteCCFastLEDCallback< DefaultColorMapper > >, GenericNoteCCRange< MIDIInputElementNote, RangeLen, BankSize, NoteCCFastLEDCallback< DefaultColorMapper > >, GenericNoteCCRange< MIDIInputElementCC, 1, BankSize, NoteCCLED< 1 > >, GenericNoteCCRange< MIDIInputElementCC, 1, BankSize, NoteCCFastLEDCallback< DefaultColorMapper > >, GenericNoteCCRange< MIDIInputElementCC, RangeLen, BankSize, NoteCCLEDPWM< RangeLen > >, GenericNoteCCRange< MIDIInputElementNote, RangeLen, BankSize, NoteCCLED< RangeLen > >, GenericNoteCCRange< MIDIInputElementNote, 1, BankSize, NoteCCLEDBarCallback< NumLEDs > >, GenericNoteCCRange< MIDIInputElementCC, 1, BankSize, NoteCCLEDPWM< 1 > >, GenericNoteCCRange< MIDIInputElementNote, RangeLen, BankSize, NoteCCLEDPWM< RangeLen > >, GenericNoteCCRange< MIDIInputElementNote, 1, BankSize, NoteCCLED< 1 > >, GenericNoteCCRange< MIDIInputElementCC, 1, BankSize, NoteCCLEDBarCallback< NumLEDs > >, GenericNoteCCRange< MIDIInputElementCC, RangeLen, BankSize, NoteCCLED< RangeLen > >, GenericVU< NumBanks, Callback >, GenericVU< NumBanks >, GenericVU< NumBanks, VULEDsCallback< NumLEDs > >, GenericVPotRing< NumBanks, Callback >, GenericVPotRing< NumBanks >, and GenericVPotRing< NumBanks, VPotRingLEDsCallback >.

Definition at line 255 of file BankableMIDIInput.hpp.

Member Data Documentation

◆ bank

Bank<N>& bank
private

Definition at line 242 of file BankableMIDIInput.hpp.

◆ type

const BankType type
private

Definition at line 243 of file BankableMIDIInput.hpp.


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