Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
NoteCCKPRange.hpp
Go to the documentation of this file.
1#pragma once
2
4
6
7// -------------------------------------------------------------------------- //
8
19template <MIDIMessageType Type, uint8_t RangeLen>
21 : public MatchingMIDIInputElement<Type, TwoByteRangeMIDIMatcher> {
22 public:
24
29
30 private:
31 bool handleUpdateImpl(typename Matcher::Result match) {
32 bool newdirty = values[match.index] != match.value;
33 values[match.index] = match.value;
34 return newdirty;
35 }
36
37 void handleUpdate(typename Matcher::Result match) override {
38 dirty |= handleUpdateImpl(match);
39 }
40
41 public:
44
47 uint8_t getValue(uint8_t index) const { return values[index]; }
48
50
52 void reset() override {
53 values = {{}};
54 dirty = true;
55 }
56
59
62 bool getDirty() const { return dirty; }
64 void clearDirty() { dirty = false; }
65
67
68 private:
70 bool dirty = true;
71};
72
76template <uint8_t RangeLen>
78
82template <uint8_t RangeLen>
84
88template <uint8_t RangeLen>
90
91// -------------------------------------------------------------------------- //
92
93namespace Bankable {
94
108template <MIDIMessageType Type, uint8_t BankSize, uint8_t RangeLen>
110 Type, BankableTwoByteRangeMIDIMatcher<BankSize>> {
111 public:
113
121
122 protected:
123 bool handleUpdateImpl(typename Matcher::Result match) {
124 bool newdirty = values[match.bankIndex][match.index] != match.value &&
125 match.bankIndex == this->getActiveBank();
126 // Only mark dirty if the value of the active bank changed
127 values[match.bankIndex][match.index] = match.value;
128 return newdirty;
129 }
130
131 void handleUpdate(typename Matcher::Result match) override {
132 dirty |= handleUpdateImpl(match);
133 }
134
135 public:
138
140 uint8_t getValue(uint8_t index) const {
141 return values[this->getActiveBank()][index];
142 }
144 uint8_t getValue(uint8_t bank, uint8_t index) const {
145 return values[bank][index];
146 }
147
149
151 void reset() override {
152 values = {{{}}};
153 dirty = true;
154 }
155
158
161 bool getDirty() const { return dirty; }
163 void clearDirty() { dirty = false; }
164
166
167 protected:
168 void onBankSettingChange() override { dirty = true; }
169
170 private:
172
173 protected:
174 bool dirty = true;
175};
176
180template <uint8_t BankSize, uint8_t RangeLen>
182
187template <uint8_t BankSize, uint8_t RangeLen>
188using CCRange =
190
194template <uint8_t BankSize, uint8_t RangeLen>
196
197} // namespace Bankable
198
#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...
uint8_t getValue(uint8_t bank, uint8_t index) const
Get the most recent MIDI value that was received for the given bank.
uint8_t getValue(uint8_t index) const
Get the most recent MIDI value that was received for the active bank.
bool getDirty() const
Check if the value was updated since the last time the dirty flag was cleared.
void onBankSettingChange() override
A function to be executed each time the bank setting changes.
AH::Array2D< uint8_t, BankSize, RangeLen > values
bool handleUpdateImpl(typename Matcher::Result match)
void handleUpdate(typename Matcher::Result match) override
NoteCCKPRange(BankConfig< BankSize > config, MIDIAddress address)
void reset() override
Reset all values to zero.
void clearDirty()
Clear the dirty flag.
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...
uint8_t getValue(uint8_t index) const
Get the most recent MIDI value that was received for the given index in the range.
NoteCCKPRange(MIDIAddress address)
bool getDirty() const
Check if the value was updated since the last time the dirty flag was cleared.
bool handleUpdateImpl(typename Matcher::Result match)
void handleUpdate(typename Matcher::Result match) override
void reset() override
Reset all values to zero.
void clearDirty()
Clear the dirty flag.
AH::Array< uint8_t, RangeLen > values
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...