Last active
July 9, 2017 08:09
-
-
Save yaxu/bf4efdf9fc06f6596a721c35dacdafac to your computer and use it in GitHub Desktop.
Store difference between Ableton Link clock and POSIX system clock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static long diff = 0; | |
const auto time = state.link.clock().micros(); | |
unsigned long milliseconds_since_epoch = | |
std::chrono::duration_cast<std::chrono::milliseconds> | |
(std::chrono::system_clock::now().time_since_epoch()).count(); | |
if (diff == 0) { | |
// POSIX is millis and Link is micros.. Not sure if that `+500` helps | |
diff = ((milliseconds_since_epoch*1000 + 500) - std::chrono::microseconds(time).count()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment