Deluge Firmware 1.3.0
Build date: 2025.04.16
Loading...
Searching...
No Matches
chords.h
1/*
2 * Copyright © 2016-2024 Synthstrom Audible Limited
3 * Copyright © 2024 Madeline Scyphers
4 *
5 * This file is part of The Synthstrom Audible Deluge Firmware.
6 *
7 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software Foundation,
9 * either version 3 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along with this program.
16 * If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20
21#include "definitions_cxx.hpp"
22#include "model/scale/note_set.h"
23#include <array>
24// #include <vector>
25
26constexpr int8_t kMaxChordKeyboardSize = 7;
27constexpr int8_t kUniqueVoicings = 4;
28constexpr int8_t kUniqueChords = 33;
29constexpr int8_t kOffScreenChords = kUniqueChords - kDisplayHeight;
30
31namespace deluge::gui::ui::keyboard {
32
33enum class ChordQuality {
34 MAJOR,
35 MINOR,
36 DIMINISHED,
37 AUGMENTED,
38 DOMINANT,
39 OTHER,
40 CHORD_QUALITY_MAX,
41};
42
43// Check and return the quality of a chord, assuming the notes are defined from the root, even if it is a rootless chord
44ChordQuality getChordQuality(NoteSet& notes);
45
46// Interval offsets for convenience
47const int8_t NONE = INT8_MAX;
48const int8_t ROOT = 0;
49const int8_t MIN2 = 1;
50const int8_t MAJ2 = 2;
51const int8_t MIN3 = 3;
52const int8_t MAJ3 = 4;
53const int8_t P4 = 5;
54const int8_t AUG4 = 6;
55const int8_t DIM5 = 6;
56const int8_t P5 = 7;
57const int8_t AUG5 = 8;
58const int8_t MIN6 = 8;
59const int8_t MAJ6 = 9;
60const int8_t DIM7 = 9;
61const int8_t MIN7 = 10;
62const int8_t DOM7 = 10;
63const int8_t MAJ7 = 11;
64const int8_t OCT = kOctaveSize;
65const int8_t MIN9 = MIN2 + OCT;
66const int8_t MAJ9 = MAJ2 + OCT;
67const int8_t MIN10 = MIN3 + OCT;
68const int8_t MAJ10 = MAJ3 + OCT;
69const int8_t P11 = P4 + OCT;
70const int8_t AUG11 = AUG4 + OCT;
71const int8_t DIM12 = DIM5 + OCT;
72const int8_t P12 = P5 + OCT;
73const int8_t MIN13 = MIN6 + OCT;
74const int8_t MAJ13 = MAJ6 + OCT;
75const int8_t MIN14 = MIN7 + OCT;
76const int8_t MAJ14 = MAJ7 + OCT;
77
79struct Voicing {
80 int8_t offsets[kMaxChordKeyboardSize];
81 const char* supplementalName = "";
82};
83
85struct Chord {
86 const char* name;
87 NoteSet intervalSet;
88 Voicing voicings[kUniqueVoicings] = {0};
89};
90
91// ChordList
92extern const Chord kEmptyChord;
93extern const Chord kMajor;
94extern const Chord kMinor;
95extern const Chord k6;
96extern const Chord k2;
97extern const Chord k69;
98extern const Chord kSus2;
99extern const Chord kSus4;
100extern const Chord k7;
101extern const Chord k7Sus4;
102extern const Chord k7Sus2;
103extern const Chord kM7;
104extern const Chord kMinor7;
105extern const Chord kMinor2;
106extern const Chord kMinor4;
107extern const Chord kDim;
108extern const Chord kFullDim;
109extern const Chord kAug;
110extern const Chord kMinor6;
111extern const Chord kMinorMaj7;
112extern const Chord kMinor7b5;
113extern const Chord kMinor9b5;
114extern const Chord kMinor7b5b9;
115extern const Chord k9;
116extern const Chord kM9;
117extern const Chord kMinor9;
118extern const Chord k11;
119extern const Chord kM11;
120extern const Chord kMinor11;
121extern const Chord k13;
122extern const Chord kM13;
123extern const Chord kM13Sharp11;
124extern const Chord kMinor13;
125
126extern const std::array<const Chord, 10> majorChords;
127
128extern const std::array<const Chord, 10> minorChords;
129
130extern const std::array<const Chord, 10> dominantChords;
131
132extern const std::array<const Chord, 10> diminishedChords;
133
134extern const std::array<const Chord, 10> augmentedChords;
135
136extern const std::array<const Chord, 10> otherChords;
137
139class ChordList {
140public:
141 ChordList();
142
150 Voicing getChordVoicing(int8_t chordNo);
151
152 void adjustChordRowOffset(int8_t offset);
153 void adjustVoicingOffset(int8_t chordNo, int8_t offset);
154
155 Chord chords[kUniqueChords];
156 int8_t voicingOffset[kUniqueChords] = {0};
157 uint8_t chordRowOffset = 0;
158
159private:
160 int8_t validateChordNo(int8_t chordNo);
161};
162
163} // namespace deluge::gui::ui::keyboard
Definition note_set.h:20
Voicing getChordVoicing(int8_t chordNo)
Get a voicing for a chord with a given index. If the voicingOffset for that Chord is out of bounds,...
Definition chords.cpp:60
A chord is a name and a set of voicings.
Definition chords.h:85
A voicing is a set of offsets from the root note of a chord.
Definition chords.h:79