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 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 : 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, MIDIAddress address, uint8_t velocity = 0x7F) 39 1 : : MIDIButtonLatched { 40 : pin, 41 : address, 42 : {velocity}, 43 1 : } {} 44 : 45 : /// Set the velocity of the MIDI Note events. 46 : void setVelocity(uint8_t velocity) { this->sender.setVelocity(velocity); } 47 : /// Get the velocity of the MIDI Note events. 48 : uint8_t getVelocity() const { return this->sender.getVelocity(); } 49 : }; 50 : 51 : END_CS_NAMESPACE