forked from sivabenepoivediamo/musicplusplus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrhythmGen.cpp
More file actions
46 lines (39 loc) · 1.77 KB
/
rhythmGen.cpp
File metadata and controls
46 lines (39 loc) · 1.77 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
#/**
* @file rhythmGen.cpp
* @brief Example: rhythm generation utilities (Euclidean, Clough-Douthett, etc.)
*
* Demonstrates generation of common rhythmic patterns and conversions to `Vectors`.
*
* @example
*/
#include "../src/rhythmGen.h"
int main() {
int steps = 16;
int events = 3;
int offset = 0;
int multiplicity = 5;
int repetitions = 3;
IntervalVector ev = euclidean(steps, events, offset);
cout << "Euclidean rhythm (" << steps << ", " << events << ", offset " << offset << "): " << ev << endl;
Vectors euc = Vectors::fromIntervals(ev.getData(), steps);
euc.printAll();
Vectors euc2 = euc.mode(-1);
cout << "Euclidean rhythm mode -1:" << endl;
euc2.transpose(1).printAll();
cout << "Euclidean rhythm rototranslate +2:" << endl;
euc2.rototranslatePositions(2).printAll();
PositionVector evPos = CloughDouthettVector(steps, events, offset);
cout << "Clough-Douthett rhythm (" << steps << ", " << events << ", offset " << offset << "): " << evPos << endl;
Vectors cld = Vectors::fromPositions(evPos.getData(), steps);
cld.printAll();
PositionVector dr = deepRhythm(steps, events, multiplicity, offset);
cout << "Deep rhythm (" << steps << ", " << events << ", multiplicity " << multiplicity << ", offset " << offset << "): " << dr << endl;
Vectors deep = Vectors::fromPositions(dr.getData(), steps);
deep.printAll();
cout << "Tihai pattern (" << steps << " steps, " << repetitions << " repetitions, pseudo: true, offset " << offset << "):" << endl;
BinaryVector bv = tihai(steps, repetitions, false, offset);
cout << bv << endl;
Vectors tih = Vectors::fromBinary(bv.getData(), offset, steps);
tih.printAll();
return 0;
}