forked from sivabenepoivediamo/musicplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchordNames.cpp
More file actions
80 lines (58 loc) · 2.4 KB
/
chordNames.cpp
File metadata and controls
80 lines (58 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "../src/chordNames.h"
/**
* * @file chordNames.cpp
* @brief Example: Analyzing MIDI note sets to determine chord names
* Demonstrates how to use the chord analysis functions to identify chord names
* from given sets of MIDI note numbers.
*/
int main() {
vector<vector<int>> testChords = {
{60, 64, 67}, // C major
{60, 63, 67}, // C minor
{60, 64, 68}, // C augmented
{60, 63, 66}, // C diminished
{60, 64, 67, 71}, // Cmaj7
{60, 64, 67, 70}, // C7
{60, 63, 67, 70}, // Cm7
{60, 63, 66, 69}, // Cdim7
{60, 63, 66, 70}, // Cm7b5
{60, 63, 67, 71}, // Cm/maj7
{60, 65, 67}, // Csus4
{60, 62, 67}, // Csus2
{60, 65, 67, 71}, // Cmaj7sus4
{60, 65, 67, 70}, // C7sus4
{60, 64, 67, 70, 74}, // C9
{60, 64, 67, 70, 73}, // C7b9
{60, 64, 67, 71, 74}, // Cmaj9
{60, 64, 67, 70, 74, 77}, // C9/11
{60, 64, 67, 70, 74, 78}, // C9/#11
{60, 64, 67, 70, 74, 77, 81}, // C9/11/13
{60, 64, 66}, // Cmaj b5
{60, 64, 68, 71}, // Caug/maj7
{60, 64, 68, 70}, // Caug7
{60, 64, 67, 69}, // C6
{60, 62, 64, 67}, // Cadd2
{60, 64, 65, 67}, // Cadd4
{60, 64, 67, 70, 73, 78}, // C7b9#11
{60, 63, 66, 70, 74}, // Cm7b5 add9
{62, 65, 69, 72}, // Dm7, Fmaj 6, Amin b6 (omit 5), C 2 4 6
{67, 71, 74, 77}, // G7, Bdim b6, Dmin 4 6, F 2 4 6
{60, 65, 67, 70}, // C7sus4
{60, 67, 70}, // C7 (omit 3)
};
for (size_t chordIdx = 0; chordIdx < testChords.size(); chordIdx++) {
const auto& chord = testChords[chordIdx];
cout << "Chord " << (chordIdx + 1) << ": ";
for (int note : chord) {
cout << note << " ";
}
cout << "\n";
for (size_t i = 0; i < chord.size(); i++) {
ChordAnalysis result = analyzeChord(chord, i);
string chordName = buildChordName(result);
cout << " " << chordName << "\n";
}
cout << "\n";
}
return 0;
}