Line data Source code
1 : #pragma once 2 : 3 : #include <AH/Containers/ArrayHelpers.hpp> 4 : #include <Banks/BankAddresses.hpp> 5 : #include <MIDI_Outputs/Bankable/Abstract/MIDIAbsoluteEncoder.hpp> 6 : #include <MIDI_Senders/PitchBendSender.hpp> 7 : 8 : AH_DIAGNOSTIC_WERROR() 9 : 10 : BEGIN_CS_NAMESPACE 11 : 12 : namespace Bankable { 13 : namespace ManyAddresses { 14 : 15 : /** 16 : * @brief A class of MIDIOutputElement%s that read the input of a **quadrature 17 : * (rotary) encoder** and send out absolute MIDI **Pitch Bend** 18 : * events. 19 : * 20 : * This version can be banked using an arbitrary list of alternative 21 : * addresses. 22 : * 23 : * @tparam NumBanks 24 : * The number of banks. 25 : * 26 : * @ingroup ManyAddressesMIDIOutputElements 27 : */ 28 : template <size_t NumBanks> 29 : class PBAbsoluteEncoder 30 : : public MIDIAbsoluteEncoder<NumBanks, ManyAddresses<NumBanks>, 31 : PitchBendSender<14>> { 32 : public: 33 : /** 34 : * @brief Construct a new Bankable PBAbsoluteEncoder object with the given 35 : * pins, channel, speed factor, and number of pulses per step. 36 : * 37 : * @param bank 38 : * The bank that selects the address to use. 39 : * @param encoder 40 : * The Encoder object to use. 41 : * Usually passed as a list of the two pins connected to the 42 : * A and B outputs of the encoder, e.g. `{2, 3}`. 43 : * The internal pull-up resistors will be enabled by the Encoder 44 : * library. 45 : * @param addresses 46 : * The list of MIDI channels [CHANNEL_1, CHANNEL_16] and optional 47 : * cable numbers [0, 15]. 48 : * @param speedMultiply 49 : * A constant factor to increase the speed of the rotary encoder. 50 : * The difference in position will just be multiplied by this 51 : * factor. 52 : * @param pulsesPerStep 53 : * The number of pulses per physical click of the encoder. 54 : * For a normal encoder, this is 4. If you want to increase the 55 : * resolution, for the use of Jog wheels, for example, you can go 56 : * as 1. 57 : * Whereas a greater speedMultiply factor will increase the 58 : * speed, increasing the number of pulsesPerStep will result in a 59 : * lower speed. 60 : */ 61 1 : PBAbsoluteEncoder(const Bank<NumBanks> &bank, AHEncoder &&encoder, 62 : const Array<MIDIChannelCable, NumBanks> &addresses, 63 : int16_t speedMultiply = 1, uint8_t pulsesPerStep = 4) 64 : : MIDIAbsoluteEncoder<NumBanks, ManyAddresses<NumBanks>, 65 : PitchBendSender<14>>( 66 3 : {bank, AH::copyAs<MIDIAddress>(addresses)}, std::move(encoder), 67 4 : speedMultiply, pulsesPerStep, {}) {} 68 : }; 69 : 70 : } // namespace ManyAddresses 71 : } // namespace Bankable 72 : 73 : END_CS_NAMESPACE 74 : 75 : AH_DIAGNOSTIC_POP()