-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtempo.hh
56 lines (44 loc) · 975 Bytes
/
tempo.hh
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
#ifndef TEMPO_H
#define TEMPO_H
#include <map>
#include <string>
using std::pair;
using std::map;
using std::string;
typedef pair<int, int> tempo_min_max;
const int BPM_min = 40;
const int BPM_max = 208;
static map<tempo_min_max, string> tempo = {
{ { 40, 60 }, "Largo" },
{ { 60, 66 }, "Larghetto" },
{ { 66, 76 }, "Adagio" },
{ { 76, 108 }, "Andante" },
{ { 108, 120 }, "Moderato" },
{ { 120, 168 }, "Allegro" },
{ { 168, 200 }, "Presto" },
{ { 200, 208 }, "Prestissimo" }
};
static string get_tempo (int bpm) {
for (auto const& t : tempo) {
if (bpm < t.first.second) {
return t.second;
}
}
}
static double get_bpm (auto tempo_name) {
for (auto const& t : tempo) {
if (tempo_name == t.second) {
return (t.first.first + t.first.second) / 2;
}
}
}
int get_index (auto value) {
int i = 0;
for (auto const& t : tempo) {
if (value <= t.first.second) {
return i;
}
i++;
}
}
#endif // TEMPO_H