-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchordTest.cpp
More file actions
37 lines (35 loc) · 1.62 KB
/
chordTest.cpp
File metadata and controls
37 lines (35 loc) · 1.62 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
/**
* @file chordTest.cpp
* @brief Example: small tests for chord helper functions
*
* Verifies chord construction from position and interval sources and prints results.
*
* @example
*/
#include "../src/chord.h"
int main() {
auto start = std::chrono::high_resolution_clock::now();
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 = 5;
int scaleShift = 0;
int degreesShift = 0;
int rot = 0;
int pos = 0;
cMajorScale = cMajorScale + scaleShift;
majorScaleIntervals.setOffset(majorScaleIntervals.getOffset() + scaleShift);
PositionVector triad = chord(cMajorScale, triadDegrees, degreesShift, rot, voices, pos);
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double, std::milli> elapsed = end - start;
cout << "Elapsed time: " << elapsed.count() << " ms\n\n";
cout << "Position source, position criterion: " << triad << endl;
PositionVector triad2 = chord(cMajorScale, grouping, degreesShift, rot, voices, pos);
cout << "Position source, interval criterion: " << triad2 << endl;
IntervalVector triadIv = chord(majorScaleIntervals, grouping, degreesShift, rot, voices, pos);
cout << "Interval source, interval criterion: " << triadIv << endl;
IntervalVector triadIv2 = chord(majorScaleIntervals, triadDegrees, degreesShift, rot, voices, pos);
cout << "Interval source, position criterion: " << triadIv2 << endl;
return 0;
}