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

MIDI Input Element that listens for MIDI Note messages in a given range, and displays their values using a FastLED LED strip. More...

#include <MIDI_Inputs/LEDs/FastLED.hpp>

+ Inheritance diagram for NoteRangeFastLED< RangeLen, ColorMapper >:
+ Collaboration diagram for NoteRangeFastLED< RangeLen, ColorMapper >:

Public Member Functions

 NoteRangeFastLED (Array< CRGB, RangeLen > &leds, MIDIAddress address, const ColorMapper &colormapper={})
 Construct a new NoteRangeFastLED object. More...
 
 NoteRangeFastLED (CRGB *leds, MIDIAddress address, const ColorMapper &colormapper={})
 Construct a new NoteRangeFastLED object. More...
 
void setBrightness (uint8_t brightness)
 Set the maximum brightness of the LEDs. More...
 
uint8_t getBrightness () const
 Get the maximum brightness of the LEDs. More...
 
void setLEDIndexPermuter (index_permuter_f permuter)
 Change the mapping from the MIDI index to the LED index. More...
 
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...
 
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...
 

Static Public Member Functions

constexpr static uint8_t length ()
 Get the length of the range. More...
 
static void beginAll ()
 Initialize all MIDIInputElementNote elements. More...
 
static void updateAll ()
 Update all MIDIInputElementNote elements. More...
 
static void resetAll ()
 Reset all MIDIInputElementNote elements to their initial state. More...
 
static void updateAllWith (const ChannelMessageMatcher &midimsg)
 Update all MIDIInputElementNote elements with a new MIDI message. More...
 

Public Attributes

NoteCCFastLEDCallback< DefaultColorMappercallback
 Callback that is called when a value in the active bank changes. More...
 

Protected Attributes

const MIDIAddress address
 
MIDIInputElementNotenext
 
MIDIInputElementNoteprevious
 

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 of this element. More...
 
bool updateImpl (const ChannelMessageMatcher &midimsg, const MIDIAddress &target) override
 
virtual uint8_t getSelection () const
 Get the active bank selection. More...
 
virtual setting_t getBankIndex (MIDIAddress target) const
 Get the bank index from a MIDI address. More...
 
virtual uint8_t getRangeIndex (MIDIAddress target) const
 Get the index of the given MIDI address in the range. More...
 
void moveDown ()
 Move down this element in the linked list of elements. More...
 
virtual MIDIAddress getTarget (const ChannelMessageMatcher &midimsg) const
 Extract the target address from a MIDI message. More...
 

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
 

Static Private Attributes

static DoublyLinkedList< MIDIInputElementNoteelements
 

Detailed Description

template<uint8_t RangeLen, class ColorMapper = DefaultColorMapper>
class NoteRangeFastLED< RangeLen, ColorMapper >

MIDI Input Element that listens for MIDI Note messages in a given range, and displays their values using a FastLED LED strip.

This class doesn't actually write to the LEDs directly, it writes to a buffer of CRGB values that is sent to the LEDs by the FastLED library in the user code.

Template Parameters
RangeLenThe length of the range of MIDI note numbers to listen for.
DefaultColorMapperThe color mapper that defines how each MIDI value should be mapped to an RGB color for the LEDs.
Examples
10.Note-FastLED-ColorMapper.ino, and 9.Note-FastLED.ino.

Definition at line 136 of file FastLED.hpp.

Constructor & Destructor Documentation

◆ NoteRangeFastLED() [1/2]

NoteRangeFastLED ( Array< CRGB, RangeLen > &  leds,
MIDIAddress  address,
const ColorMapper &  colormapper = {} 
)
inline

Construct a new NoteRangeFastLED object.

Parameters
ledsA buffer of CRGB colors, used by the FastLED library. This class only writes to the buffer, it's the responsibility of the user to actually output this buffer to the LEDs in the main loop, using the FastLED library.
addressThe first address in the range. The entire range is defined by this address and the RangeLen template parameter.
For example, if address = 10 and RangeLen = 4, the this object will listen to addresses 10, 11, 12, 13.
colormapperOptional initialization for the color mapper.

Definition at line 156 of file FastLED.hpp.

◆ NoteRangeFastLED() [2/2]

NoteRangeFastLED ( CRGB *  leds,
MIDIAddress  address,
const ColorMapper &  colormapper = {} 
)
inline

Construct a new NoteRangeFastLED object.

Parameters
ledsA buffer of CRGB colors, used by the FastLED library. This class only writes to the buffer, it's the responsibility of the user to actually output this buffer to the LEDs in the main loop, using the FastLED library.
addressThe first address in the range. The entire range is defined by this address and the RangeLen template parameter.
For example, if address = 10 and RangeLen = 4, the this object will listen to addresses 10, 11, 12, 13.
colormapperOptional initialization for the color mapper.

Definition at line 180 of file FastLED.hpp.

Member Function Documentation

◆ setBrightness()

void setBrightness ( uint8_t  brightness)
inline

Set the maximum brightness of the LEDs.

Parameters
brightnessThe maximum brightness [0, 255]

Definition at line 189 of file FastLED.hpp.

◆ getBrightness()

uint8_t getBrightness ( ) const
inline

Get the maximum brightness of the LEDs.

Definition at line 193 of file FastLED.hpp.

◆ setLEDIndexPermuter()

void setLEDIndexPermuter ( index_permuter_f  permuter)
inline

Change the mapping from the MIDI index to the LED index.

The MIDI index is derived from the note or controller number.

The function should take the (zer-based) MIDI index value as a parameter, and return the corresponding LED index (zero-based). By default, the LED index is the same as the MIDI index.

Definition at line 195 of file FastLED.hpp.

◆ match()

bool match ( const MIDIAddress target) const
inlineoverrideprivatevirtualinherited

Check if the address of the incoming MIDI message is within the range of addresses of this element.

Reimplemented from MIDIInputElement.

Definition at line 164 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
inlineoverridevirtualinherited

Initialize.

Reimplemented from MIDIInputElement.

Definition at line 85 of file NoteCCRange.hpp.

◆ reset()

void reset
inlineoverridevirtualinherited

Reset all values to zero.

Reimplemented from MIDIInputElement.

Definition at line 87 of file NoteCCRange.hpp.

◆ updateImpl()

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

Implements MIDIInputElement.

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.

◆ getSelection()

virtual uint8_t getSelection
inlineprivatevirtualinherited

Get the active bank selection.

Definition at line 125 of file NoteCCRange.hpp.

◆ getBankIndex()

virtual setting_t getBankIndex ( MIDIAddress  target) const
inlineprivatevirtualinherited

Get the bank index from a MIDI address.

Definition at line 128 of file NoteCCRange.hpp.

◆ getRangeIndex()

virtual uint8_t getRangeIndex ( MIDIAddress  target) const
inlineprivatevirtualinherited

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

Definition at line 135 of file NoteCCRange.hpp.

◆ length() [1/2]

constexpr static uint8_t length
inlinestaticconstexprinherited

Get the length of the range.

Examples
10.Note-FastLED-ColorMapper.ino, and 9.Note-FastLED.ino.

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.

◆ beginAll()

static void beginAll ( )
inlinestaticinherited

Initialize all MIDIInputElementNote elements.

See also
MIDIInputElementNote::begin

Definition at line 49 of file MIDIInputElementNote.hpp.

◆ updateAll()

static void updateAll ( )
inlinestaticinherited

Update all MIDIInputElementNote elements.

See also
MIDIInputElementNote::update

Definition at line 60 of file MIDIInputElementNote.hpp.

◆ resetAll()

static void resetAll ( )
inlinestaticinherited

Reset all MIDIInputElementNote elements to their initial state.

See also
MIDIInputElementNote::reset

Definition at line 71 of file MIDIInputElementNote.hpp.

◆ updateAllWith()

static void updateAllWith ( const ChannelMessageMatcher midimsg)
inlinestaticinherited

Update all MIDIInputElementNote elements with a new MIDI message.

See also
MIDIInputElementNote::updateWith

Definition at line 84 of file MIDIInputElementNote.hpp.

◆ moveDown()

void 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 102 of file MIDIInputElementNote.hpp.

◆ update()

virtual void update ( )
inlinevirtualinherited

◆ updateWith()

bool 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 MIDIAddress 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 MIDIInputElementPC, MIDIInputElementChannelPressure, VU_Base< NumValues, Callback >, VU_Base< NumBanks, VULEDsCallback< NumLEDs > >, VU_Base< NumBanks, VUEmptyCallback >, VU_Base< 1, VUEmptyCallback >, and VU_Base< 1, VULEDsCallback< NumLEDs > >.

Definition at line 63 of file MIDIInputElement.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

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

Definition at line 146 of file NoteCCRange.hpp.

◆ elements

DoublyLinkedList< MIDIInputElementNote > elements
staticprivateinherited

Definition at line 107 of file MIDIInputElementNote.hpp.

◆ address

const MIDIAddress address
protectedinherited

Definition at line 83 of file MIDIInputElement.hpp.

◆ next

MIDIInputElementNote * next
protectedinherited

Definition at line 323 of file LinkedList.hpp.

◆ previous

MIDIInputElementNote * previous
protectedinherited

Definition at line 324 of file LinkedList.hpp.

◆ rangeLength

uint8_t rangeLength
privateinherited

Definition at line 27 of file NoteCCRange.hpp.


The documentation for this class was generated from the following file: