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