Change from audiocontext currenttime to logicaltime
This commit is contained in:
@ -28,19 +28,20 @@ export class TransportNode extends AudioWorkletNode {
|
|||||||
/** @type {(this: MessagePort, ev: MessageEvent<any>) => any} */
|
/** @type {(this: MessagePort, ev: MessageEvent<any>) => any} */
|
||||||
handleMessage = (message) => {
|
handleMessage = (message) => {
|
||||||
if (message.data && message.data.type === "bang") {
|
if (message.data && message.data.type === "bang") {
|
||||||
let { futureTimeStamp, timeToNextPulse, nextPulsePosition } = this.convertTimeToNextBarsBeats(message.data.logicalTime);
|
this.logicalTime = message.data.logicalTime;
|
||||||
|
let { futureTimeStamp, timeToNextPulse, nextPulsePosition } = this.convertTimeToNextBarsBeats(this.logicalTime);
|
||||||
|
|
||||||
// Evaluate the global buffer only once per ppqn value
|
// Evaluate the global buffer only once per ppqn value
|
||||||
if (this.nextPulsePosition !== nextPulsePosition) {
|
if (this.nextPulsePosition !== nextPulsePosition) {
|
||||||
this.nextPulsePosition = nextPulsePosition;
|
this.nextPulsePosition = nextPulsePosition;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const now = this.app.audioContext.currentTime;
|
const now = this.logicalTime;
|
||||||
this.app.clock.time_position = futureTimeStamp;
|
this.app.clock.time_position = futureTimeStamp;
|
||||||
// this.$clock.innerHTML = `[${futureTimeStamp.bar}:${futureTimeStamp.beat}:${zeroPad(futureTimeStamp.pulse, '2')}]`;
|
//this.$clock.innerHTML = `[${futureTimeStamp.bar}:${futureTimeStamp.beat}:${zeroPad(futureTimeStamp.pulse, '2')}]`;
|
||||||
tryEvaluate(this.app, this.app.global_buffer);
|
tryEvaluate(this.app, this.app.global_buffer);
|
||||||
this.hasBeenEvaluated = true;
|
this.hasBeenEvaluated = true;
|
||||||
this.currentPulsePosition = nextPulsePosition;
|
this.currentPulsePosition = nextPulsePosition;
|
||||||
const then = this.app.audioContext.currentTime;
|
const then = this.logicalTime;
|
||||||
this.lastLatencies[this.indexOfLastLatencies] = then - now;
|
this.lastLatencies[this.indexOfLastLatencies] = then - now;
|
||||||
this.indexOfLastLatencies = (this.indexOfLastLatencies + 1) % this.lastLatencies.length;
|
this.indexOfLastLatencies = (this.indexOfLastLatencies + 1) % this.lastLatencies.length;
|
||||||
const averageLatency = this.lastLatencies.reduce((a, b) => a + b) / this.lastLatencies.length;
|
const averageLatency = this.lastLatencies.reduce((a, b) => a + b) / this.lastLatencies.length;
|
||||||
|
|||||||
Reference in New Issue
Block a user