mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 18:59:59 +01:00
Introducing modes of Metronome synchronicity
This commit is contained in:
@@ -72,6 +72,13 @@ namespace ableton
|
||||
return sessionState.phaseAtTime(now(), mQuantum);
|
||||
}
|
||||
|
||||
std::chrono::microseconds timeNextPhase() const
|
||||
{
|
||||
auto sessionState = mLink.captureAppSessionState();
|
||||
double beat = ceil(sessionState.phaseAtTime(now(), mQuantum));
|
||||
return sessionState.timeAtBeat(beat, mQuantum);
|
||||
}
|
||||
|
||||
double tempo() const
|
||||
{
|
||||
auto sessionState = mLink.captureAppSessionState();
|
||||
@@ -218,6 +225,11 @@ std::chrono::microseconds Metronome::timeToBeat()
|
||||
return engine_.timeNextBeat() - engine_.now();
|
||||
}
|
||||
|
||||
std::chrono::microseconds Metronome::timeToPhase()
|
||||
{
|
||||
return engine_.timeNextPhase() - engine_.now();
|
||||
}
|
||||
|
||||
void delay(std::function<void()> f, std::chrono::microseconds us)
|
||||
{
|
||||
std::this_thread::sleep_for(us);
|
||||
@@ -229,6 +241,11 @@ void Metronome::executeAtBeat( std::function<void()> f )
|
||||
std::thread( delay, f, timeToBeat() ).detach();
|
||||
}
|
||||
|
||||
void Metronome::executeAtPhase( std::function<void()> f )
|
||||
{
|
||||
std::thread( delay, f, timeToPhase() ).detach();
|
||||
}
|
||||
|
||||
size_t Metronome::peers() const
|
||||
{
|
||||
return link_.numPeers();
|
||||
|
||||
Reference in New Issue
Block a user