diff --git a/src/Clock.ts b/src/Clock.ts index cb2d3d0..b1f197b 100644 --- a/src/Clock.ts +++ b/src/Clock.ts @@ -33,7 +33,8 @@ export class Clock { */ ctx: AudioContext; - elapsed: number + elapsed: number; + logicalTime: number; transportNode: TransportNode | null; private _bpm: number; time_signature: number[]; @@ -45,6 +46,7 @@ export class Clock { this.time_position = { bar: 0, beat: 0, pulse: 0 }; this.time_signature = [4, 4]; this.elapsed = 0; + this.logicalTime = 0; this.tick = 0; this._bpm = 120; this._ppqn = 48; @@ -144,10 +146,6 @@ export class Clock { return this._ppqn; } - get logicalTime(): number { - return this.tick * this.pulse_duration; - } - get realTime(): number { return this.elapsed; } @@ -163,6 +161,11 @@ export class Clock { } } + public incrementTick() { + this.tick++; + this.logicalTime += this.pulse_duration; + } + public nextTickFrom(time: number, nudge: number): number { /** * Compute the time remaining before the next clock tick. diff --git a/src/TransportNode.js b/src/TransportNode.js index 83ee5ae..0644d90 100644 --- a/src/TransportNode.js +++ b/src/TransportNode.js @@ -18,7 +18,7 @@ export class TransportNode extends AudioWorkletNode { } else if (message.data.type === "bang") { if (this.app.settings.send_clock) this.app.api.MidiConnection.sendMidiClock(); - this.app.clock.tick++; + this.app.clock.incrementTick(); const futureTimeStamp = this.app.clock.convertTicksToTimeposition( this.app.clock.tick );