Deluge Firmware
1.3.0
Build date: 2026.11.28
Toggle main menu visibility
Loading...
Searching...
No Matches
scale_change.h
1
#pragma once
2
3
#include "model/scale/note_set.h"
4
#include <array>
5
#include <cstdint>
6
#include <optional>
7
11
struct
LetterMapping
{
13
bool
preferFlats
=
false
;
15
std::array<int8_t, 12>
sourceLetter
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
17
std::array<int8_t, 7>
sourcePrimary
{-1, -1, -1, -1, -1, -1, -1};
19
std::array<int8_t, 7>
targetPrimary
{-1, -1, -1, -1, -1, -1, -1};
21
std::array<int8_t, 7>
targetSecond
{-1, -1, -1, -1, -1, -1, -1};
22
};
23
24
class
ScaleChange
{
25
public
:
28
NoteSet
source
;
29
NoteSet
target;
32
int8_t
operator[]
(uint8_t degree)
const
{
return
degreeOffset[degree]; }
33
int8_t&
operator[]
(uint8_t degree) {
return
degreeOffset[degree]; }
42
NoteSet
applyTo
(NoteSet notes)
const
;
43
47
bool
isIdentity
()
const
{
48
if
(
letterMapping
) {
49
return
false
;
50
}
51
for
(int8_t offset : degreeOffset) {
52
if
(offset != 0) {
53
return
false
;
54
}
55
}
56
return
true
;
57
}
58
60
std::optional<LetterMapping>
letterMapping
;
61
62
private
:
63
int8_t degreeOffset[kMaxScaleSize] = {0};
64
};
NoteSet
Definition
note_set.h:20
ScaleChange
Definition
scale_change.h:24
ScaleChange::source
NoteSet source
Definition
scale_change.h:28
ScaleChange::operator[]
int8_t operator[](uint8_t degree) const
Definition
scale_change.h:32
ScaleChange::isIdentity
bool isIdentity() const
Definition
scale_change.h:47
ScaleChange::applyTo
NoteSet applyTo(NoteSet notes) const
Definition
scale_change.cpp:4
ScaleChange::letterMapping
std::optional< LetterMapping > letterMapping
Definition
scale_change.h:60
LetterMapping
Definition
scale_change.h:11
LetterMapping::sourceLetter
std::array< int8_t, 12 > sourceLetter
Letter 0..6 of each interval of the source scale.
Definition
scale_change.h:15
LetterMapping::sourcePrimary
std::array< int8_t, 7 > sourcePrimary
For each letter, the interval of the source scale's (primary) note with it.
Definition
scale_change.h:17
LetterMapping::preferFlats
bool preferFlats
How anchors outside the source scale are spelled.
Definition
scale_change.h:13
LetterMapping::targetSecond
std::array< int8_t, 7 > targetSecond
For each letter, the interval of the target scale's second note with it, if two share the letter.
Definition
scale_change.h:21
LetterMapping::targetPrimary
std::array< int8_t, 7 > targetPrimary
For each letter, the interval of the target scale's (primary) note with it.
Definition
scale_change.h:19