#pragma once #include #include "config.h" #include "BPMDetect.h" // Virtual base class // Abstraction of BPM detection / setting class Click { public: Click(){} virtual ~Click(){} }; // Internally generated // Configured via: BPM class InternalClick: public Click { public: InternalClick(Config& config): m_bpm(config.get_bpm()){} virtual ~InternalClick(){} private: int m_bpm; }; // Generated from MIDI notes // Configured via channel and note to listen to class NoteClick: public Click { public: // signals boost::signals2::signal signal_click; boost::signals2::signal signal_bpm; NoteClick(Config& config): m_channel(config.get_midi_channel()), m_note(config.get_midi_note()), m_detect(1) { m_detect.signal_bpm.connect([&](int bpm){signal_bpm(bpm);}); } virtual ~NoteClick(){} // slots void receive_note(int channel, int note, uint64_t timestamp) { (void) timestamp; 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(): m_detect(24) { m_detect.signal_bpm.connect([&](int bpm){signal_bpm(bpm);}); } virtual ~ClockClick(){} // signals boost::signals2::signal signal_bpm; // slots void receive_clock() { m_detect.receive_event(); } private: BPMDetect m_detect; };