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 | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
MCU::Bankable::GenericVPotRing< NumBanks, Callback > Class Template Reference

A class for MIDI input elements that represent Mackie Control Universal V-Pots. More...

#include <VPotRing.hpp>

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

Public Member Functions

 GenericVPotRing (const BankConfig< NumBanks > &config, uint8_t track, const MIDICNChannel &channelCN, const Callback &callback)
 
void begin () override
 Initialize. More...
 
void reset () override
 Reset all values to zero. More...
 
virtual void update ()
 Update the value of the input element. Used for decaying VU meters etc. More...
 
bool updateWith (const ChannelMessageMatcher &midimsg)
 Receive a new MIDI message and update the internal state. More...
 
uint8_t getPosition () const
 Return the position of the V-Pot ring. [0, 11]. More...
 
bool getCenterLed () const
 Return the status of the center LED of the V-Pot ring. More...
 
uint8_t getMode () const
 Return the mode of the V-Pot ring: 0 = single dot, 1 = boost/cut, 2 = wrap, 3 = spread. More...
 
uint8_t getStartOn () const
 Get the first segment that should be on. More...
 
uint8_t getStartOff () const
 Get the first segment that should be off. 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 ()
 Initialize all MIDIInputElementCC elements. More...
 
static void updateAll ()
 Update all MIDIInputElementCC elements. More...
 
static void resetAll ()
 Reset all MIDIInputElementCC elements to their initial state. More...
 
static void updateAllWith (const ChannelMessageMatcher &midimsg)
 Update all MIDIInputElementCC 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 uint8_t sanitizeValue (uint8_t value)
 Make sure that the received value is valid and will not result in array out of bounds conditions. More...
 
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
 
MIDIInputElementCCnext
 
MIDIInputElementCCprevious
 
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...
 
bool updateImpl (const ChannelMessageMatcher &midimsg, const MIDICNChannelAddress &target) override
 Update the internal state with the new MIDI message. More...
 
uint8_t getValue () const override
 
void moveDown ()
 Move down this element in the linked list of elements. More...
 
virtual MIDICNChannelAddress getTarget (const ChannelMessageMatcher &midimsg) const
 Extract the target address from a MIDI message. More...
 

Static Private Member Functions

static uint8_t getPosition (uint8_t value)
 Extract the position from the raw value. More...
 
static bool getCenterLed (uint8_t value)
 Extract the center LED state from the raw value. More...
 
static uint8_t getMode (uint8_t value)
 Extract the mode from the raw value. More...
 

Private Attributes

Array< uint8_t, NumValues > values
 
Bank< N > & bank
 
const BankType type
 

Static Private Attributes

static DoublyLinkedList< MIDIInputElementCCelements
 

Detailed Description

template<uint8_t NumBanks, class Callback = VPotEmptyCallback>
class MCU::Bankable::GenericVPotRing< NumBanks, Callback >

A class for MIDI input elements that represent Mackie Control Universal V-Pots.

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

Template Parameters
NumBanksThe number of banks.

Definition at line 177 of file VPotRing.hpp.

Constructor & Destructor Documentation

◆ GenericVPotRing()

template<uint8_t NumBanks, class Callback = VPotEmptyCallback>
MCU::Bankable::GenericVPotRing< NumBanks, Callback >::GenericVPotRing ( const BankConfig< NumBanks > &  config,
uint8_t  track,
const MIDICNChannel channelCN,
const Callback &  callback 
)
inline

Definition at line 180 of file VPotRing.hpp.

Member Function Documentation

◆ getSelection()

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

Get the active bank selection.

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

Definition at line 186 of file VPotRing.hpp.

◆ getBankIndex() [1/2]

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

Get the bank index from a MIDI address.

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

Definition at line 190 of file VPotRing.hpp.

◆ match()

template<uint8_t NumBanks, class Callback = VPotEmptyCallback>
bool MCU::Bankable::GenericVPotRing< 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 196 of file VPotRing.hpp.

◆ onBankSettingChange()

template<uint8_t NumBanks, class Callback = VPotEmptyCallback>
void MCU::Bankable::GenericVPotRing< 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 201 of file VPotRing.hpp.

◆ begin()

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

Initialize.

Reimplemented from MIDIInputElement.

Definition at line 92 of file VPotRing.hpp.

◆ reset()

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

Reset all values to zero.

Reimplemented from MIDIInputElement.

Definition at line 95 of file VPotRing.hpp.

◆ sanitizeValue()

static uint8_t MCU::VPotRing_Base< NumValues, Callback >::sanitizeValue ( uint8_t  value)
inlinestaticprotectedinherited

Make sure that the received value is valid and will not result in array out of bounds conditions.

Definition at line 105 of file VPotRing.hpp.

◆ updateImpl()

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

Update the internal state with the new MIDI message.

Implements MIDIInputElement.

Definition at line 110 of file VPotRing.hpp.

◆ getValue()

uint8_t MCU::VPotRing_Base< NumValues, Callback >::getValue ( ) const
inlineoverrideprivatevirtualinherited

Implements MCU::IVPotRing.

Definition at line 118 of file VPotRing.hpp.

◆ beginAll()

static void MIDIInputElementCC::beginAll ( )
inlinestaticinherited

Initialize all MIDIInputElementCC elements.

See also
MIDIInputElementCC::begin

Definition at line 50 of file MIDIInputElementCC.hpp.

◆ updateAll()

static void MIDIInputElementCC::updateAll ( )
inlinestaticinherited

Update all MIDIInputElementCC elements.

See also
MIDIInputElementCC::update

Definition at line 58 of file MIDIInputElementCC.hpp.

◆ resetAll()

static void MIDIInputElementCC::resetAll ( )
inlinestaticinherited

Reset all MIDIInputElementCC elements to their initial state.

See also
MIDIInputElementCC::reset

Definition at line 66 of file MIDIInputElementCC.hpp.

◆ updateAllWith()

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

Update all MIDIInputElementCC elements with a new MIDI message.

See also
MIDIInputElementCC::updateWith

Definition at line 74 of file MIDIInputElementCC.hpp.

◆ moveDown()

void MIDIInputElementCC::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 92 of file MIDIInputElementCC.hpp.

◆ update()

virtual void MIDIInputElement::update ( )
inlinevirtualinherited

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

◆ getTarget()

virtual MIDICNChannelAddress MIDIInputElement::getTarget ( const ChannelMessageMatcher midimsg) const
inlineprivatevirtualinherited

Extract the target address from a MIDI message.

Note
This base version of the function is only valid for messages that use data1 as an address (i.e. Note On, Note Off, Polyphonic Key Pressure and Control Change), because it assumes that the target address consists of the address (data 1), the MIDI channel and the cable number.

Reimplemented in MCU::VU_Base< NumValues, Callback >, MCU::VU_Base< NumBanks, Callback >, MCU::VU_Base< NumBanks, VULEDsCallback< NumLEDs > >, MCU::VU_Base< NumBanks, VUEmptyCallback >, MCU::VU_Base< 1, VUEmptyCallback >, MCU::VU_Base< 1, VULEDsCallback< NumLEDs > >, MCU::VU_Base< 1, Callback >, MIDIInputElementChannelPressure, and MIDIInputElementPC.

Definition at line 64 of file MIDIInputElement.hpp.

◆ getPosition() [1/2]

uint8_t MCU::IVPotRing::getPosition ( ) const
inlineinherited

Return the position of the V-Pot ring. [0, 11].

Definition at line 32 of file VPotRing.hpp.

◆ getPosition() [2/2]

static uint8_t MCU::IVPotRing::getPosition ( uint8_t  value)
inlinestaticprivateinherited

Extract the position from the raw value.

Definition at line 72 of file VPotRing.hpp.

◆ getCenterLed() [1/2]

bool MCU::IVPotRing::getCenterLed ( ) const
inlineinherited

Return the status of the center LED of the V-Pot ring.

Definition at line 34 of file VPotRing.hpp.

◆ getCenterLed() [2/2]

static bool MCU::IVPotRing::getCenterLed ( uint8_t  value)
inlinestaticprivateinherited

Extract the center LED state from the raw value.

Definition at line 77 of file VPotRing.hpp.

◆ getMode() [1/2]

uint8_t MCU::IVPotRing::getMode ( ) const
inlineinherited

Return the mode of the V-Pot ring: 0 = single dot, 1 = boost/cut, 2 = wrap, 3 = spread.

Definition at line 37 of file VPotRing.hpp.

◆ getMode() [2/2]

static uint8_t MCU::IVPotRing::getMode ( uint8_t  value)
inlinestaticprivateinherited

Extract the mode from the raw value.

Definition at line 79 of file VPotRing.hpp.

◆ getStartOn()

uint8_t MCU::IVPotRing::getStartOn ( ) const
inlineinherited

Get the first segment that should be on.

Definition at line 40 of file VPotRing.hpp.

◆ getStartOff()

uint8_t MCU::IVPotRing::getStartOff ( ) const
inlineinherited

Get the first segment that should be off.

Definition at line 56 of file VPotRing.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::VPotRing_Base< NumValues, Callback >::values
privateinherited

Definition at line 129 of file VPotRing.hpp.

◆ callback

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

Definition at line 132 of file VPotRing.hpp.

◆ elements

DoublyLinkedList< MIDIInputElementCC > MIDIInputElementCC::elements
staticprivateinherited

Definition at line 97 of file MIDIInputElementCC.hpp.

◆ address

const MIDICNChannelAddress MIDIInputElement::address
protectedinherited

Definition at line 80 of file MIDIInputElement.hpp.

◆ next [1/2]

MIDIInputElementCC * DoublyLinkable< MIDIInputElementCC >::next
protectedinherited

Definition at line 301 of file LinkedList.hpp.

◆ previous [1/2]

MIDIInputElementCC * DoublyLinkable< MIDIInputElementCC >::previous
protectedinherited

Definition at line 302 of file LinkedList.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