Control Surface  1.1.0
MIDI Control Surface library for Arduino
Bankable/NoteButtonMatrix.hpp
Go to the documentation of this file.
1 #pragma once
2 
6 
8 
9 namespace Bankable {
10 
11 /**
12  * @brief A class of MIDIOutputElement%s that read the input from a **matrix
13  * of momentary push buttons or switches**, and send out MIDI **Note**
14  * events.
15  *
16  * A Note On event is sent when a button is pressed, and a Note Off
17  * event is sent when a button is released.
18  * Crude software debouncing is implemented by limiting the refresh rate.
19  * This version can be banked.
20  *
21  * @tparam nb_rows
22  * The number of rows of the matrix.
23  * @tparam nb_cols
24  * The number of columns of the matrix.
25  *
26  * @ingroup BankableMIDIOutputElements
27  */
28 template <uint8_t nb_rows, uint8_t nb_cols>
30  : public MIDIButtonMatrix<MatrixAddress<nb_rows, nb_cols>,
31  DigitalNoteSender, nb_rows, nb_cols> {
32  public:
33  /**
34  * @brief Create a new Bankable NoteButtonMatrix object with the given
35  * pins, note numbers and channel.
36  *
37  * @param config
38  * The bank configuration to use: the bank to add this element to,
39  * and whether to change the address, channel or cable number.
40  * @param rowPins
41  * A list of pin numbers connected to the rows of the button
42  * matrix.
43  * **⚠** These pins will be driven LOW as outputs (Lo-Z).
44  * @param colPins
45  * A list of pin numbers connected to the columns of the button
46  * matrix.
47  * These pins will be used as inputs (Hi-Z), and the
48  * internal pull-up resistor will be enabled.
49  * @param notes
50  * A 2-dimensional array of the same dimensions as the button
51  * matrix that contains the note number of each button. [0, 127]
52  * @param channelCN
53  * The MIDI channel [CHANNEL_1, CHANNEL_16] and Cable Number
54  * [0, 15].
55  * @param velocity
56  * The velocity of the MIDI Note events.
57  */
59  const PinList<nb_rows> &rowPins,
60  const PinList<nb_cols> &colPins,
62  MIDICNChannel channelCN = {CHANNEL_1, 0},
63  uint8_t velocity = 0x7F)
65  nb_rows, nb_cols>{
66  {config, notes, channelCN},
67  rowPins,
68  colPins,
69  {velocity},
70  } {}
71 
72  /// Set the velocity of the MIDI Note events.
73  void setVelocity(uint8_t velocity) { this->sender.setVelocity(velocity); }
74  /// Get the velocity of the MIDI Note events.
75  uint8_t getVelocity() const { return this->sender.getVelocity(); }
76 };
77 
78 } // namespace Bankable
79 
Bankable
A namespace for MIDI elements that can be added to a Bank, to change their address or channel.
Definition: BankAddresses.hpp:7
Bankable::NoteButtonMatrix::NoteButtonMatrix
NoteButtonMatrix(const OutputBankConfig &config, const PinList< nb_rows > &rowPins, const PinList< nb_cols > &colPins, const AddressMatrix< nb_rows, nb_cols > &notes, MIDICNChannel channelCN={CHANNEL_1, 0}, uint8_t velocity=0x7F)
Create a new Bankable NoteButtonMatrix object with the given pins, note numbers and channel.
Definition: Bankable/NoteButtonMatrix.hpp:58
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
BankAddresses.hpp
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
MIDIButtonMatrix.hpp
MIDICNChannel
A class for saving a MIDI channel and cable number.
Definition: MIDICNChannelAddress.hpp:19
DigitalNoteSender::getVelocity
uint8_t getVelocity() const
Definition: DigitalNoteSender.hpp:18
Bankable::NoteButtonMatrix::getVelocity
uint8_t getVelocity() const
Get the velocity of the MIDI Note events.
Definition: Bankable/NoteButtonMatrix.hpp:75
AddressMatrix
Array2D< uint8_t, nb_rows, nb_cols > AddressMatrix
Definition: Def.hpp:26
AH::ButtonMatrix::rowPins
const PinList< nb_rows > rowPins
Definition: ButtonMatrix.hpp:85
Bankable::NoteButtonMatrix
A class of MIDIOutputElements that read the input from a matrix of momentary push buttons or switches...
Definition: Bankable/NoteButtonMatrix.hpp:29
Bankable::NoteButtonMatrix::setVelocity
void setVelocity(uint8_t velocity)
Set the velocity of the MIDI Note events.
Definition: Bankable/NoteButtonMatrix.hpp:73
DigitalNoteSender.hpp
DigitalNoteSender
Definition: DigitalNoteSender.hpp:7
DigitalNoteSender::setVelocity
void setVelocity(uint8_t velocity)
Definition: DigitalNoteSender.hpp:17
AH::ButtonMatrix::colPins
const PinList< nb_cols > colPins
Definition: ButtonMatrix.hpp:86
OutputBankConfig
A struct for selecting the bank of BankableMIDIOutputs and the bank type.
Definition: BankConfig.hpp:50
Bankable::MIDIButtonMatrix
MIDIButtonMatrix.
Definition: Bankable/Abstract/MIDIButtonMatrix.hpp:29
Bankable::MatrixAddress
Definition: BankAddresses.hpp:43
CHANNEL_1
constexpr Channel CHANNEL_1
Definition: Channel.hpp:111
Bankable::MIDIButtonMatrix< MatrixAddress< nb_rows, nb_cols >, DigitalNoteSender, nb_rows, nb_cols >::sender
DigitalNoteSender sender
Definition: Bankable/Abstract/MIDIButtonMatrix.hpp:80