summaryrefslogtreecommitdiffhomepage
path: root/Click.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 /Click.h
parentb2c35cdf69a9084806ac7930cf4475980d596cf6 (diff)
BPM detect
Diffstat (limited to 'Click.h')
-rw-r--r--Click.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/Click.h b/Click.h
index 7861d33..4af693e 100644
--- a/Click.h
+++ b/Click.h
@@ -3,6 +3,7 @@
#include <boost/signals2.hpp>
#include "config.h"
+#include "BPMDetect.h"
// Virtual base class
// Abstraction of BPM detection / setting
@@ -30,17 +31,20 @@ private:
class NoteClick: public Click
{
public:
+ // signals
+ boost::signals2::signal<void()> signal_click;
+ boost::signals2::signal<void(int)> signal_bpm;
+
NoteClick(Config& config):
m_channel(config.get_midi_channel()),
- m_note(config.get_midi_note())
+ m_note(config.get_midi_note()),
+ m_detect(1)
{
+ m_detect.signal_bpm.connect([&](int bpm){signal_bpm(bpm);});
}
virtual ~NoteClick(){}
- // signals
- boost::signals2::signal<void()> signal_click;
-
// slots
void receive_note(int channel, int note, uint64_t timestamp)
{
@@ -48,19 +52,38 @@ public:
if (true || (channel == m_channel && note == m_note)) {
signal_click();
+ m_detect.receive_event();
}
}
private:
int m_channel;
int m_note;
+
+ BPMDetect m_detect;
};
// Generated from MIDI Clock
class ClockClick: public Click
{
public:
- ClockClick(){}
+ ClockClick(): m_detect(24)
+ {
+ m_detect.signal_bpm.connect([&](int bpm){signal_bpm(bpm);});
+ }
+
virtual ~ClockClick(){}
+
+ // signals
+ boost::signals2::signal<void(int)> signal_bpm;
+
+ // slots
+ void receive_clock()
+ {
+ m_detect.receive_event();
+ }
+
+private:
+ BPMDetect m_detect;
};