Control Surface master
MIDI Control Surface library for Arduino
Functions
BankableMIDIMatcherHelpers Namespace Reference

Functions

bool inRange (uint8_t tgt, 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...
 
template<uint8_t BankSize>
bool matchBankable (uint8_t tgt, uint8_t base, const Bank< BankSize > &bank)
 Check if the given address is part of the bank relative to the base address. More...
 
template<uint8_t BankSize>
bool matchBankableInRange (uint8_t tgt, uint8_t base, const Bank< BankSize > &bank, uint8_t rangeLen)
 
template<uint8_t BankSize>
uint8_t getRangeIndex (uint8_t tgt, uint8_t base, const Bank< BankSize > &bank)
 
template<uint8_t BankSize>
uint8_t getBankIndex (uint8_t tgt, uint8_t base, const Bank< BankSize > &bank)
 
template<uint8_t BankSize>
bool matchBankable (MIDIAddress tgt, MIDIAddress base, BaseBankConfig< BankSize > config)
 Check whether a given address is part of the bank relative to the base address. More...
 
template<uint8_t BankSize>
bool matchBankableInRange (MIDIAddress tgt, MIDIAddress base, BaseBankConfig< BankSize > config, uint8_t length)
 Check whether a given address is part of the bank relative to the base address and within a range with a given length. More...
 
template<uint8_t BankSize>
uint8_t getBankIndex (MIDIAddress target, MIDIAddress base, BaseBankConfig< BankSize > config)
 Calculate the bank setting of a given MIDI address, relative to a base address. More...
 
template<uint8_t BankSize>
uint8_t getRangeIndex (MIDIAddress tgt, MIDIAddress base, BaseBankConfig< BankSize > config)
 Calculate the index in the address range of a given MIDI address, relative to a base address. More...
 

Function Documentation

◆ inRange()

bool inRange ( uint8_t  tgt,
uint8_t  base,
uint8_t  length 
)
inline

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

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

Definition at line 22 of file BankableMIDIMatcherHelpers.hpp.

◆ matchBankable() [1/2]

bool matchBankable ( uint8_t  tgt,
uint8_t  base,
const Bank< BankSize > &  bank 
)

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 ...
☐ ☐ ☐ ☒ ☐ ☐ ☐ ☒ ☐ ☐ ☐ ☐ ☐ ...

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
tgtThe address to check.
baseThe base address (the address of bank setting 0).
bankThe bank to match the address in.
Note
Equivalent to matchBankableInRange(toMatch, base, 1).

Definition at line 54 of file BankableMIDIMatcherHelpers.hpp.

◆ matchBankableInRange() [1/2]

bool matchBankableInRange ( uint8_t  tgt,
uint8_t  base,
const Bank< BankSize > &  bank,
uint8_t  rangeLen 
)

◆ getRangeIndex() [1/2]

uint8_t getRangeIndex ( uint8_t  tgt,
uint8_t  base,
const Bank< BankSize > &  bank 
)

◆ getBankIndex() [1/2]

uint8_t getBankIndex ( uint8_t  tgt,
uint8_t  base,
const Bank< BankSize > &  bank 
)

◆ matchBankable() [2/2]

bool matchBankable ( MIDIAddress  tgt,
MIDIAddress  base,
BaseBankConfig< BankSize >  config 
)

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

Parameters
tgtThe address to check.
baseThe base address (the address of bank setting 0).
configThe bank configuration.

Definition at line 116 of file BankableMIDIMatcherHelpers.hpp.

◆ matchBankableInRange() [2/2]

bool matchBankableInRange ( MIDIAddress  tgt,
MIDIAddress  base,
BaseBankConfig< BankSize >  config,
uint8_t  length 
)

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

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

Definition at line 157 of file BankableMIDIMatcherHelpers.hpp.

◆ getBankIndex() [2/2]

uint8_t getBankIndex ( MIDIAddress  target,
MIDIAddress  base,
BaseBankConfig< BankSize >  config 
)

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).
configThe bank configuration to determine the index.

Definition at line 193 of file BankableMIDIMatcherHelpers.hpp.

◆ getRangeIndex() [2/2]

uint8_t getRangeIndex ( MIDIAddress  tgt,
MIDIAddress  base,
BaseBankConfig< BankSize >  config 
)

Calculate the index in the address range of a given MIDI address, relative to a base address.

Parameters
tgtThe MIDI address to calculate the bank setting of.
baseThe base address to compare it to (beginning of the range for bank setting 0).
configThe bank configuration to determine the index.

Definition at line 222 of file BankableMIDIMatcherHelpers.hpp.