Control Surface pin-t-adl
MIDI Control Surface library for Arduino
ProgramChangeSelector.hpp
Go to the documentation of this file.
1#pragma once
2
6
8
9template <setting_t N, class Callback = EmptySelectorCallback>
11 : public GenericSelector<N, Callback>,
12 public MatchingMIDIInputElement<MIDIMessageType::PROGRAM_CHANGE,
13 OneByteMIDIMatcher> {
14 public:
17 Matcher>;
18
20 const Callback &callback,
21 MIDIChannelCable address)
22 : GenericSelector<N, Callback>{selectable, callback},
23 Parent(address) {}
24
26
28
29 void handleUpdate(typename Matcher::Result match) override {
30 uint8_t program = match.value;
31 if (program < N) {
32 this->set(program);
33 } else {
34 DEBUGFN(F("Warning: Received Program Change to program 0x")
35 << hex << program << dec
36 << F(", which is not smaller than the number of settings (")
37 << N << ')');
38 }
39 }
40};
41
50template <setting_t N>
52 public:
54 MIDIChannelCable address)
55 : GenericProgramChangeSelector<N>{selectable, {}, address} {}
56};
57
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
MatchingMIDIInputElement< MIDIMessageType::PROGRAM_CHANGE, Matcher > Parent
GenericProgramChangeSelector(Selectable< N > &selectable, const Callback &callback, MIDIChannelCable address)
void begin() override
Initialize this updatable.
void handleUpdate(typename Matcher::Result match) override
void reset() override
Reset the input element to its initial state.
void set(setting_t newSetting)
Select the given selection.
Definition: Selector.hpp:93
void begin() override
Initialize this updatable.
Definition: Selector.hpp:72
void reset()
Reset the selection to the initial selection.
Definition: Selector.hpp:80
A class for saving a MIDI channel and cable number.
Definition: MIDIAddress.hpp:24
The MIDIInputElement base class is very general: you give it a MIDI message, and it calls the updateW...
Selector that listens for MIDI Program Change events on a given MIDI Channel, and uses the program nu...
ProgramChangeSelector(Selectable< N > &selectable, MIDIChannelCable address)
#define DEBUGFN(x)
Print an expression and its function (function name and line number) to the debug output if debugging...
Definition: Debug.hpp:118
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
Print & dec(Print &printer)
Definition: PrintStream.cpp:77
Matcher for MIDI messages with 1 data byte, such as Channel Pressure and Program Change.