making everything an arrow function

This commit is contained in:
2023-08-17 17:54:03 +02:00
parent ab482b38b2
commit bf2cb7713d
6 changed files with 110 additions and 118 deletions

View File

@ -35,7 +35,8 @@ export class TransportNode extends AudioWorkletNode {
if (this.nextPulsePosition !== nextPulsePosition) {
this.nextPulsePosition = nextPulsePosition;
setTimeout(() => {
const now = performance.now();
// const now = performance.now(); // Use AudioContext time instead
const now = this.app.audioContext.currentTime;
this.app.clock.time_position = futureTimeStamp;
// this.$clock.innerHTML = `[${futureTimeStamp.bar}:${futureTimeStamp.beat}:${zeroPad(futureTimeStamp.pulse, '2')}]`;
tryEvaluate(
@ -44,7 +45,8 @@ export class TransportNode extends AudioWorkletNode {
);
this.hasBeenEvaluated = true;
this.currentPulsePosition = nextPulsePosition;
const then = performance.now();
// const then = performance.now(); // Use AudioContext time instead
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;