This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
MIDI Control Surface library for Arduino
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
MCU::Bankable::GenericVU< NumBanks, Callback > Class Template Reference

A class for MIDI input elements that represent Mackie Control Universal VU meters. More...

#include <VU.hpp>

Inheritance diagram for MCU::Bankable::GenericVU< NumBanks, Callback >:
Collaboration diagram for MCU::Bankable::GenericVU< NumBanks, Callback >:

Public Member Functions

 GenericVU (const BankConfig< NumBanks > &config, uint8_t track, const MIDICNChannel &channelCN, unsigned int decayTime, const Callback &callback)
 Construct a new Bankable VU object. More...
 
void begin () override
 Initialize. More...
 
void reset () override
 Reset all values to zero. More...
 
uint8_t getValue () override
 Return the VU meter value as an integer in [0, 12]. More...
 
bool getOverload () override
 Return the overload status. More...
 
void update () override
 Update is called periodically, it decays the meter if the time is right. More...
 
bool updateWith (const ChannelMessageMatcher &midimsg)
 Receive a new MIDI message and update the internal state. More...
 
virtual float getFloatValue ()
 Get the VU meter value as a floating point number. More...
 
uint8_t getMax () const
 Get the maximum value that this VU meter can return. More...
 
uint8_t getBankIndex (const MIDICNChannelAddress &target, const MIDICNChannelAddress &base) const
 Calculate the bank setting of a given MIDI address, relative to a base address. More...
 

Static Public Member Functions

static void beginAll ()
 
static void resetAll ()
 Reset all MIDIInputElementChannelPressure elements to their initial state. More...
 
static void updateAll ()
 Update all MIDIInputElementChannelPressure elements. More...
 
static void updateAllWith (const ChannelMessageMatcher &midimsg)
 Update all MIDIInputElementChannelPressure elements with a new MIDI message. More...
 

Public Attributes

Callback callback
 

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 MIDICNChannelAddress &toMatch, const MIDICNChannelAddress &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 (MIDICNChannelAddress target, MIDICNChannelAddress base) const
 If matchBankableAddressInRange returned true, get the index of the message in the range. More...
 
bool matchBankableAddressInRange (const MIDICNChannelAddress &toMatch, const MIDICNChannelAddress &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...
 

Protected Attributes

const MIDICNChannelAddress address
 
MIDIInputElementChannelPressurenext
 
MIDIInputElementChannelPressureprevious
 
const uint8_t max
 
BankableMIDIInput< N > * next
 
BankableMIDIInput< N > * previous
 

Private Member Functions

setting_t getSelection () const override
 Get the active bank selection. More...
 
uint8_t getBankIndex (const MIDICNChannelAddress &target) const override
 Get the bank index from a MIDI address. More...
 
bool match (const MIDICNChannelAddress &target) const override
 Check if the address of the incoming MIDI message is in one of the banks of this element. More...
 
void onBankSettingChange () override
 A function to be executed each time the bank setting changes. More...
 
uint8_t getValue (uint8_t index) const
 Get the VU meter value from the raw value. More...
 
bool getOverload (uint8_t index) const
 Get the overload status value from the raw value. More...
 
bool updateImpl (const ChannelMessageMatcher &midimsg, const MIDICNChannelAddress &target) override
 Called when an incoming MIDI message matches this element. More...
 
MIDICNChannelAddress getTarget (const ChannelMessageMatcher &midimsg) const override
 The address of the VU meter is the high nibble of the first (and only) data byte. More...
 
void decay ()
 
void setValue (uint8_t index, uint8_t newValue)
 Set the VU meter value. More...
 
void setOverload (uint8_t index)
 Set the overload status. More...
 
void clearOverload (uint8_t index)
 Clear the overload status. More...
 
void moveDown ()
 Move down this element in the linked list of elements. More...
 

Private Attributes

Array< uint8_t, NumValues > values
 
unsigned int decayTime
 
unsigned long prevDecayTime
 
Bank< N > & bank
 
const BankType type
 

Static Private Attributes

static DoublyLinkedList< MIDIInputElementChannelPressureelements
 

Detailed Description

template<uint8_t NumBanks, class Callback = VUEmptyCallback>
class MCU::Bankable::GenericVU< NumBanks, Callback >

A class for MIDI input elements that represent Mackie Control Universal VU meters.

This version is generic to allow for custom callbacks.
This version can be banked.

Template Parameters
NumBanksThe number of banks.

Definition at line 287 of file VU.hpp.

Constructor & Destructor Documentation

◆ GenericVU()

template<uint8_t NumBanks, class Callback = VUEmptyCallback>
MCU::Bankable::GenericVU< NumBanks, Callback >::GenericVU ( const BankConfig< NumBanks > &  config,
uint8_t  track,
const MIDICNChannel channelCN,
unsigned int  decayTime,
const Callback &  callback 
)
inline

Construct a new Bankable VU object.

Parameters
configThe bank configuration to use.
trackThe track of the VU meter. [1, 8]
channelCNThe MIDI channel [CHANNEL_1, CHANNEL_16] and optional Cable Number [0, 15].
decayTimeThe time in milliseconds it takes for the value to decay one step.
The MCU protocol uses 300 ms per division, and two steps per division, so the default is 150 ms per step.
Some software doesn't work if the VU meter decays automatically, in that case, you can set the decay time to zero to disable the decay.
callbackThe callback object that is update when the value or bank changes.
Used for displaying the value on a range of LEDs etc.

Definition at line 313 of file VU.hpp.

Member Function Documentation

◆ getSelection()

template<uint8_t NumBanks, class Callback = VUEmptyCallback>
setting_t MCU::Bankable::GenericVU< NumBanks, Callback >::getSelection ( ) const
inlineoverrideprivatevirtual

Get the active bank selection.

Reimplemented from MCU::VU_Base< NumBanks, Callback >.

Definition at line 325 of file VU.hpp.

◆ getBankIndex() [1/2]

template<uint8_t NumBanks, class Callback = VUEmptyCallback>
uint8_t MCU::Bankable::GenericVU< NumBanks, Callback >::getBankIndex ( const MIDICNChannelAddress target) const
inlineoverrideprivatevirtual

Get the bank index from a MIDI address.

Reimplemented from MCU::VU_Base< NumBanks, Callback >.

Definition at line 329 of file VU.hpp.

◆ match()

template<uint8_t NumBanks, class Callback = VUEmptyCallback>
bool MCU::Bankable::GenericVU< NumBanks, Callback >::match ( const MIDICNChannelAddress target) const
inlineoverrideprivatevirtual

Check if the address of the incoming MIDI message is in one of the banks of this element.

Reimplemented from MIDIInputElement.

Definition at line 335 of file VU.hpp.

◆ onBankSettingChange()

template<uint8_t NumBanks, class Callback = VUEmptyCallback>
void MCU::Bankable::GenericVU< NumBanks, Callback >::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 340 of file VU.hpp.

◆ begin()

void MCU::VU_Base< NumValues, Callback >::begin ( )
inlineoverridevirtualinherited

Initialize.

Reimplemented from MIDIInputElement.

Definition at line 87 of file VU.hpp.

◆ reset()

void MCU::VU_Base< NumValues, Callback >::reset ( )
inlineoverridevirtualinherited

Reset all values to zero.

Reimplemented from MIDIInputElement.

Definition at line 89 of file VU.hpp.

◆ getValue() [1/2]

uint8_t MCU::VU_Base< NumValues, Callback >::getValue ( )
inlineoverridevirtualinherited

Return the VU meter value as an integer in [0, 12].

Implements IVU.

Definition at line 95 of file VU.hpp.

◆ getValue() [2/2]

uint8_t MCU::VU_Base< NumValues, Callback >::getValue ( uint8_t  index) const
inlineprivateinherited

Get the VU meter value from the raw value.

Definition at line 161 of file VU.hpp.

◆ getOverload() [1/2]

bool MCU::VU_Base< NumValues, Callback >::getOverload ( )
inlineoverridevirtualinherited

Return the overload status.

Implements IVU.

Definition at line 97 of file VU.hpp.

◆ getOverload() [2/2]

bool MCU::VU_Base< NumValues, Callback >::getOverload ( uint8_t  index) const
inlineprivateinherited

Get the overload status value from the raw value.

Definition at line 163 of file VU.hpp.

◆ update()

void MCU::VU_Base< NumValues, Callback >::update ( )
inlineoverridevirtualinherited

Update is called periodically, it decays the meter if the time is right.

Reimplemented from MIDIInputElement.

Definition at line 100 of file VU.hpp.

◆ updateImpl()

bool MCU::VU_Base< NumValues, Callback >::updateImpl ( const ChannelMessageMatcher midimsg,
const MIDICNChannelAddress target 
)
inlineoverrideprivatevirtualinherited

Called when an incoming MIDI message matches this element.

Implements MIDIInputElement.

Definition at line 110 of file VU.hpp.

◆ getTarget()

MIDICNChannelAddress MCU::VU_Base< NumValues, Callback >::getTarget ( const ChannelMessageMatcher midimsg) const
inlineoverrideprivatevirtualinherited

The address of the VU meter is the high nibble of the first (and only) data byte.

Reimplemented from MIDIInputElementChannelPressure.

Definition at line 127 of file VU.hpp.

◆ decay()

void MCU::VU_Base< NumValues, Callback >::decay ( )
inlineprivateinherited

Definition at line 135 of file VU.hpp.

◆ setValue()

void MCU::VU_Base< NumValues, Callback >::setValue ( uint8_t  index,
uint8_t  newValue 
)
inlineprivateinherited

Set the VU meter value.

Definition at line 151 of file VU.hpp.

◆ setOverload()

void MCU::VU_Base< NumValues, Callback >::setOverload ( uint8_t  index)
inlineprivateinherited

Set the overload status.

Definition at line 157 of file VU.hpp.

◆ clearOverload()

void MCU::VU_Base< NumValues, Callback >::clearOverload ( uint8_t  index)
inlineprivateinherited

Clear the overload status.

Definition at line 159 of file VU.hpp.

◆ beginAll()

static void MIDIInputElementChannelPressure::beginAll ( )
inlinestaticinherited

Definition at line 38 of file MIDIInputElementChannelPressure.hpp.

◆ resetAll()

static void MIDIInputElementChannelPressure::resetAll ( )
inlinestaticinherited

Reset all MIDIInputElementChannelPressure elements to their initial state.

See also
MIDIInputElementChannelPressure::reset

Definition at line 50 of file MIDIInputElementChannelPressure.hpp.

◆ updateAll()

static void MIDIInputElementChannelPressure::updateAll ( )
inlinestaticinherited

Update all MIDIInputElementChannelPressure elements.

Definition at line 59 of file MIDIInputElementChannelPressure.hpp.

◆ updateAllWith()

static void MIDIInputElementChannelPressure::updateAllWith ( const ChannelMessageMatcher midimsg)
inlinestaticinherited

Update all MIDIInputElementChannelPressure elements with a new MIDI message.

See also
MIDIInputElementChannelPressure::updateWith

Definition at line 71 of file MIDIInputElementChannelPressure.hpp.

◆ moveDown()

void MIDIInputElementChannelPressure::moveDown ( )
inlineprivateinherited

Move down this element in the linked list of elements.

This means that the element will be checked earlier on the next iteration.

Definition at line 96 of file MIDIInputElementChannelPressure.hpp.

◆ updateWith()

bool MIDIInputElement::updateWith ( const ChannelMessageMatcher midimsg)
inlineinherited

Receive a new MIDI message and update the internal state.

Definition at line 39 of file MIDIInputElement.hpp.

◆ getFloatValue()

virtual float IVU::getFloatValue ( )
inlinevirtualinherited

Get the VU meter value as a floating point number.

Reimplemented in AudioVU.

Definition at line 28 of file VU.hpp.

◆ getMax()

uint8_t IVU::getMax ( ) const
inlineinherited

Get the maximum value that this VU meter can return.

Definition at line 30 of file VU.hpp.

◆ getBankIndex() [2/2]

uint8_t BankableMIDIInput< N >::getBankIndex ( const MIDICNChannelAddress target,
const MIDICNChannelAddress 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 BankableMIDIInput< N >::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 BankableMIDIInput< N >::matchBankable ( const MIDICNChannelAddress toMatch,
const MIDICNChannelAddress 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 175 of file BankableMIDIInput.hpp.

◆ matchBankableInRange()

bool BankableMIDIInput< N >::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()

uint8_t BankableMIDIInput< N >::getRangeIndex ( MIDICNChannelAddress  target,
MIDICNChannelAddress  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 BankableMIDIInput< N >::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 162 of file BankableMIDIInput.hpp.

◆ matchBankableAddressInRange()

bool BankableMIDIInput< N >::matchBankableAddressInRange ( const MIDICNChannelAddress toMatch,
const MIDICNChannelAddress 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 212 of file BankableMIDIInput.hpp.

Member Data Documentation

◆ values

Array<uint8_t, NumValues> MCU::VU_Base< NumValues, Callback >::values
privateinherited

Definition at line 166 of file VU.hpp.

◆ decayTime

unsigned int MCU::VU_Base< NumValues, Callback >::decayTime
privateinherited

Definition at line 167 of file VU.hpp.

◆ prevDecayTime

unsigned long MCU::VU_Base< NumValues, Callback >::prevDecayTime
privateinherited

Definition at line 168 of file VU.hpp.

◆ callback

Callback MCU::VU_Base< NumValues, Callback >::callback
inherited

Definition at line 171 of file VU.hpp.

◆ elements

DoublyLinkedList< MIDIInputElementChannelPressure > MIDIInputElementChannelPressure::elements
staticprivateinherited

Definition at line 101 of file MIDIInputElementChannelPressure.hpp.

◆ address

const MIDICNChannelAddress MIDIInputElement::address
protectedinherited

Definition at line 80 of file MIDIInputElement.hpp.

◆ next [1/2]

Definition at line 301 of file LinkedList.hpp.

◆ previous [1/2]

Definition at line 302 of file LinkedList.hpp.

◆ max

const uint8_t IVU::max
protectedinherited

Definition at line 33 of file VU.hpp.

◆ bank

Bank<N>& BankableMIDIInput< N >::bank
privateinherited

Definition at line 242 of file BankableMIDIInput.hpp.

◆ type

const BankType BankableMIDIInput< N >::type
privateinherited

Definition at line 243 of file BankableMIDIInput.hpp.

◆ next [2/2]

BankableMIDIInput< N > * DoublyLinkable< BankableMIDIInput< N > >::next
protectedinherited

Definition at line 301 of file LinkedList.hpp.

◆ previous [2/2]

BankableMIDIInput< N > * DoublyLinkable< BankableMIDIInput< N > >::previous
protectedinherited

Definition at line 302 of file LinkedList.hpp.


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