-
Notifications
You must be signed in to change notification settings - Fork 0
/
note.cpp
64 lines (52 loc) · 1.02 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
#include "note.h"
#include "synth.h"
#include <cmath>
note::note(int num){
on = true;
first = true;
ticks = 0;
rel_ticks = 0;
note_num = num;
frequency = num_to_freq(num);
velocity = 100;
note_length = 44100; //SETS NOTE LENGTH TO 1 SECOND PENDING MIDI IMPLEMENTATION
ndata = new float[synth::get_ksmps()];
}
note::note(int num, int vel){
on = true;
first = true;
ticks = 0;
rel_ticks = 0;
note_num = num;
frequency = num_to_freq(num);
velocity = vel;
note_length = 44100; //SETS NOTE LENGTH TO 1 SECOND PENDING MIDI IMPLEMENTATION
ndata = new float[synth::get_ksmps()];
}
note::~note(){
delete ndata;
}
void note::add_ticks(int add){
ticks += add;
}
void note::add_rel_ticks(int add){
rel_ticks += add;
}
int note::get_ticks(){
return ticks;
}
int note::get_rel_ticks(){
return rel_ticks;
}
double note::get_frequency(){
return frequency;
}
double note::num_to_freq(int num){
return std::pow(2, (num / 12.0)) * 8.1757989156;
}
bool note::is_on(){
return on;
}
void note::turn_off(){
on = false;
}