#pragma once #include "InterfaceMIDIInputElements.hpp" #include "MIDIInputElementMatchers.hpp" BEGIN_CS_NAMESPACE template class NoteCCKPValue : public MatchingMIDIInputElement, public Interfaces::IValue { public: using Matcher = TwoByteMIDIMatcher; NoteCCKPValue(MIDIAddress address) : MatchingMIDIInputElement(address) {} protected: bool handleUpdateImpl(typename Matcher::Result match) { bool newdirty = value != match.value; value = match.value; return newdirty; } void handleUpdate(typename Matcher::Result match) override { dirty |= handleUpdateImpl(match); } public: uint8_t getValue() const override { return value; } void reset() override { value = 0; dirty = true; } private: uint8_t value = 0; }; using NoteValue = NoteCCKPValue; using CCValue = NoteCCKPValue; using KPValue = NoteCCKPValue; namespace Bankable { template class NoteCCKPValue : public BankableMatchingMIDIInputElement< Type, BankableTwoByteMIDIMatcher>, public Interfaces::IValue { public: using Matcher = BankableTwoByteMIDIMatcher; NoteCCKPValue(BankConfig config, MIDIAddress address) : BankableMatchingMIDIInputElement({config, address}) {} protected: bool handleUpdateImpl(typename Matcher::Result match) { bool newdirty = values[match.bankIndex] != match.value && match.bankIndex == this->getActiveBank(); values[match.bankIndex] = match.value; return newdirty; } void handleUpdate(typename Matcher::Result match) override { dirty |= handleUpdateImpl(match); } public: uint8_t getValue() const override { return values[this->getActiveBank()]; } uint8_t getValue(uint8_t bank) const { return values[bank]; } void reset() override { values = {{}}; dirty = true; } protected: void onBankSettingChange() override { dirty = true; } private: AH::Array values = {{}}; }; template using NoteValue = NoteCCKPValue; template using CCValue = NoteCCKPValue; template using KPValue = NoteCCKPValue; } // namespace Bankable END_CS_NAMESPACE