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 NumBanks 30 : * The number of variants/alternative addresses the element has. 31 : * 32 : * @ingroup ManyAddressesMIDIOutputElements 33 : */ 34 : template <setting_t NumBanks> 35 1 : class PBPotentiometer 36 : : public Bankable::MIDIFilteredAnalog<ManyAddresses<NumBanks>, 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 [CABLE_1, CABLE_16]. 50 : */ 51 1 : PBPotentiometer(const Bank<NumBanks> &bank, pin_t analogPin, 52 : const Array<MIDIChannelCN, NumBanks> &addresses) 53 1 : : MIDIFilteredAnalog<ManyAddresses<NumBanks>, PitchBendSender<10>>{ 54 2 : {bank, AH::copyAs<MIDIAddress>(addresses)}, analogPin, {}} {} 55 : }; 56 : 57 : } // namespace ManyAddresses 58 : } // namespace Bankable 59 : 60 : END_CS_NAMESPACE 61 : 62 : AH_DIAGNOSTIC_POP()