From f23bd208b38ccfdc814daa99818a7e119f5ee313 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 15 Feb 2026 15:00:57 +0100 Subject: refactor(timeline-editor): centralize BPM calculations Replace repeated 60.0/bpm calculations with precomputed secondsPerBeat and beatsPerSecond properties. Add computeBPMValues helper and updateBPM function for consistency. Also prevent wheel events on time markers. Co-Authored-By: Claude Sonnet 4.5 --- tools/timeline_editor/timeline-playback.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tools/timeline_editor/timeline-playback.js') diff --git a/tools/timeline_editor/timeline-playback.js b/tools/timeline_editor/timeline-playback.js index bfeb75a..17223ac 100644 --- a/tools/timeline_editor/timeline-playback.js +++ b/tools/timeline_editor/timeline-playback.js @@ -117,7 +117,7 @@ export class PlaybackController { } } if (this.state.audioDuration > 0) { - maxTime = Math.max(maxTime, this.state.audioDuration * this.state.bpm / 60.0); + maxTime = Math.max(maxTime, this.state.audioDuration * this.state.beatsPerSecond); } const w = maxTime * this.state.pixelsPerSecond; @@ -313,10 +313,10 @@ export class PlaybackController { // Helpers beatsToTime(beats) { - return beats * 60.0 / this.state.bpm; + return beats * this.state.secondsPerBeat; } timeToBeats(seconds) { - return seconds * this.state.bpm / 60.0; + return seconds * this.state.beatsPerSecond; } } -- cgit v1.2.3