diff options
author | Roland Reichwein <mail@reichwein.it> | 2025-01-04 17:51:59 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2025-01-04 17:51:59 +0100 |
commit | 2e793141e5434043205763c70d3a597cf2d78eeb (patch) | |
tree | 8b6a14273fcc98ff7bf118cf63574257a637547f /InternalClick.cpp | |
parent | 624a69994d89c71b1ce59dd3b2117a235400be2f (diff) |
Separate clocks
Diffstat (limited to 'InternalClick.cpp')
-rw-r--r-- | InternalClick.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/InternalClick.cpp b/InternalClick.cpp new file mode 100644 index 0000000..33654fd --- /dev/null +++ b/InternalClick.cpp @@ -0,0 +1,19 @@ +#include "InternalClick.h" + +InternalClick::InternalClick(Config& config): + m_config{config}, + m_timestamp{clock_type::now()} +{ +} + +void InternalClick::run_cyclic_50ms() +{ + std::chrono::time_point<clock_type> now = clock_type::now(); + + 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 + } +} + |