As I understand it, the audio context has:
.currentTime, the time at the beginning of the next schedule-able 128-sample frame buffer (previous buffers having already been sent).baseLatency, the time it takes to transfer scheduled audio from WebAudio land to the OS.getOutputTimestamp().contextTime, a timestamp for the sample frame currently being handed to the OS
By this understanding, context.getOutputTimestamp().contextTime should never be less than context.currentTime - context.baseLatency.
But it is! In my tests in Chrome on a fast MacBook it is less than that by as much as -0.025s. That's > 1000 sample frames behind.
const context = new AudioContext();
// Let the audio clock settle
setTimeout(function() {
const currentTime = context.currentTime;
const contextTime = context.getOutputTimestamp().contextTime;
console.assert(
contextTime > (currentTime - context.baseLatency),
'contextTime', contextTime,
'currentTime', currentTime,
'baseLatency', context.baseLatency,
'contextTime - (currentTime - baseLatency)', contextTime - (currentTime - context.baseLatency)
);
}, 1000);
Are my assumptions about what it should do skewed, or is the API lying to me about it's baseLatency?