From 39ec820c931b07bc0cec98add36f106a5965e137 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sat, 4 Jan 2025 13:48:34 +0100 Subject: BPM detect --- UI.h | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'UI.h') diff --git a/UI.h b/UI.h index a3c56e0..db2f2cc 100644 --- a/UI.h +++ b/UI.h @@ -8,38 +8,56 @@ #include +using clock_type = std::chrono::high_resolution_clock; + +struct IntervalCounter +{ +public: + IntervalCounter(); + int get_count_per_second(); + void count(); + +private: + uint64_t m_count{}; + uint64_t m_count_checkpoint{}; + std::chrono::time_point m_checkpoint_timestamp{}; +}; + class UI { public: - using clock_type = std::chrono::high_resolution_clock; UI(Config& config); void draw(); - // signals + // signals, from user input boost::signals2::signal bpm_plus; boost::signals2::signal bpm_minus; boost::signals2::signal note_set_from_midi; boost::signals2::signal mode; + boost::signals2::signal output; // slots void count_main_loops(); + void count_midi_events(); void slot_active_sensing(); void slot_midi_note(int channel, int note, uint64_t timestamp); + void slot_note_bpm(int bpm); + void slot_clock_bpm(int bpm); private: Config& m_config; - int get_main_loops_per_second(); - - uint64_t m_main_loops; - uint64_t m_main_loops_checkpoint; - std::chrono::time_point m_main_loops_timestamp; + IntervalCounter m_main_loops; + IntervalCounter m_midi_events; std::chrono::time_point m_active_sensing_timestamp; uint64_t m_midi_timestamp; std::deque> m_midi_monitor; + + int m_note_bpm; + int m_clock_bpm; }; -- cgit v1.2.3