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/MIDIFilteredAnalog.hpp>
6 : #include <MIDI_Senders/PitchBendSender.hpp>
7 :
8 : BEGIN_CS_NAMESPACE
9 :
10 : namespace Bankable {
11 : namespace ManyAddresses {
12 :
13 : /**
14 : * @brief A class of MIDIOutputElement%s that read the analog input from a
15 : * **potentiometer or fader**, and send out 14-bit MIDI **Pitch Bend**
16 : * events.
17 : *
18 : * The analog input is filtered and hysteresis is applied for maximum
19 : * stability.
20 : * The actual precision is "only" 10 bits, because this is the resolution of the
21 : * built-in ADC, and this is the default resolution used by the Mackie Control
22 : * Universal protocol.
23 : * This version can be banked using an arbitrary list of alternative
24 : * addresses.
25 : *
26 : * @tparam NumBanks
27 : * The number of variants/alternative addresses the element has.
28 : *
29 : * @ingroup ManyAddressesMIDIOutputElements
30 : */
31 : template <setting_t NumBanks>
32 : class PBPotentiometer
33 : : public Bankable::MIDIFilteredAnalog<ManyAddresses<NumBanks>,
34 : PitchBendSender<10>> {
35 : public:
36 : /**
37 : * @brief Create a new Bankable PBPotentiometer object with the given
38 : * analog pin and channel.
39 : *
40 : * @param bank
41 : * The bank that selects the address to use.
42 : * @param analogPin
43 : * The analog input pin to read from.
44 : * @param addresses
45 : * The list of MIDI channels [Channel_1, Channel_16] and optional
46 : * Cable Numbers [Cable_1, Cable_16].
47 : */
48 1 : PBPotentiometer(const Bank<NumBanks> &bank, pin_t analogPin,
49 : const Array<MIDIChannelCable, NumBanks> &addresses)
50 : : MIDIFilteredAnalog<ManyAddresses<NumBanks>, PitchBendSender<10>> {
51 1 : {bank, AH::copyAs<MIDIAddress>(addresses)}, analogPin, {}} {}
52 : };
53 :
54 : } // namespace ManyAddresses
55 : } // namespace Bankable
56 :
57 : END_CS_NAMESPACE
|