-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathNote.cpp
95 lines (78 loc) · 1.37 KB
/
Note.cpp
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
#include <cmath> //for pow(x, y)
#include <utility>
#include <vector>
#include "Note.h"
Note::Note()
{
frequency_ = 9;
duration_ = 1;
volume_ = MAX_AMPLITUDE / 4;
}
Note::Note(int frequency, double duration, double volume)
{
frequency_ = frequency;
duration_ = duration;
volume_ = volume;
}
int Note::getFrequency() const
{
return frequency_;
}
double Note::getRealFrequency() const
{
return pow(2, 1.0 * (frequency_ - 9) / 12) * REAL_FREQUENCY;
}
double Note::getDuration() const
{
return duration_;
}
double Note::getVolume() const
{
return volume_;
}
void Note::setVolume(double volume)
{
volume_ = volume;
}
Chord::Chord(Note note, Mode mode)
{
note_ = note;
mode_ = mode;
}
Mode Chord::getMode() const
{
return mode_;
}
Note Chord::getNote() const
{
return note_;
}
int Chord::getFrequency() const
{
return note_.getFrequency();
}
double Chord::getDuration() const
{
return note_.getDuration();
}
double Chord::getVolume() const
{
return note_.getVolume();
}
Melody::Melody(const noteSequence& sequence1, const noteSequence& sequence2, double number) :
accompaniment_(sequence1),
mainTheme_(sequence2),
secondsInBar_(number)
{ }
noteSequence Melody::getAccompaniment() const
{
return accompaniment_;
}
noteSequence Melody::getMainTheme() const
{
return mainTheme_;
}
double Melody::getSecondsInBar() const
{
return secondsInBar_;
}