-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchordClass.cpp
More file actions
65 lines (52 loc) · 2.3 KB
/
chordClass.cpp
File metadata and controls
65 lines (52 loc) · 2.3 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
#include "../src/chord.h"
/**
* @file chordClass.cpp
* @brief Example: chord class usage and parameter manipulation
*
* Demonstrates construction of chords from positions and intervals,
* updating parameters, and inversion behavior.
*
*/
int main() {
PositionVector cMajorScale({0, 2, 4, 5, 7, 9, 11}, 12);
IntervalVector majorScaleIntervals({2, 2, 1, 2, 2, 2, 1}, 0, 12);
PositionVector triadDegrees({0, 2, 4}, 12);
IntervalVector grouping({2}, 0, 12);
int voices = 3;
int scaleShift = 0;
int degreesShift = 0;
int rot = 1;
// Adjust scales
cMajorScale = cMajorScale + scaleShift;
majorScaleIntervals.setOffset(majorScaleIntervals.getOffset() + scaleShift);
// Create ChordParams
ChordParams params;
params.withShift(degreesShift)
.withPosition(rot)
.withPreVoices(voices);
// Using Chord class - Position source, position criterion
Chord chord1(cMajorScale, triadDegrees, params);
std::cout << "Position source, position criterion: " << chord1.toPositions() << std::endl;
// Using Chord class - Position source, interval criterion
Chord chord2(cMajorScale, grouping, params);
std::cout << "Position source, interval criterion: " << chord2.toPositions() << std::endl;
// Using Chord class - Interval source, interval criterion
Chord chord3(majorScaleIntervals, grouping, params);
std::cout << "Interval source, interval criterion: " << chord3.toIntervals() << std::endl;
// Using Chord class - Interval source, position criterion
Chord chord4(majorScaleIntervals, triadDegrees, params);
std::cout << "Interval source, position criterion: " << chord4.toIntervals() << std::endl;
// Example of updating parameters
chord1.setRotationOrRototrans(2);
std::cout << "\nAfter changing rotation to 2: " << chord1.toPositions() << std::endl;
// Example with inversion
ChordParams invertedParams;
invertedParams.withShift(0)
.withPosition(0)
.withPreVoices(3)
.withInvert(true)
.withAxis(6);
Chord invertedChord(cMajorScale, triadDegrees, invertedParams);
std::cout << "\nInverted chord: " << invertedChord.toPositions() << std::endl;
return 0;
}