Control Surface  1.1.0
MIDI Control Surface library for Arduino
Transposer.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Banks/Bank.hpp>
5 #include <Def/Def.hpp>
6 
8 
9 template <int8_t MINIMUM_SEMITONES, int8_t MAXIMUM_SEMITONES>
10 class Transposer : public Bank<MAXIMUM_SEMITONES - MINIMUM_SEMITONES + 1> {
11  public:
12  Transposer(int8_t step = 1) : Bank<N>(step, -MINIMUM_SEMITONES) {
13  static_assert(MINIMUM_SEMITONES <= 0,
14  "Error: the minimum transposition must be negative");
15  static_assert(MAXIMUM_SEMITONES >= 0,
16  "Error: the maximum transposition must be positive");
17  }
18  /**
19  * @brief Get the current transposition offset.
20  *
21  * @todo The return type is a uint8_t, but it can be negative.
22  * This is not an issue, because the result will be the same,
23  * since the addition will just overflow and truncate, but
24  * it's not really clean.
25  */
26  setting_t getSelection() const override {
28  MINIMUM_SEMITONES;
29  }
30 
31  static constexpr setting_t N = MAXIMUM_SEMITONES - MINIMUM_SEMITONES + 1;
32 };
33 
Bank
A class that groups Bankable BankableMIDIOutputs and BankableMIDIInputs, and allows the user to chang...
Definition: Bank.hpp:77
Def.hpp
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:9
Transposer::N
static constexpr setting_t N
Definition: Transposer.hpp:31
Transposer
Definition: Transposer.hpp:10
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition: Settings/NamespaceSettings.hpp:10
Control_Surface_Class.hpp
OutputBank::getSelection
virtual setting_t getSelection() const
Get the current bank setting.
Definition: Bank.hpp:49
setting_t
uint8_t setting_t
The type used for Selectors.
Definition: Def.hpp:50
Bank.hpp
Transposer::getSelection
setting_t getSelection() const override
Get the current transposition offset.
Definition: Transposer.hpp:26
Transposer::Transposer
Transposer(int8_t step=1)
Definition: Transposer.hpp:12