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 : * [0, 15]. 39 : * @param velocity 40 : * The velocity of the MIDI Note events. 41 : */ 42 4 : NoteButtonLatching(const OutputBankConfig &config, pin_t pin, 43 : const MIDICNChannelAddress &address, 44 : uint8_t velocity = 0x7F) 45 4 : : MIDIButtonLatching<SingleAddress, DigitalNoteSender>{ 46 4 : {config, address}, 47 4 : pin, 48 4 : {velocity}, 49 8 : } {} 50 : 51 : /// Set the velocity of the MIDI Note events. 52 : void setVelocity(uint8_t velocity) { this->sender.setVelocity(velocity); } 53 : /// Get the velocity of the MIDI Note events. 54 : uint8_t getVelocity() const { return this->sender.getVelocity(); } 55 : }; 56 : 57 : } // namespace Bankable 58 : 59 : END_CS_NAMESPACE