Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
NoteCCKPValue.hpp
Go to the documentation of this file.
1#pragma once
2
5
7
8// -------------------------------------------------------------------------- //
9
18template <MIDIMessageType Type>
19class NoteCCKPValue : public MatchingMIDIInputElement<Type, TwoByteMIDIMatcher>,
20 public Interfaces::IValue {
21 public:
23
28
29 protected:
30 bool handleUpdateImpl(typename Matcher::Result match) {
31 bool newdirty = value != match.value;
32 value = match.value;
33 return newdirty;
34 }
35
36 void handleUpdate(typename Matcher::Result match) override {
37 dirty |= handleUpdateImpl(match);
38 }
39
40 public:
43
45 uint8_t getValue() const override { return value; }
46
48
50 void reset() override {
51 value = 0;
52 dirty = true;
53 }
54
55 private:
57};
58
63
68
73
74// -------------------------------------------------------------------------- //
75
76namespace Bankable {
77
89template <MIDIMessageType Type, uint8_t BankSize>
91 Type, BankableTwoByteMIDIMatcher<BankSize>>,
92 public Interfaces::IValue {
93 public:
95
102
103 protected:
104 bool handleUpdateImpl(typename Matcher::Result match) {
105 bool newdirty = values[match.bankIndex] != match.value &&
106 match.bankIndex == this->getActiveBank();
107 // Only mark dirty if the value of the active bank changed
108 values[match.bankIndex] = match.value;
109 return newdirty;
110 }
111
112 void handleUpdate(typename Matcher::Result match) override {
113 dirty |= handleUpdateImpl(match);
114 }
115
116 public:
119
121 uint8_t getValue() const override { return values[this->getActiveBank()]; }
123 uint8_t getValue(uint8_t bank) const { return values[bank]; }
124
126
128 void reset() override {
129 values = {{}};
130 dirty = true;
131 }
132
133 protected:
134 void onBankSettingChange() override { dirty = true; }
135
136 private:
138};
139
143template <uint8_t BankSize>
145
149template <uint8_t BankSize>
151
155template <uint8_t BankSize>
157
158} // namespace Bankable
159
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Similar to MatchingMIDIInputElement, but for Bankable MIDI Input Elements.
Generic base class for classes that listen for MIDI Note, Control Change and Key Pressure events on a...
void onBankSettingChange() override
A function to be executed each time the bank setting changes.
bool handleUpdateImpl(typename Matcher::Result match)
AH::Array< uint8_t, BankSize > values
NoteCCKPValue(BankConfig< BankSize > config, MIDIAddress address)
uint8_t getValue() const override
Get the most recent MIDI value that was received for the active bank.
void handleUpdate(typename Matcher::Result match) override
void reset() override
Reset all values to zero.
uint8_t getValue(uint8_t bank) const
Get the most recent MIDI value that was received for the given bank.
Abstract interface for MIDI input elements that receive and store a 7-bit value.
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
The MIDIInputElement base class is very general: you give it a MIDI message, and it calls the updateW...
Generic base class for classes that listen for MIDI Note, Control Change and Key Pressure events on a...
NoteCCKPValue(MIDIAddress address)
bool handleUpdateImpl(typename Matcher::Result match)
uint8_t getValue() const override
Get the most recent MIDI value that was received.
void handleUpdate(typename Matcher::Result match) override
void reset() override
Reset all values to zero.
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
An array wrapper for easy copying, comparing, and iterating.
Definition Array.hpp:32
Matcher for MIDI messages with 2 data bytes, such as Note On/Off, Control Change, Key Pressure.
Matcher for MIDI messages with 2 data bytes, such as Note On/Off, Control Change, Key Pressure (but n...