Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
Selectors
ProgramChangeSelector.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
MIDI_Inputs/MIDIInputElement.hpp
>
4
#include <
MIDI_Inputs/MIDIInputElementMatchers.hpp
>
5
#include <
Selectors/Selector.hpp
>
6
7
BEGIN_CS_NAMESPACE
8
9
template
<setting_t N,
class
Callback = EmptySelectorCallback>
10
class
GenericProgramChangeSelector
11
:
public
GenericSelector
<N, Callback>,
12
public
MatchingMIDIInputElement
<MIDIMessageType::ProgramChange,
13
OneByteMIDIMatcher> {
14
public
:
15
using
Matcher
=
OneByteMIDIMatcher
;
16
using
Parent
=
17
MatchingMIDIInputElement<MIDIMessageType::ProgramChange, Matcher>
;
18
19
GenericProgramChangeSelector
(
Selectable<N>
&
selectable
,
20
const
Callback &
callback
,
21
MIDIChannelCable
address)
22
:
GenericSelector
<N, Callback> {
selectable
,
callback
},
Parent
(address) {
23
}
24
25
void
begin
()
override
{
GenericSelector<N, Callback>::begin
(); }
26
27
void
reset
()
override
{
GenericSelector<N, Callback>::reset
(); }
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
50
template
<setting_t N>
51
class
ProgramChangeSelector
:
public
GenericProgramChangeSelector
<N> {
52
public
:
53
ProgramChangeSelector
(
Selectable<N>
&
selectable
,
MIDIChannelCable
address)
54
:
GenericProgramChangeSelector
<N> {
selectable
, {}, address} {}
55
};
56
57
END_CS_NAMESPACE
MIDIInputElementMatchers.hpp
MIDIInputElement.hpp
Selector.hpp
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
GenericProgramChangeSelector::GenericProgramChangeSelector
GenericProgramChangeSelector(Selectable< N > &selectable, const Callback &callback, MIDIChannelCable address)
Definition
ProgramChangeSelector.hpp:19
GenericProgramChangeSelector::Parent
MatchingMIDIInputElement< MIDIMessageType::ProgramChange, Matcher > Parent
Definition
ProgramChangeSelector.hpp:16
GenericProgramChangeSelector::begin
void begin() override
Initialize this updatable.
Definition
ProgramChangeSelector.hpp:25
GenericProgramChangeSelector::handleUpdate
void handleUpdate(typename Matcher::Result match) override
Definition
ProgramChangeSelector.hpp:29
GenericProgramChangeSelector::reset
void reset() override
Reset the input element to its initial state.
Definition
ProgramChangeSelector.hpp:27
GenericProgramChangeSelector::Matcher
OneByteMIDIMatcher Matcher
Definition
ProgramChangeSelector.hpp:15
GenericSelector< N, EmptySelectorCallback >::set
void set(setting_t newSetting)
Definition
Selector.hpp:93
GenericSelector< N, EmptySelectorCallback >::callback
EmptySelectorCallback callback
Definition
Selector.hpp:144
GenericSelector< N, EmptySelectorCallback >::selectable
Selectable< N > & selectable
Definition
Selector.hpp:141
GenericSelector::begin
void begin() override
Initialize this updatable.
Definition
Selector.hpp:72
GenericSelector::reset
void reset()
Reset the selection to the initial selection.
Definition
Selector.hpp:80
GenericSelector< N, EmptySelectorCallback >::GenericSelector
GenericSelector(Selectable< N > &selectable, const EmptySelectorCallback &callback)
Definition
Selector.hpp:69
MIDIChannelCable
A class for saving a MIDI channel and cable number.
Definition
MIDIAddress.hpp:24
MatchingMIDIInputElement< MIDIMessageType::ProgramChange, OneByteMIDIMatcher >::MatchingMIDIInputElement
MatchingMIDIInputElement(const OneByteMIDIMatcher &matcher)
Definition
MIDIInputElement.hpp:90
ProgramChangeSelector::ProgramChangeSelector
ProgramChangeSelector(Selectable< N > &selectable, MIDIChannelCable address)
Definition
ProgramChangeSelector.hpp:53
Selectable
Definition
Selectable.hpp:11
DEBUGFN
#define DEBUGFN(x)
Print an expression and its function (function name and line number) to the debug output if debugging...
Definition
Debug.hpp:115
AH::hex
Print & hex(Print &printer)
Definition
PrintStream.cpp:63
AH::dec
Print & dec(Print &printer)
Definition
PrintStream.cpp:78
OneByteMIDIMatcher::Result
Definition
MIDIInputElementMatchers.hpp:18
OneByteMIDIMatcher::Result::value
uint8_t value
Definition
MIDIInputElementMatchers.hpp:20
OneByteMIDIMatcher
Matcher for MIDI messages with 1 data byte, such as Channel Pressure and Program Change.
Definition
MIDIInputElementMatchers.hpp:15
Generated by
1.17.0