use awp as time reference at max precision
This commit is contained in:
@ -13,8 +13,8 @@ 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 === "bang") {
|
if (message.data && message.data.type === "bang") {
|
||||||
let info = this.convertTimeToBarsBeats(this.context.currentTime);
|
let info = this.convertTimeToBarsBeats(message.data.currentTime);
|
||||||
this.app.clock.time_position = { bar: info.bar, beat: info.beat, pulse: info.ppqn }
|
this.app.clock.time_position = { bar: info.bar, beat: info.beat, pulse: info.ppqn }
|
||||||
this.$clock.innerHTML = `[${info.bar} | ${info.beat} | ${zeroPad(info.ppqn, '2')}]`
|
this.$clock.innerHTML = `[${info.bar} | ${info.beat} | ${zeroPad(info.ppqn, '2')}]`
|
||||||
tryEvaluate( this.app, this.app.global_buffer );
|
tryEvaluate( this.app, this.app.global_buffer );
|
||||||
|
|||||||
@ -4,29 +4,31 @@ class TransportProcessor extends AudioWorkletProcessor {
|
|||||||
super(options);
|
super(options);
|
||||||
this.port.addEventListener("message", this.handleMessage);
|
this.port.addEventListener("message", this.handleMessage);
|
||||||
this.port.start();
|
this.port.start();
|
||||||
|
this.stated = false;
|
||||||
|
/*
|
||||||
this.interval = 0.0001;
|
this.interval = 0.0001;
|
||||||
this.origin = currentTime;
|
this.origin = currentTime;
|
||||||
this.next = this.origin + this.interval;
|
this.next = this.origin + this.interval;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMessage = (message) => {
|
handleMessage = (message) => {
|
||||||
if (message.data === "start") {
|
if (message.data === "start") {
|
||||||
this.origin = currentTime;
|
this.started = true;
|
||||||
this.next = this.origin + this.interval;
|
// this.origin = currentTime;
|
||||||
|
// this.next = this.origin + this.interval;
|
||||||
} else if (message.data === "pause") {
|
} else if (message.data === "pause") {
|
||||||
this.next = Infinity;
|
// this.next = Infinity;
|
||||||
|
this.started = false;
|
||||||
} else if (message.data === "stop") {
|
} else if (message.data === "stop") {
|
||||||
this.origin = currentTime;
|
// this.origin = currentTime;
|
||||||
this.next = Infinity;
|
// this.next = Infinity;
|
||||||
|
this.started = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
process(inputs, outputs, parameters) {
|
process(inputs, outputs, parameters) {
|
||||||
if (currentTime >= this.next) {
|
if (this.started) this.port.postMessage({ type: "bang", currentTime });
|
||||||
while (this.next < currentTime)
|
|
||||||
this.next += this.interval;
|
|
||||||
this.port.postMessage("bang");
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user