Control Surface pin-t-adl
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
10template <int8_t MinTransposition, int8_t MaxTransposition>
11class Transposer : public Bank<MaxTransposition - MinTransposition + 1> {
12 public:
13 Transposer(int8_t step = 1)
14 : Bank<NumBanks>(step, -MinTransposition, MinTransposition) {
15 static_assert(MinTransposition <= 0,
16 "Error: the minimum transposition must be negative");
17 static_assert(MaxTransposition >= 0,
18 "Error: the maximum transposition must be positive");
19 }
20
27 void setTransposition(int8_t tp) { this->select(tp - MinTransposition); }
28
30 int8_t getTransposition() const {
31 return this->getSelection() + MinTransposition;
32 }
33
35 int8_t getTranspositionSemitones() const { return this->getOffset(); }
36
37 static constexpr setting_t N = MaxTransposition - MinTransposition + 1;
38 static constexpr setting_t NumBanks = N;
39};
40
uint8_t setting_t
The type used for Selectors.
Definition: Def.hpp:53
#define END_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
A class that groups Bankable MIDI Output Elements and Bankable MIDI Input Elements,...
Definition: Bank.hpp:91
void select(setting_t bankSetting) override
Select the given bank setting.
setting_t getSelection() const
Get the current bank setting (zero-based).
Definition: Bank.hpp:44
int8_t getOffset() const
Get the address offset (number of banks times the index of the selected bank after applying the offse...
Definition: Bank.hpp:58
Class for transposing the address of NoteButton and other MIDI elements.
Definition: Transposer.hpp:11
static constexpr setting_t N
Definition: Transposer.hpp:37
void setTransposition(int8_t tp)
Set the transposition.
Definition: Transposer.hpp:27
int8_t getTransposition() const
Get the transposition.
Definition: Transposer.hpp:30
int8_t getTranspositionSemitones() const
Get the transposition as a number of semitones.
Definition: Transposer.hpp:35
static constexpr setting_t NumBanks
Definition: Transposer.hpp:38
Transposer(int8_t step=1)
Definition: Transposer.hpp:13