summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Click.h24
-rw-r--r--main.cpp16
2 files changed, 13 insertions, 27 deletions
diff --git a/Click.h b/Click.h
index 4af693e..6d3d871 100644
--- a/Click.h
+++ b/Click.h
@@ -5,30 +5,20 @@
#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
+class InternalClick
{
public:
- InternalClick(Config& config): m_bpm(config.get_bpm()){}
- virtual ~InternalClick(){}
+ InternalClick(Config& config): m_config(config){}
private:
- int m_bpm;
+ Config& m_config;
};
// Generated from MIDI notes
// Configured via channel and note to listen to
-class NoteClick: public Click
+class NoteClick
{
public:
// signals
@@ -43,8 +33,6 @@ public:
m_detect.signal_bpm.connect([&](int bpm){signal_bpm(bpm);});
}
- virtual ~NoteClick(){}
-
// slots
void receive_note(int channel, int note, uint64_t timestamp)
{
@@ -64,7 +52,7 @@ private:
};
// Generated from MIDI Clock
-class ClockClick: public Click
+class ClockClick
{
public:
ClockClick(): m_detect(24)
@@ -72,8 +60,6 @@ public:
m_detect.signal_bpm.connect([&](int bpm){signal_bpm(bpm);});
}
- virtual ~ClockClick(){}
-
// signals
boost::signals2::signal<void(int)> signal_bpm;
diff --git a/main.cpp b/main.cpp
index 5c8d345..4a5f698 100644
--- a/main.cpp
+++ b/main.cpp
@@ -50,9 +50,9 @@ int main(void)
Config config;
- std::shared_ptr<ClockClick> clock_click = std::make_shared<ClockClick>();
- std::shared_ptr<NoteClick> note_click = std::make_shared<NoteClick>(config);
- std::shared_ptr<InternalClick> internal_click = std::make_shared<InternalClick>(config);
+ ClockClick clock_click;
+ NoteClick note_click(config);
+ InternalClick internal_click(config);
MIDI midi;
PCM pcm;
@@ -72,17 +72,17 @@ int main(void)
//
// Signal-Slot Connections:
//
- midi.signal_note.connect([&](int channel, int note, uint64_t timestamp){note_click->receive_note(channel, note, timestamp);});
- note_click->signal_click.connect([&](){pcm.click();});
- note_click->signal_bpm.connect([&](int bpm){ui.slot_note_bpm(bpm);});
- clock_click->signal_bpm.connect([&](int bpm){ui.slot_clock_bpm(bpm);});
+ midi.signal_note.connect([&](int channel, int note, uint64_t timestamp){note_click.receive_note(channel, note, timestamp);});
+ note_click.signal_click.connect([&](){pcm.click();});
+ note_click.signal_bpm.connect([&](int bpm){ui.slot_note_bpm(bpm);});
+ clock_click.signal_bpm.connect([&](int bpm){ui.slot_clock_bpm(bpm);});
midi.signal_active_sensing.connect([&](){ui.slot_active_sensing();});
timer_500ms.elapsed.connect([&](){ui.draw();});
signal_count_loops.connect([&](){ui.count_main_loops();});
midi.signal_count_events.connect([&](){ui.count_midi_events();});
timer_10min.elapsed.connect([&](){config.persist();});
midi.signal_note.connect([&](int channel, int note, uint64_t timestamp){ui.slot_midi_note(channel, note, timestamp);});
- midi.signal_clock.connect([&](){clock_click->receive_clock();});
+ midi.signal_clock.connect([&](){clock_click.receive_clock();});
midi.flush();