Skip to content

Instantly share code, notes, and snippets.

@yaxu
Last active July 9, 2017 08:09
Show Gist options
  • Save yaxu/bf4efdf9fc06f6596a721c35dacdafac to your computer and use it in GitHub Desktop.
Save yaxu/bf4efdf9fc06f6596a721c35dacdafac to your computer and use it in GitHub Desktop.
Store difference between Ableton Link clock and POSIX system clock
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