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