diff --git a/src/Clock.ts b/src/Clock.ts index e0f814d..8dff62c 100644 --- a/src/Clock.ts +++ b/src/Clock.ts @@ -137,7 +137,6 @@ export class Clock { set bpm(bpm: number) { if (bpm > 0 && this._bpm !== bpm) { - this._bpm = bpm; this.transportNode?.setBPM(bpm); } } @@ -223,7 +222,8 @@ export class Clock { * @remark also sends a MIDI message if a port is declared */ this.app.clock.tick = 0; - this.logicalTime = 0 + this.logicalTime = 0; + this.elapsed = 0; this.time_position = { bar: 0, beat: 0, pulse: 0 }; this.app.api.MidiConnection.sendStopMessage(); this.transportNode?.stop(); diff --git a/src/TransportNode.js b/src/TransportNode.js index 0644d90..7c6c681 100644 --- a/src/TransportNode.js +++ b/src/TransportNode.js @@ -30,6 +30,8 @@ export class TransportNode extends AudioWorkletNode { } else { tryEvaluate(this.app, this.app.global_buffer); } + } else if (message.data.type === "bpm") { + this.app.clock.bpm = message.data.value; } } }; diff --git a/src/TransportProcessor.js b/src/TransportProcessor.js index 046d17f..06bd225 100644 --- a/src/TransportProcessor.js +++ b/src/TransportProcessor.js @@ -36,6 +36,7 @@ class TransportProcessor extends AudioWorkletProcessor { } else if (message.data.type === 'bpm') { this.bpm = message.data.value; this.currentPulsePosition = 0; + this.port.postMessage({ type: "bpm", value: this.bpm }); } else if (message.data.type === 'ppqn') { this.ppqn = message.data.value; this.currentPulsePosition = 0;