-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoteDurFunction.txt
More file actions
46 lines (33 loc) · 1.13 KB
/
noteDurFunction.txt
File metadata and controls
46 lines (33 loc) · 1.13 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
//Written by Colton Arnold Fall 2025
fun void noteDur() {
32 => int length;
[0,0,0,0,1,2,1,2,] @=> int observations[];
hmm.train(2, 3, observations);
int results1[length];
hmm.generate(length, results1);
0.0 => float counter;
for (0 => int i; counter < 16 && i < length; i++) {
float dur;
if (results1[i] == 0) { 0.5 => dur; }
else if (results1[i] == 1) { 1.0 => dur; }
else if (results1[i] == 2) { 2.0 => dur; }
else { continue; }
counter + dur => counter;
durArray << dur;
chout <= results1[i] <= " ";
}
chout <= IO.newline();
if (counter > 16.0) {
counter - 16.0 => float remainder;
<<<"Over by:", remainder>>>;
// Remove last duration
durArray[durArray.size() - 1]=> float lastDur;
counter - lastDur => counter;
// Add back trimmed duration if remainder is less than the last duration
if (lastDur - remainder > 0.0) {
durArray << (lastDur - remainder);
counter + (lastDur - remainder) => counter;
}
}
<<<"Final duration sum:", counter>>>;
}