Line data Source code
1 : /* ✔ */ 2 : 3 : #pragma once 4 : 5 : #include <MIDI_Outputs/Abstract/MIDIButtonLatched.hpp> 6 : #include <MIDI_Senders/DigitalNoteSender.hpp> 7 : 8 : BEGIN_CS_NAMESPACE 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 1 : 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 : * [CABLE_1, CABLE_16]. 35 : * @param velocity 36 : * The velocity of the MIDI Note events. 37 : */ 38 1 : NoteButtonLatched(pin_t pin, const MIDIAddress &address, 39 : uint8_t velocity = 0x7F) 40 1 : : MIDIButtonLatched{ 41 1 : pin, 42 1 : address, 43 1 : {velocity}, 44 2 : } {} 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 : 52 : END_CS_NAMESPACE