Introducing modes of Metronome synchronicity

This commit is contained in:
Bruno Herbelin
2021-11-24 21:48:51 +01:00
parent a8abd52afb
commit e123d139e4
7 changed files with 60 additions and 11 deletions

View File

@@ -2,7 +2,6 @@
#define METRONOME_H
#include <chrono>
#include <thread>
#include <functional>
class Metronome
@@ -14,6 +13,12 @@ class Metronome
public:
typedef enum {
SYNC_NONE = 0,
SYNC_BEAT,
SYNC_PHASE
} Synchronicity;
static Metronome& manager ()
{
// The only instance
@@ -41,10 +46,14 @@ public:
double beats () const;
double phase () const;
// mechanisms to delay execution to next beat of phase
// mechanisms to delay execution to next beat
std::chrono::microseconds timeToBeat();
void executeAtBeat( std::function<void()> f );
// mechanisms to delay execution to next phase
std::chrono::microseconds timeToPhase();
void executeAtPhase( std::function<void()> f );
size_t peers () const;
};