From ae829123cc652e9127c149b5d43d17372284bf96 Mon Sep 17 00:00:00 2001 From: larssand Date: Sat, 14 Nov 2026 15:40:49 +0100 Subject: [PATCH] feat(audio): passing sounds decoded once and played through WebAudio, no lag with several cars at once (1.89.27) --- CHANGELOG.md | 6 +++++ package-lock.json | 4 +-- package.json | 2 +- src/app.js | 2 ++ src/race_audio.js | 45 +++++++++++++++++++++++++++++-- tests/race_audio.test.js | 58 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 112 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b69c3b8..01ebe86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.89.27 - 2026-11-14 + +### Changed + +- **Passing sound without lag:** the passing sound (and a car's or driver's own) is loaded and decoded once and played through WebAudio, so several cars crossing at once each get their beep straight away (about 1 ms instead of starting a new audio file per passing). Before the page has been clicked, or without WebAudio, it plays as before. + ## 1.89.26 - 2026-11-14 ### Added diff --git a/package-lock.json b/package-lock.json index fb8254e..4a4b016 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.89.26", + "version": "1.89.27", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.89.26", + "version": "1.89.27", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index baf9deb..62db6d3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.89.26", + "version": "1.89.27", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/src/app.js b/src/app.js index e471ff8..616399d 100644 --- a/src/app.js +++ b/src/app.js @@ -6219,6 +6219,8 @@ let audioCtx = null; let lastFinishAnnouncementSessionId = null; const raceAudioEngine = createRaceAudioEngine({ getSettings: () => state.settings.raceAudio, + // Passing sounds through WebAudio (decoded once, low latency); overlay windows stay silent anyway. + getAudioContext: () => (overlayMode ? null : ensureAudioContext()), speak: (text, options = {}) => new Promise((resolve) => { let settled = false; const done = (value) => { if (!settled) { settled = true; resolve(value); } }; diff --git a/src/race_audio.js b/src/race_audio.js index fa5a92a..5c561d9 100644 --- a/src/race_audio.js +++ b/src/race_audio.js @@ -234,6 +234,10 @@ export function createRaceAudioEngine(options = {}) { const random = options.random || Math.random; const now = options.now || Date.now; const log = options.log || (() => {}); + // WebAudio for passing sounds: each file is fetched and decoded once, then every passing plays + // its own copy at once (overlapping, no