Control Surface
main
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
MIDI_Inputs
PBValue.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
InterfaceMIDIInputElements.hpp
"
4
#include "
MIDIInputElementMatchers.hpp
"
5
6
BEGIN_CS_NAMESPACE
7
8
// -------------------------------------------------------------------------- //
9
13
class
PBValue
:
public
MatchingMIDIInputElement
<MIDIMessageType::PitchBend,
14
PitchBendMIDIMatcher>,
15
public
Interfaces::IValue14
{
16
public
:
17
using
Matcher
=
PitchBendMIDIMatcher
;
18
21
PBValue
(
MIDIChannelCable
address) :
MatchingMIDIInputElement
(address) {}
22
23
protected
:
24
void
handleUpdate
(
typename
Matcher::Result
match)
override
{
25
dirty
|=
value
!= match.
value
;
26
value
= match.
value
;
27
}
28
29
public
:
32
34
uint16_t
getValue
()
const override
{
return
value
; }
35
37
39
void
reset
()
override
{
40
value
= 0;
41
dirty
=
true
;
42
}
43
44
private
:
45
uint16_t
value
= 0;
46
};
47
48
// -------------------------------------------------------------------------- //
49
50
namespace
Bankable
{
51
58
template
<u
int
8_t BankSize>
59
class
PBValue
60
:
public
BankableMatchingMIDIInputElement
<
61
MIDIMessageType::PitchBend, BankablePitchBendMIDIMatcher<BankSize>>,
62
public
Interfaces::IValue14
{
63
public
:
64
constexpr
static
auto
MessageType
=
MIDIMessageType::PitchBend
;
65
using
Matcher
=
BankablePitchBendMIDIMatcher<BankSize>
;
66
using
Parent
=
BankableMatchingMIDIInputElement<MessageType, Matcher>
;
67
72
PBValue
(
BankConfig<BankSize, BankType::ChangeChannel>
config,
73
MIDIChannelCable
address)
74
:
Parent
({config, address}) {}
75
76
protected
:
77
void
handleUpdate
(
typename
Matcher::Result
match)
override
{
78
dirty
|=
values
[match.
bankIndex
] != match.
value
&&
79
match.
bankIndex
== this->
getActiveBank
();
80
// Only mark dirty if the value of the active bank changed
81
values
[match.
bankIndex
] = match.
value
;
82
}
83
84
public
:
87
89
uint16_t
getValue
()
const override
{
return
values
[this->
getActiveBank
()]; }
91
uint16_t
getValue
(uint8_t bank)
const
{
return
values
[bank]; }
92
94
96
void
reset
()
override
{
97
values
= {{}};
98
dirty
=
true
;
99
}
100
101
protected
:
102
void
onBankSettingChange
()
override
{
dirty
=
true
; }
103
104
private
:
105
AH::Array<uint16_t, BankSize>
values
= {{}};
106
};
107
108
}
// namespace Bankable
109
110
END_CS_NAMESPACE
InterfaceMIDIInputElements.hpp
MIDIInputElementMatchers.hpp
MIDIMessageType::PitchBend
@ PitchBend
Pitch Bend Channel Voice message (3B).
Definition
MIDI_MessageTypes.hpp:32
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
BankableMatchingMIDIInputElement< MIDIMessageType::PitchBend, BankablePitchBendMIDIMatcher< BankSize > >::getActiveBank
uint8_t getActiveBank() const
Definition
MIDIInputElement.hpp:126
BankableMatchingMIDIInputElement< MIDIMessageType::PitchBend, BankablePitchBendMIDIMatcher< BankSize > >::BankableMatchingMIDIInputElement
BankableMatchingMIDIInputElement(const BankablePitchBendMIDIMatcher< BankSize > &matcher)
Definition
MIDIInputElement.hpp:121
Bankable::PBValue::getValue
uint16_t getValue() const override
Get the most recent MIDI value that was received for the active bank.
Definition
PBValue.hpp:89
Bankable::PBValue::PBValue
PBValue(BankConfig< BankSize, BankType::ChangeChannel > config, MIDIChannelCable address)
Definition
PBValue.hpp:72
Bankable::PBValue::onBankSettingChange
void onBankSettingChange() override
A function to be executed each time the bank setting changes.
Definition
PBValue.hpp:102
Bankable::PBValue::getValue
uint16_t getValue(uint8_t bank) const
Get the most recent MIDI value that was received for the given bank.
Definition
PBValue.hpp:91
Bankable::PBValue::Matcher
BankablePitchBendMIDIMatcher< BankSize > Matcher
Definition
PBValue.hpp:65
Bankable::PBValue::Parent
BankableMatchingMIDIInputElement< MessageType, Matcher > Parent
Definition
PBValue.hpp:66
Bankable::PBValue::handleUpdate
void handleUpdate(typename Matcher::Result match) override
Definition
PBValue.hpp:77
Bankable::PBValue::MessageType
static constexpr auto MessageType
Definition
PBValue.hpp:64
Bankable::PBValue::reset
void reset() override
Reset all values to zero.
Definition
PBValue.hpp:96
Bankable::PBValue::values
AH::Array< uint16_t, BankSize > values
Definition
PBValue.hpp:105
Interfaces::IValue14
Abstract interface for MIDI input elements that receive and store a 14-bit value.
Definition
InterfaceMIDIInputElements.hpp:33
Interfaces::IValue14::dirty
bool dirty
Definition
InterfaceMIDIInputElements.hpp:49
MIDIChannelCable
A class for saving a MIDI channel and cable number.
Definition
MIDIAddress.hpp:24
MatchingMIDIInputElement< MIDIMessageType::PitchBend, PitchBendMIDIMatcher >::MatchingMIDIInputElement
MatchingMIDIInputElement(const PitchBendMIDIMatcher &matcher)
Definition
MIDIInputElement.hpp:90
PBValue::getValue
uint16_t getValue() const override
Get the most recent MIDI value that was received.
Definition
PBValue.hpp:34
PBValue::Matcher
PitchBendMIDIMatcher Matcher
Definition
PBValue.hpp:17
PBValue::value
uint16_t value
Definition
PBValue.hpp:45
PBValue::PBValue
PBValue(MIDIChannelCable address)
Definition
PBValue.hpp:21
PBValue::handleUpdate
void handleUpdate(typename Matcher::Result match) override
Definition
PBValue.hpp:24
PBValue::reset
void reset() override
Reset all values to zero.
Definition
PBValue.hpp:39
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition
BankAddresses.hpp:7
AH::Array
An array wrapper for easy copying, comparing, and iterating.
Definition
Array.hpp:32
BankConfig
Definition
BankConfig.hpp:54
BankablePitchBendMIDIMatcher::Result
Definition
MIDIInputElementMatchers.hpp:195
BankablePitchBendMIDIMatcher::Result::bankIndex
uint8_t bankIndex
Definition
MIDIInputElementMatchers.hpp:198
BankablePitchBendMIDIMatcher::Result::value
uint16_t value
Definition
MIDIInputElementMatchers.hpp:197
BankablePitchBendMIDIMatcher
Matcher for MIDI Pitch Bend messages.
Definition
MIDIInputElementMatchers.hpp:189
PitchBendMIDIMatcher::Result
Definition
MIDIInputElementMatchers.hpp:62
PitchBendMIDIMatcher::Result::value
uint16_t value
Definition
MIDIInputElementMatchers.hpp:64
PitchBendMIDIMatcher
Matcher for MIDI Pitch Bend messages. Matches a single address.
Definition
MIDIInputElementMatchers.hpp:59
Generated by
1.17.0