Control Surface  1.1.0
MIDI Control Surface library for Arduino
NoteButtonLatched.hpp
Go to the documentation of this file.
1 /* ✔ */
2 
3 #pragma once
4 
7 
9 
10 /**
11  * @brief A class of MIDIOutputElement%s that read the input of a **momentary
12  * push button or toggle switch**, and send out MIDI **Note** events.
13  *
14  * It latches the input, so press once to enable, press again to disable
15  * (toggle).
16  *
17  * The switch is debounced in software.
18  * This version cannot be banked.
19  *
20  * @ingroup MIDIOutputElements
21  */
22 class NoteButtonLatched : public MIDIButtonLatched<DigitalNoteSender> {
23  public:
24  /**
25  * @brief Create a new NoteButtonLatched object on the given pin and with
26  * address.
27  *
28  * @param pin
29  * The digital input pin to read from.
30  * The internal pull-up resistor will be enabled.
31  * @param address
32  * The MIDI address containing the note number [0, 127],
33  * channel [CHANNEL_1, CHANNEL_16], and optional cable number
34  * [0, 15].
35  * @param velocity
36  * The velocity of the MIDI Note events.
37  */
39  uint8_t velocity = 0x7F)
41  pin,
42  address,
43  {velocity},
44  } {}
45 
46  /// Set the velocity of the MIDI Note events.
47  void setVelocity(uint8_t velocity) { this->sender.setVelocity(velocity); }
48  /// Get the velocity of the MIDI Note events.
49  uint8_t getVelocity() const { return this->sender.getVelocity(); }
50 };
51 
MIDIButtonLatched< DigitalNoteSender >::sender
DigitalNoteSender sender
Definition: Abstract/MIDIButtonLatched.hpp:76
NoteButtonLatched
A class of MIDIOutputElements that read the input of a momentary push button or toggle switch,...
Definition: NoteButtonLatched.hpp:22
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
NoteButtonLatched::setVelocity
void setVelocity(uint8_t velocity)
Set the velocity of the MIDI Note events.
Definition: NoteButtonLatched.hpp:47
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
MIDICNChannelAddress
A type-safe utility class for saving a MIDI address consisting of a 7-bit address,...
Definition: MIDICNChannelAddress.hpp:82
MIDIButtonLatched< DigitalNoteSender >::address
const MIDICNChannelAddress address
Definition: Abstract/MIDIButtonLatched.hpp:72
AH::pin_t
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
Definition: Hardware-Types.hpp:17
DigitalNoteSender::getVelocity
uint8_t getVelocity() const
Definition: DigitalNoteSender.hpp:18
DigitalNoteSender.hpp
NoteButtonLatched::NoteButtonLatched
NoteButtonLatched(pin_t pin, const MIDICNChannelAddress &address, uint8_t velocity=0x7F)
Create a new NoteButtonLatched object on the given pin and with address.
Definition: NoteButtonLatched.hpp:38
MIDIButtonLatched.hpp
DigitalNoteSender::setVelocity
void setVelocity(uint8_t velocity)
Definition: DigitalNoteSender.hpp:17
NoteButtonLatched::getVelocity
uint8_t getVelocity() const
Get the velocity of the MIDI Note events.
Definition: NoteButtonLatched.hpp:49
MIDIButtonLatched
A class for momentary buttons and switches that send MIDI events.
Definition: Abstract/MIDIButtonLatched.hpp:20