From 090669fddadeeb835c694ae959ccaca6c73f378a Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Fri, 25 Aug 2023 15:43:42 +0300 Subject: [PATCH] Go back to currentTime for latency calculations --- src/TransportNode.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/TransportNode.js b/src/TransportNode.js index 8ef0c3a..0d33e63 100644 --- a/src/TransportNode.js +++ b/src/TransportNode.js @@ -35,13 +35,12 @@ export class TransportNode extends AudioWorkletNode { if (this.nextPulsePosition !== nextPulsePosition) { this.nextPulsePosition = nextPulsePosition; setTimeout(() => { - const now = this.logicalTime; + const now = this.app.audioContext.currentTime; this.app.clock.time_position = futureTimeStamp; - //this.$clock.innerHTML = `[${futureTimeStamp.bar}:${futureTimeStamp.beat}:${zeroPad(futureTimeStamp.pulse, '2')}]`; tryEvaluate(this.app, this.app.global_buffer); this.hasBeenEvaluated = true; this.currentPulsePosition = nextPulsePosition; - const then = this.logicalTime; + const then = this.app.audioContext.currentTime; this.lastLatencies[this.indexOfLastLatencies] = then - now; this.indexOfLastLatencies = (this.indexOfLastLatencies + 1) % this.lastLatencies.length; const averageLatency = this.lastLatencies.reduce((a, b) => a + b) / this.lastLatencies.length;