Simplified clock

This commit is contained in:
2023-09-02 23:50:40 +03:00
parent 969a4c17c1
commit cee8c82c89
3 changed files with 12 additions and 33 deletions

View File

@ -8,19 +8,16 @@ export class TransportNode extends AudioWorkletNode {
this.app = application
this.port.addEventListener("message", this.handleMessage);
this.port.start();
this.logicalTime = 0;
}
/** @type {(this: MessagePort, ev: MessageEvent<any>) => any} */
handleMessage = (message) => {
if (message.data && message.data.type === "bang") {
this.logicalTime = message.data.logicalTime;
this.app.clock.tick++
const futureTimeStamp = this.app.clock.convertTicksToTimeposition(this.app.clock.tick);
this.app.clock.time_position = futureTimeStamp;
if (this.app.exampleIsPlaying) {
tryEvaluate(this.app, this.app.example_buffer);
} else {