Line data Source code
1 : #pragma once 2 : 3 : #include <Banks/BankAddresses.hpp> 4 : #include <MIDI_Outputs/Bankable/Abstract/MIDIButtonLatching.hpp> 5 : #include <MIDI_Senders/DigitalNoteSender.hpp> 6 : 7 : BEGIN_CS_NAMESPACE 8 : 9 : namespace Bankable { 10 : 11 : /** 12 : * @brief A class of MIDIOutputElement%s that read the input of a **latching 13 : * push button or toggle switch**, and send out MIDI **Note** events. 14 : * 15 : * When the switch changes state, two MIDI Note events are sent: first 16 : * a Note On event, followed immediately by a Note Off event. 17 : * The switch is debounced in software. 18 : * This version can be banked. 19 : * 20 : * @ingroup BankableMIDIOutputElements 21 : */ 22 4 : class NoteButtonLatching 23 : : public MIDIButtonLatching<SingleAddress, DigitalNoteSender> { 24 : public: 25 : /** 26 : * @brief Create a new Bankable NoteButtonLatching object with the given 27 : * pin, note number and channel. 28 : * 29 : * @param config 30 : * The bank configuration to use: the bank to add this element to, 31 : * and whether to change the address, channel or cable number. 32 : * @param pin 33 : * The digital input pin to read from. 34 : * The internal pull-up resistor will be enabled. 35 : * @param address 36 : * The MIDI address containing the note number [0, 127], 37 : * channel [CHANNEL_1, CHANNEL_16], and optional cable number 38 : * [CABLE_1, CABLE_16]. 39 : * @param velocity 40 : * The velocity of the MIDI Note events. 41 : */ 42 4 : NoteButtonLatching(OutputBankConfig<> config, pin_t pin, 43 : MIDIAddress address, uint8_t velocity = 0x7F) 44 4 : : MIDIButtonLatching<SingleAddress, DigitalNoteSender>{ 45 4 : {config, address}, 46 4 : pin, 47 4 : {velocity}, 48 8 : } {} 49 : 50 : /// Set the velocity of the MIDI Note events. 51 : void setVelocity(uint8_t velocity) { this->sender.setVelocity(velocity); } 52 : /// Get the velocity of the MIDI Note events. 53 : uint8_t getVelocity() const { return this->sender.getVelocity(); } 54 : }; 55 : 56 : } // namespace Bankable 57 : 58 : END_CS_NAMESPACE