Control Surface
develop
MIDI Control Surface library for Arduino
Toggle main menu visibility
Loading...
Searching...
No Matches
src
MIDI_Constants
Chords
Chords.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Intervals.hpp
"
4
#include <
Def/Def.hpp
>
5
6
BEGIN_CS_NAMESPACE
7
8
class
IChord
{
9
public
:
10
virtual
~IChord
() =
default
;
11
virtual
const
int8_t *
begin
()
const
= 0;
12
virtual
const
int8_t *
end
()
const
= 0;
13
};
14
15
template
<u
int
8_t N>
16
class
Chord
:
public
IChord
{
17
public
:
18
Chord
(
const
Array<int8_t, N>
&
offsets
) :
offsets
(
offsets
) {}
19
const
int8_t *
begin
()
const override
{
return
offsets
.begin(); }
20
const
int8_t *
end
()
const override
{
return
offsets
.end(); }
21
22
template
<u
int
8_t M>
23
Chord<N + M>
operator+
(
const
Chord<M>
&rhs)
const
{
24
return
{
cat
(this->
getOffsets
(), rhs.
getOffsets
())};
25
}
26
27
Chord<N + 1>
operator+
(int8_t rhs)
const
{
28
return
*
this
+
Chord<1>
{{rhs}};
29
}
30
31
const
Array<int8_t, N>
getOffsets
()
const
{
return
offsets
; }
32
33
private
:
34
Array<int8_t, N>
offsets
;
35
};
36
39
41
namespace
Chords
{
42
43
using namespace
Intervals
;
44
45
const
Chord<2>
Major
= {{
M3
,
P5
}};
46
const
Chord<2>
MajorFirstInv
= {{
M3
,
P5
-
P8
}};
// First inversion
47
const
Chord<2>
MajorSecondInv
= {{
M3
-
P8
,
P5
-
P8
}};
// Second inversion
48
49
const
Chord<2>
Minor
= {{
m3
,
P5
}};
50
const
Chord<2>
MinorFirstInv
= {{
m3
,
P5
-
P8
}};
51
const
Chord<2>
MinorSecondInv
= {{
m3
-
P8
,
P5
-
P8
}};
52
53
const
Chord<2>
Diminished
= {{
m3
,
d5
}};
54
const
Chord<2>
Augmented
= {{
m3
,
m6
}};
55
56
const
Chord<3>
DominantSeventh
= {{
M3
,
P5
,
m7
}};
57
const
Chord<3>
MajorSeventh
= {{
M3
,
P5
,
M7
}};
58
59
}
// namespace Chords
60
62
namespace
Bass
{
63
64
using namespace
Intervals
;
65
66
const
Chord<1>
Single
= {{-
P8
}};
67
const
Chord<2>
Double
= {{-
P8
, -2 *
P8
}};
68
const
Chord<3>
Triple
= {{-
P8
, -2 *
P8
, -3 *
P8
}};
69
70
}
// namespace Bass
71
73
74
END_CS_NAMESPACE
Def.hpp
Intervals.hpp
END_CS_NAMESPACE
#define END_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:14
BEGIN_CS_NAMESPACE
#define BEGIN_CS_NAMESPACE
Definition
Settings/NamespaceSettings.hpp:11
Chord
Definition
Chords.hpp:16
Chord::operator+
Chord< N+1 > operator+(int8_t rhs) const
Definition
Chords.hpp:27
Chord::offsets
Array< int8_t, N > offsets
Definition
Chords.hpp:34
Chord::operator+
Chord< N+M > operator+(const Chord< M > &rhs) const
Definition
Chords.hpp:23
Chord::Chord
Chord(const Array< int8_t, N > &offsets)
Definition
Chords.hpp:18
Chord::getOffsets
const Array< int8_t, N > getOffsets() const
Definition
Chords.hpp:31
Chord::end
const int8_t * end() const override
Definition
Chords.hpp:20
Chord::begin
const int8_t * begin() const override
Definition
Chords.hpp:19
IChord
Definition
Chords.hpp:8
IChord::~IChord
virtual ~IChord()=default
IChord::begin
virtual const int8_t * begin() const =0
IChord::end
virtual const int8_t * end() const =0
AH::cat
Array< T, M+N > cat(const Array< T, M > &a, const Array< T, N > &b)
Concatenate two arrays.
Definition
ArrayHelpers.hpp:197
Bass
Predefined Chord constants with bass notes.
Definition
Chords.hpp:62
Bass::Triple
const Chord< 3 > Triple
Definition
Chords.hpp:68
Bass::Double
const Chord< 2 > Double
Definition
Chords.hpp:67
Bass::Single
const Chord< 1 > Single
Definition
Chords.hpp:66
Chords
Predefined Chord constants.
Definition
Chords.hpp:41
Chords::MajorSecondInv
const Chord< 2 > MajorSecondInv
Definition
Chords.hpp:47
Chords::Augmented
const Chord< 2 > Augmented
Definition
Chords.hpp:54
Chords::MajorFirstInv
const Chord< 2 > MajorFirstInv
Definition
Chords.hpp:46
Chords::DominantSeventh
const Chord< 3 > DominantSeventh
Definition
Chords.hpp:56
Chords::MajorSeventh
const Chord< 3 > MajorSeventh
Definition
Chords.hpp:57
Chords::MinorSecondInv
const Chord< 2 > MinorSecondInv
Definition
Chords.hpp:51
Chords::Minor
const Chord< 2 > Minor
Definition
Chords.hpp:49
Chords::MinorFirstInv
const Chord< 2 > MinorFirstInv
Definition
Chords.hpp:50
Chords::Major
const Chord< 2 > Major
Definition
Chords.hpp:45
Chords::Diminished
const Chord< 2 > Diminished
Definition
Chords.hpp:53
Intervals
Definition
Intervals.hpp:5
Intervals::m3
constexpr int8_t m3
Minor third.
Definition
Intervals.hpp:10
Intervals::P8
constexpr int8_t P8
Perfect octave.
Definition
Intervals.hpp:19
Intervals::d5
constexpr int8_t d5
Diminished fifth.
Definition
Intervals.hpp:13
Intervals::m7
constexpr int8_t m7
Minor seventh.
Definition
Intervals.hpp:17
Intervals::M7
constexpr int8_t M7
Major seventh.
Definition
Intervals.hpp:18
Intervals::M3
constexpr int8_t M3
Major third.
Definition
Intervals.hpp:11
Intervals::m6
constexpr int8_t m6
Minor sixth.
Definition
Intervals.hpp:15
Intervals::P5
constexpr int8_t P5
Perfect fifth.
Definition
Intervals.hpp:14
AH::Array
An array wrapper for easy copying, comparing, and iterating.
Definition
Array.hpp:32
Generated by
1.17.0