diff --git a/src/TransportNode.js b/src/TransportNode.js index db09830..83ee5ae 100644 --- a/src/TransportNode.js +++ b/src/TransportNode.js @@ -12,23 +12,24 @@ export class TransportNode extends AudioWorkletNode { /** @type {(this: MessagePort, ev: MessageEvent) => any} */ handleMessage = (message) => { - if (message.data && message.data.type === "elapsed") { - this.app.clock.elapsed = message.data.value - } - if (message.data && message.data.type === "bang") { - if (this.app.settings.send_clock) - this.app.api.MidiConnection.sendMidiClock(); - this.app.clock.tick++; - const futureTimeStamp = this.app.clock.convertTicksToTimeposition( - this.app.clock.tick - ); - this.app.clock.time_position = futureTimeStamp; - this.timeviewer.innerHTML = `${zeroPad(futureTimeStamp.bar, 2)}:${futureTimeStamp.beat + 1 - }:${zeroPad(futureTimeStamp.pulse, 2)} / ${this.app.clock.bpm}`; - if (this.app.exampleIsPlaying) { - tryEvaluate(this.app, this.app.example_buffer); - } else { - tryEvaluate(this.app, this.app.global_buffer); + if(message.data) { + if (message.data.type === "elapsed") { + this.app.clock.elapsed = message.data.value + } else if (message.data.type === "bang") { + if (this.app.settings.send_clock) + this.app.api.MidiConnection.sendMidiClock(); + this.app.clock.tick++; + const futureTimeStamp = this.app.clock.convertTicksToTimeposition( + this.app.clock.tick + ); + this.app.clock.time_position = futureTimeStamp; + this.timeviewer.innerHTML = `${zeroPad(futureTimeStamp.bar, 2)}:${futureTimeStamp.beat + 1 + }:${zeroPad(futureTimeStamp.pulse, 2)} / ${this.app.clock.bpm}`; + if (this.app.exampleIsPlaying) { + tryEvaluate(this.app, this.app.example_buffer); + } else { + tryEvaluate(this.app, this.app.global_buffer); + } } } };