-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbluesUtils.cpp
More file actions
executable file
·83 lines (75 loc) · 1.64 KB
/
Copy pathbluesUtils.cpp
File metadata and controls
executable file
·83 lines (75 loc) · 1.64 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
81
82
83
// Copyright CS 312 free open source
/***************************************************************
*
* CS 312
* 7.2 Homework 22
* bluesUtils.cpp
* TranKiet trank
* TaoDuo taod
* 2/17/2016
*
***************************************************************/
#ifndef BLUESUTILS_H_
#include "bluesUtils.h"
#endif
#include <random>
int rand_range(int lo, int hi) {
std::random_device rd;
std::default_random_engine dre{rd()};
std::uniform_int_distribution<int> dist{lo, hi};
return dist(dre);
}
int weighted_dist() {
// const int k0 = 4; // 0
// const int k1 = 1; // 3
// const int k2 = 1; // 4
// const int k3 = 2; // 7
// const int k4 = 1; // 9
// const int k5 = 2; // 10
// const int k0 = 1;
// const int k1 = 0;
// const int k2 = 0;
// const int k3 = 0;
// const int k4 = 0;
// const int k5 = 0;
const int k0 = 2;
const int k1 = 1;
const int k2 = 0;
const int k3 = 0;
const int k4 = 0;
const int k5 = 0;
std::random_device rd;
std::default_random_engine engine(rd());
std::discrete_distribution<int> distributionA{k0, k1, k2, k3, k4, k5};
int n = distributionA(engine);
return kBLUES_SCALE.at(n);
}
uint16_t get_note_offset(int meas_num, uint16_t start_note) {
uint16_t offset;
switch (meas_num % 12) {
case 1:
case 2:
case 3:
case 4:
case 7:
case 8:
case 11:
offset = start_note;
break;
case 5:
case 6:
case 10:
offset = start_note + 5;
break;
case 9:
offset = start_note + 7;
break;
case 0:
offset = start_note - 5;
break;
default:
offset = start_note;
break;
}
return offset;
}