From dd48d407457d13ca1bd7c86d0e6b5140ab45ec80 Mon Sep 17 00:00:00 2001 From: Miika Alonen Date: Thu, 24 Aug 2023 21:34:54 +0300 Subject: [PATCH] Slightly better sync. onbeat() starts now from the first beat --- src/API.ts | 5 +++-- src/classes/ZPlayer.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/API.ts b/src/API.ts index b0af566..73e0a01 100644 --- a/src/API.ts +++ b/src/API.ts @@ -884,11 +884,12 @@ export class UserAPI { */ let final_pulses: boolean[] = []; beat.forEach((b) => { - b = (b % this.app.clock.time_signature[0]) + 1; + const _mod = b % this.app.clock.time_signature[0]; + b = _mod === 0 ? b : _mod; let integral_part = Math.floor(b); let decimal_part = b - integral_part; final_pulses.push( - integral_part === this.app.clock.time_position.beat && + integral_part === this.app.clock.time_position.beat && this.app.clock.time_position.pulse === decimal_part * this.app.clock.ppqn ); diff --git a/src/classes/ZPlayer.ts b/src/classes/ZPlayer.ts index 1b32c8f..2486e08 100644 --- a/src/classes/ZPlayer.ts +++ b/src/classes/ZPlayer.ts @@ -38,9 +38,9 @@ export class Player extends Event { areWeThereYet = (): boolean => { const howAboutNow = ( - (this.notStarted()) || + (this.notStarted() && this.app.clock.time_position.pulse === 1) || ( - this.current && + this.current && this.pulseToSecond(this.app.api.epulse()+1) >= this.pulseToSecond(this.callTime) + (this.current.duration*4) * this.pulseToSecond(this.app.api.ppqn())