Line data Source code
1 : #pragma once
2 :
3 : #include <MIDI_Outputs/Abstract/MIDIRotaryEncoder.hpp>
4 : #include <MIDI_Senders/RelativeCCSender.hpp>
5 :
6 : BEGIN_CS_NAMESPACE
7 :
8 : /**
9 : * @brief A class of MIDIOutputElement%s that read the input of a **quadrature
10 : * (rotary) encoder** and send out relative MIDI **Control Change**
11 : * events.
12 : *
13 : * This version cannot be banked.
14 : *
15 : * @ingroup MIDIOutputElements
16 : */
17 : class CCRotaryEncoder : public MIDIRotaryEncoder<RelativeCCSender> {
18 : public:
19 : /**
20 : * @brief Construct a new CCRotaryEncoder object with the given pins,
21 : * address, channel, speed factor, and number of pulses per step.
22 : *
23 : * @param encoder
24 : * The Encoder object to use.
25 : * Usually passed as a list of the two pins connected to the
26 : * A and B outputs of the encoder, e.g. `{2, 3}`.
27 : * The internal pull-up resistors will be enabled by the Encoder
28 : * library.
29 : * @param address
30 : * The MIDI address containing the controller number [0, 119],
31 : * channel [Channel_1, Channel_16], and optional cable number
32 : * [Cable_1, Cable_16].
33 : * @param speedMultiply
34 : * A constant factor to increase the speed of the rotary encoder.
35 : * The difference in position will just be multiplied by this
36 : * factor.
37 : * @param pulsesPerStep
38 : * The number of pulses per physical click of the encoder.
39 : * For a normal encoder, this is 4. If you want to increase the
40 : * resolution, for the use of Jog wheels, for example, you can go
41 : * as 1.
42 : * Whereas a greater speedMultiplier factor will increase the
43 : * speed, increasing the number of pulsesPerStep will result in a
44 : * lower speed.
45 : */
46 13 : CCRotaryEncoder(AHEncoder &&encoder, MIDIAddress address,
47 : int16_t speedMultiply = 1, uint8_t pulsesPerStep = 4)
48 13 : : MIDIRotaryEncoder<RelativeCCSender>(
49 13 : std::move(encoder), address, speedMultiply, pulsesPerStep, {}) {}
50 : };
51 :
52 : /**
53 : * @brief A class of MIDIOutputElement%s that read the input of a **quadrature
54 : * (rotary) encoder** and send out relative MIDI **Control Change**
55 : * events. This class just saves a reference to the encoder you give
56 : * it, so it can be shared with other classes.
57 : *
58 : * This version cannot be banked.
59 : *
60 : * @ingroup MIDIOutputElements
61 : */
62 : class BorrowedCCRotaryEncoder
63 : : public BorrowedMIDIRotaryEncoder<RelativeCCSender> {
64 : public:
65 : /**
66 : * @brief Construct a new CCRotaryEncoder object with the given pins,
67 : * address, channel, speed factor, and number of pulses per step.
68 : *
69 : * @param encoder
70 : * The Encoder object to use. Saved by reference, so it must
71 : * out-live this instance.
72 : * @param address
73 : * The MIDI address containing the controller number [0, 119],
74 : * channel [Channel_1, Channel_16], and optional cable number
75 : * [0, 15].
76 : * @param speedMultiply
77 : * A constant factor to increase the speed of the rotary encoder.
78 : * The difference in position will just be multiplied by this
79 : * factor.
80 : * @param pulsesPerStep
81 : * The number of pulses per physical click of the encoder.
82 : * For a normal encoder, this is 4. If you want to increase the
83 : * resolution, for the use of Jog wheels, for example, you can go
84 : * as 1.
85 : * Whereas a greater speedMultiplier factor will increase the
86 : * speed, increasing the number of pulsesPerStep will result in a
87 : * lower speed.
88 : */
89 : BorrowedCCRotaryEncoder(AHEncoder &encoder, MIDIAddress address,
90 : int16_t speedMultiply = 1,
91 : uint8_t pulsesPerStep = 4)
92 : : BorrowedMIDIRotaryEncoder<RelativeCCSender>(
93 : encoder, address, speedMultiply, pulsesPerStep, {}) {}
94 : };
95 :
96 : END_CS_NAMESPACE
|