summaryrefslogtreecommitdiffhomepage
path: root/InternalClick.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'InternalClick.cpp')
-rw-r--r--InternalClick.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/InternalClick.cpp b/InternalClick.cpp
index 33654fd..e0c757e 100644
--- a/InternalClick.cpp
+++ b/InternalClick.cpp
@@ -1,5 +1,10 @@
#include "InternalClick.h"
+#include "log.h"
+#include "debug.h"
+
+#include <fmt/format.h>
+
InternalClick::InternalClick(Config& config):
m_config{config},
m_timestamp{clock_type::now()}
@@ -12,8 +17,10 @@ void InternalClick::run_cyclic_50ms()
std::chrono::duration<double> duration{60.0 / static_cast<double>(m_config.get_bpm())};
if (now - m_timestamp > duration) {
- m_timestamp = now;
- signal_click(0); // offset
+ std::chrono::duration<double> offset = now - m_timestamp - duration;
+ m_timestamp = now - std::chrono::duration_cast<clock_type::duration>(offset);
+ signal_click(offset);
+ debug_cout << fmt::format("offset={}", offset.count()) << std::endl;
}
}