summaryrefslogtreecommitdiffhomepage
path: root/UI.h
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2025-01-04 13:48:34 +0100
committerRoland Reichwein <mail@reichwein.it>2025-01-04 13:48:34 +0100
commit39ec820c931b07bc0cec98add36f106a5965e137 (patch)
treed1f2f0feb07ff325f363e767181ffaeeab94e20b /UI.h
parentb2c35cdf69a9084806ac7930cf4475980d596cf6 (diff)
BPM detect
Diffstat (limited to 'UI.h')
-rw-r--r--UI.h32
1 files changed, 25 insertions, 7 deletions
diff --git a/UI.h b/UI.h
index a3c56e0..db2f2cc 100644
--- a/UI.h
+++ b/UI.h
@@ -8,38 +8,56 @@
#include <boost/signals2.hpp>
+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<clock_type> 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<void()> bpm_plus;
boost::signals2::signal<void()> bpm_minus;
boost::signals2::signal<void()> note_set_from_midi;
boost::signals2::signal<void()> mode;
+ boost::signals2::signal<void()> 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<clock_type> m_main_loops_timestamp;
+ IntervalCounter m_main_loops;
+ IntervalCounter m_midi_events;
std::chrono::time_point<clock_type> m_active_sensing_timestamp;
uint64_t m_midi_timestamp;
std::deque<std::pair<int,int>> m_midi_monitor;
+
+ int m_note_bpm;
+ int m_clock_bpm;
};