summary refs log tree commit diff stats
path: root/src/schedule.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/schedule.h')
-rw-r--r--src/schedule.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/schedule.h b/src/schedule.h index 5d77761..f7c5543 100644 --- a/src/schedule.h +++ b/src/schedule.h
@@ -5,17 +5,23 @@ class Schedule {
5public: 5public:
6 6
7 explicit Schedule( 7 explicit Schedule(
8 size_t bpm) : 8 double bpm) :
9 bpm_(bpm), 9 bpm_(bpm),
10 tick_(60.0 / static_cast<double>(bpm_)) 10 bps_(bpm_ / 60.0),
11 tick_(1.0 / bps_)
11 { 12 {
12 } 13 }
13 14
14 size_t getBPM() const 15 double getBPM() const
15 { 16 {
16 return bpm_; 17 return bpm_;
17 } 18 }
18 19
20 double getBPS() const
21 {
22 return bps_;
23 }
24
19 void accumulate(double dt) 25 void accumulate(double dt)
20 { 26 {
21 accum_ += dt; 27 accum_ += dt;
@@ -26,6 +32,7 @@ public:
26 if (accum_ > tick_) 32 if (accum_ > tick_)
27 { 33 {
28 accum_ -= tick_; 34 accum_ -= tick_;
35 beats_++;
29 36
30 return true; 37 return true;
31 } else { 38 } else {
@@ -33,11 +40,18 @@ public:
33 } 40 }
34 } 41 }
35 42
43 size_t getBeat() const
44 {
45 return beats_;
46 }
47
36private: 48private:
37 49
38 size_t bpm_; 50 double bpm_;
51 double bps_;
39 double tick_; 52 double tick_;
40 double accum_ = 0.0; 53 double accum_ = 0.0;
54 size_t beats_ = 0;
41 55
42}; 56};
43 57