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