Control Surface pin-t-adl
MIDI Control Surface library for Arduino
PBValue.hpp
Go to the documentation of this file.
1#pragma once
2
5
7
8// -------------------------------------------------------------------------- //
9
13class PBValue : public MatchingMIDIInputElement<MIDIMessageType::PITCH_BEND,
14 PitchBendMIDIMatcher>,
16 public:
18
22
23 protected:
24 void handleUpdate(typename Matcher::Result match) override {
25 dirty |= value != match.value;
26 value = match.value;
27 }
28
29 public:
32
34 uint16_t getValue() const override { return value; }
35
37
39 void reset() override {
40 value = 0;
41 dirty = true;
42 }
43
44 private:
45 uint16_t value = 0;
46};
47
48// -------------------------------------------------------------------------- //
49
50namespace Bankable {
51
58template <uint8_t BankSize>
61 MIDIMessageType::PITCH_BEND, BankablePitchBendMIDIMatcher<BankSize>>,
63 public:
67
73 MIDIChannelCable address)
74 : Parent({config, address}) {}
75
76 protected:
77 void handleUpdate(typename Matcher::Result match) override {
78 dirty |= values[match.bankIndex] != match.value &&
79 match.bankIndex == this->getActiveBank();
80 // Only mark dirty if the value of the active bank changed
81 values[match.bankIndex] = match.value;
82 }
83
84 public:
87
89 uint16_t getValue() const override { return values[this->getActiveBank()]; }
91 uint16_t getValue(uint8_t bank) const { return values[bank]; }
92
94
96 void reset() override {
97 values = {{}};
98 dirty = true;
99 }
100
101 protected:
102 void onBankSettingChange() override { dirty = true; }
103
104 private:
106};
107
108} // namespace Bankable
109
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Similar to MatchingMIDIInputElement, but for Bankable MIDI Input Elements.
Class that listens for MIDI Pitch Bend events on a single address and saves their value.
Definition: PBValue.hpp:62
uint16_t getValue() const override
Get the most recent MIDI value that was received for the active bank.
Definition: PBValue.hpp:89
PBValue(BankConfig< BankSize, BankType::CHANGE_CHANNEL > config, MIDIChannelCable address)
Definition: PBValue.hpp:72
void onBankSettingChange() override
A function to be executed each time the bank setting changes.
Definition: PBValue.hpp:102
uint16_t getValue(uint8_t bank) const
Get the most recent MIDI value that was received for the given bank.
Definition: PBValue.hpp:91
void handleUpdate(typename Matcher::Result match) override
Definition: PBValue.hpp:77
void reset() override
Reset all values to zero.
Definition: PBValue.hpp:96
AH::Array< uint16_t, BankSize > values
Definition: PBValue.hpp:105
Abstract interface for MIDI input elements that receive and store a 14-bit value.
A class for saving a MIDI channel and cable number.
Definition: MIDIAddress.hpp:24
typename std::conditional< Type==MIDIMessageType::SYSEX_START, SysExMessage, ChannelMessage >::type MessageType
The MIDIInputElement base class is very general: you give it a MIDI message, and it calls the updateW...
Class that listens for MIDI Pitch Bend events on a single address and saves their value.
Definition: PBValue.hpp:15
uint16_t getValue() const override
Get the most recent MIDI value that was received.
Definition: PBValue.hpp:34
uint16_t value
Definition: PBValue.hpp:45
PBValue(MIDIChannelCable address)
Definition: PBValue.hpp:21
void handleUpdate(typename Matcher::Result match) override
Definition: PBValue.hpp:24
void reset() override
Reset all values to zero.
Definition: PBValue.hpp:39
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Matcher for MIDI Pitch Bend messages.
Matcher for MIDI Pitch Bend messages. Matches a single address.