Line data Source code
1 : #pragma once 2 : 3 : #include <AH/Settings/Warnings.hpp> 4 : AH_DIAGNOSTIC_WERROR() 5 : 6 : #include <AH/Containers/ArrayHelpers.hpp> 7 : #include <Banks/BankAddresses.hpp> 8 : #include <MIDI_Outputs/Bankable/Abstract/MIDIFilteredAnalog.hpp> 9 : #include <MIDI_Senders/PitchBendSender.hpp> 10 : 11 : BEGIN_CS_NAMESPACE 12 : 13 : namespace Bankable { 14 : namespace ManyAddresses { 15 : 16 : /** 17 : * @brief A class of MIDIOutputElement%s that read the analog input from a 18 : * **potentiometer or fader**, and send out 14-bit MIDI **Pitch Bend** 19 : * events. 20 : * 21 : * The analog input is filtered and hysteresis is applied for maximum 22 : * stability. 23 : * The actual precision is "only" 10 bits, because this is the resolution of the 24 : * built-in ADC, and this is the default resolution used by the Mackie Control 25 : * Universal protocol. 26 : * This version can be banked using an arbitrary list of alternative 27 : * addresses. 28 : * 29 : * @tparam N 30 : * The number of variants/alternative addresses the element has. 31 : * 32 : * @ingroup ManyAddressesMIDIOutputElements 33 : */ 34 : template <setting_t N> 35 1 : class PBPotentiometer 36 : : public Bankable::MIDIFilteredAnalog<ManyAddresses<N>, 37 : PitchBendSender<10>> { 38 : public: 39 : /** 40 : * @brief Create a new Bankable PBPotentiometer object with the given 41 : * analog pin and channel. 42 : * 43 : * @param bank 44 : * The bank that selects the address to use. 45 : * @param analogPin 46 : * The analog input pin to read from. 47 : * @param addresses 48 : * The list of MIDI channels [CHANNEL_1, CHANNEL_16] and optional 49 : * Cable Numbers [0, 15]. 50 : * @param sender 51 : * The MIDI sender to use. 52 : */ 53 1 : PBPotentiometer(const Bank<N> &bank, pin_t analogPin, 54 : const Array<MIDICNChannel, N> &addresses, 55 : const PitchBendSender<10> &sender = {}) 56 1 : : MIDIFilteredAnalog<ManyAddresses<N>, PitchBendSender<10>>{ 57 1 : {bank, AH::copyAs<MIDICNChannelAddress>(addresses)}, 58 1 : analogPin, 59 1 : sender, 60 2 : } {} 61 : }; 62 : 63 : } // namespace ManyAddresses 64 : } // namespace Bankable 65 : 66 : END_CS_NAMESPACE 67 : 68 : AH_DIAGNOSTIC_POP()