-
Notifications
You must be signed in to change notification settings - Fork 0
/
notes.h
146 lines (120 loc) · 2.59 KB
/
notes.h
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#ifndef NOTES_H
#define NOTES_H
#include <string>
#include <vector>
#include <array>
#include <map>
typedef std::map<char, double> MNoteFreq;
//C++11 initialization of a map, +100 EXP
const MNoteFreq freqTable {
{'c', 130.8127826503},
{'d', 146.8323839587},
{'e', 164.8137784564},
{'f', 174.6141157165},
{'g', 195.9977179909},
{'a', 220.0000000000},
{'b', 246.9416506281},
{'h', 246.9416506281}
};
// for parts of ligature(tie)
// e.g. 1c+2+4.+8..+16..t
class NoteDuration
{
protected:
unsigned short value; //1, 2, 4, 8, 16, 32(, ...)
bool dot, dot2;
bool triplet;
double duration; //in ms
unsigned short tempo;
public:
NoteDuration(); //kvuli inicializaci pole durations v Ligature
NoteDuration(unsigned short v, bool d, bool d2, bool t);
unsigned short getValue();
bool getDot();
bool getDot2();
bool getTriplet();
~NoteDuration(){}
};
// for notes in chord type no.1: 4<a1 #c1 e1>
class NotePitch
{
protected:
bool sharp;
char note;
short octave; //from -1(great octave) to 3
unsigned short pitch; //in Hz
bool isNote(char c);
public:
NotePitch(); //kvuli inicializaci pole pitches v Chord
NotePitch(bool s, char n, short o);
bool getSharp();
char getNote();
short getOctave();
double getPitch();
~NotePitch(){}
};
//e.g. 16..#a2t[Hello ]
class Note : public NoteDuration, public NotePitch //multiple inheritance, +500 EXP
{
protected:
std::string word;
public:
Note(): //kvuli inicializaci pole notes v DifferentDurationsChord
NoteDuration(),
NotePitch()
{}
Note(unsigned short v,
bool d,
bool d2,
bool t,
bool s,
char n,
short o,
std::string w):
NoteDuration(v, d, d2, t),
NotePitch(s, n, o),
word(w)
{}
std::array<NoteDuration, 9> *ligature;
std::array<NotePitch, 6> *chord;
std::array<Note, 6> *ddchord; //different durations chord
std::string getWord();
~Note(){}
};
struct Rest : public Note
{
Rest(unsigned short v,
bool d,
bool d2,
bool t):
Note(v, d, d2, t, false, '-', -2, "")
{}
~Rest(){}
};
struct Tempo
{
double BPM; //beats per minute
unsigned short position; //after which note tempo begins
Tempo(){}
~Tempo(){}
};
//8..t=280
struct ValuedTempo : public Tempo
{
unsigned short tempo; //280
NoteDuration duration; //8..t
ValuedTempo(){}
ValuedTempo(unsigned short v, bool d, bool d2, bool t);
~ValuedTempo(){}
};
class Song
{
// private:
public:
std::vector<Note> melody;
std::vector<Tempo> tempos;
public:
Song(){}
~Song(){}
};
#endif