diff options
author | Roland Reichwein <mail@reichwein.it> | 2025-01-04 18:27:21 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2025-01-04 18:27:21 +0100 |
commit | dbe72ddb8eb215de6d38cd01ed201704ab315a4f (patch) | |
tree | 8fda403192090d8560bca9fe5a2e9f9e4e1a7e41 /InternalClick.cpp | |
parent | 2e793141e5434043205763c70d3a597cf2d78eeb (diff) |
Compensate phase
Diffstat (limited to 'InternalClick.cpp')
-rw-r--r-- | InternalClick.cpp | 11 |
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; } } |