From dbe72ddb8eb215de6d38cd01ed201704ab315a4f Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 4 Jan 2025 18:27:21 +0100 Subject: Compensate phase --- InternalClick.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'InternalClick.cpp') 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 + InternalClick::InternalClick(Config& config): m_config{config}, m_timestamp{clock_type::now()} @@ -12,8 +17,10 @@ void InternalClick::run_cyclic_50ms() std::chrono::duration duration{60.0 / static_cast(m_config.get_bpm())}; if (now - m_timestamp > duration) { - m_timestamp = now; - signal_click(0); // offset + std::chrono::duration offset = now - m_timestamp - duration; + m_timestamp = now - std::chrono::duration_cast(offset); + signal_click(offset); + debug_cout << fmt::format("offset={}", offset.count()) << std::endl; } } -- cgit v1.2.3