Control Surface  1.1.1
MIDI Control Surface library for Arduino
ProgramChangeSelector.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <Selectors/Selector.hpp>
5 
7 
8 template <setting_t N, class Callback = EmptySelectorCallback>
9 class GenericProgramChangeSelector : public GenericSelector<N, Callback>,
10  public MIDIInputElementPC {
11  public:
13  const Callback &callback,
14  const MIDICNChannel &address)
15  : GenericSelector<N, Callback>{selectable, callback},
17 
18  void begin() override {
21  }
22 
24 
25  bool updateImpl(const ChannelMessageMatcher &midimsg,
26  const MIDICNChannelAddress &target) override {
27  (void)target;
28  uint8_t program = midimsg.data1;
29  if (program < N) {
30  this->set(program);
31  } else {
32  DEBUGFN(F("Warning: Received Program Change to program 0x")
33  << hex << program << dec
34  << F(", which is not smaller than the number of settings (")
35  << N << ')');
36  }
37  return true;
38  }
39 };
40 
49 template <setting_t N>
51  public:
53  const MIDICNChannel &address)
55 };
56 
MIDIInputElement::address
const MIDICNChannelAddress address
Definition: MIDIInputElement.hpp:80
ChannelMessageMatcher::data1
uint8_t data1
Definition: ChannelMessageMatcher.hpp:20
GenericSelector::begin
void begin() override
Initialize this updatable.
Definition: Selector.hpp:73
GenericProgramChangeSelector
Definition: ProgramChangeSelector.hpp:9
GenericProgramChangeSelector::reset
void reset() override
Reset the input element to its initial state.
Definition: ProgramChangeSelector.hpp:23
GenericProgramChangeSelector::updateImpl
bool updateImpl(const ChannelMessageMatcher &midimsg, const MIDICNChannelAddress &target) override
Update the internal state with the new MIDI message.
Definition: ProgramChangeSelector.hpp:25
GenericProgramChangeSelector::GenericProgramChangeSelector
GenericProgramChangeSelector(Selectable< N > &selectable, const Callback &callback, const MIDICNChannel &address)
Definition: ProgramChangeSelector.hpp:12
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
Selectable
Definition: Selectable.hpp:11
MIDIInputElementPC.hpp
ChannelMessageMatcher
Struct for easily matching MIDI messages.
Definition: ChannelMessageMatcher.hpp:10
GenericSelector::callback
Callback callback
Definition: Selector.hpp:140
MIDIInputElement::begin
virtual void begin()
Initialize the input element.
Definition: MIDIInputElement.hpp:30
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
ProgramChangeSelector
Selector that listens for MIDI Program Change events on a given MIDI Channel, and uses the program nu...
Definition: ProgramChangeSelector.hpp:50
GenericSelector
Definition: Selector.hpp:57
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDICNChannelAddress.hpp:82
ProgramChangeSelector::ProgramChangeSelector
ProgramChangeSelector(Selectable< N > &selectable, const MIDICNChannel &address)
Definition: ProgramChangeSelector.hpp:52
MIDICNChannel
A class for saving a MIDI channel and cable number.
Definition: MIDICNChannelAddress.hpp:19
Selector.hpp
GenericSelector::reset
void reset()
Reset the selection to the initial selection.
Definition: Selector.hpp:81
MIDIInputElementPC
Definition: MIDIInputElementPC.hpp:15
GenericSelector::set
void set(setting_t newSetting)
Select the given selection.
Definition: Selector.hpp:89
hex
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
MIDI_Notes::F
constexpr int8_t F
Definition: Notes.hpp:23
DEBUGFN
#define DEBUGFN(x)
Print an expression and its function (function name and line number) to the debug output if debugging...
Definition: Debug.hpp:93
GenericSelector::selectable
Selectable< N > & selectable
Definition: Selector.hpp:137
dec
Print & dec(Print &printer)
Definition: PrintStream.cpp:77
GenericProgramChangeSelector::begin
void begin() override
Initialize the input element.
Definition: ProgramChangeSelector.hpp:18