This is an old version of the documentation. View the latest version here.
Control Surface  1.0.0
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::begin
virtual void begin()
Initialize the input element.
Definition: MIDIInputElement.hpp:30
GenericSelector::selectable
Selectable< N > & selectable
Definition: Selector.hpp:137
GenericProgramChangeSelector
Definition: ProgramChangeSelector.hpp:9
GenericProgramChangeSelector::reset
void reset() override
Reset the input element to its initial state.
Definition: ProgramChangeSelector.hpp:23
GenericProgramChangeSelector::begin
void begin() override
Initialize the input element.
Definition: ProgramChangeSelector.hpp:18
Selectable
Definition: Selectable.hpp:11
MIDIInputElementPC.hpp
ChannelMessageMatcher
Struct for easily matching MIDI messages.
Definition: ChannelMessageMatcher.hpp:10
GenericProgramChangeSelector::GenericProgramChangeSelector
GenericProgramChangeSelector(Selectable< N > &selectable, const Callback &callback, const MIDICNChannel &address)
Definition: ProgramChangeSelector.hpp:12
ProgramChangeSelector
Selector that listens for MIDI Program Change events on a given MIDI Channel, and uses the program nu...
Definition: ProgramChangeSelector.hpp:50
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: NamespaceSettings.hpp:9
GenericSelector::set
void set(setting_t newSetting)
Select the given selection.
Definition: Selector.hpp:89
GenericProgramChangeSelector::updateImpl
bool updateImpl(const ChannelMessageMatcher &midimsg, const MIDICNChannelAddress &target) override
Update the internal state with the new MIDI message.
Definition: ProgramChangeSelector.hpp:25
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
GenericSelector::callback
Callback callback
Definition: Selector.hpp:140
DEBUGFN
#define DEBUGFN(x)
Definition: Debug.hpp:164
MIDICNChannel
A class for saving a MIDI channel and cable number.
Definition: MIDICNChannelAddress.hpp:19
Selector.hpp
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: NamespaceSettings.hpp:10
MIDIInputElementPC
Definition: MIDIInputElementPC.hpp:15
ChannelMessageMatcher::data1
uint8_t data1
Definition: ChannelMessageMatcher.hpp:20
dec
Print & dec(Print &printer)
Definition: PrintStream.cpp:77
hex
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
GenericSelector::begin
void begin() override
Initialize this updatable.
Definition: Selector.hpp:73
ProgramChangeSelector::ProgramChangeSelector
ProgramChangeSelector(Selectable< N > &selectable, const MIDICNChannel &address)
Definition: ProgramChangeSelector.hpp:52
MIDIInputElement::address
const MIDICNChannelAddress address
Definition: MIDIInputElement.hpp:80
GenericSelector::reset
void reset()
Reset the selection to the initial selection.
Definition: Selector.hpp:81
MIDI_Notes::F
constexpr int8_t F
Definition: Notes.hpp:23