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.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/schedule.h b/src/schedule.h new file mode 100644 index 0000000..5d77761 --- /dev/null +++ b/src/schedule.h
@@ -0,0 +1,44 @@
1#ifndef SCHEDULE_H_EF7B9D12
2#define SCHEDULE_H_EF7B9D12
3
4class Schedule {
5public:
6
7 explicit Schedule(
8 size_t bpm) :
9 bpm_(bpm),
10 tick_(60.0 / static_cast<double>(bpm_))
11 {
12 }
13
14 size_t getBPM() const
15 {
16 return bpm_;
17 }
18
19 void accumulate(double dt)
20 {
21 accum_ += dt;
22 }
23
24 bool step()
25 {
26 if (accum_ > tick_)
27 {
28 accum_ -= tick_;
29
30 return true;
31 } else {
32 return false;
33 }
34 }
35
36private:
37
38 size_t bpm_;
39 double tick_;
40 double accum_ = 0.0;
41
42};
43
44#endif /* end of include guard: SCHEDULE_H_EF7B9D12 */