feat(audio): air horn for start and finish, count 10..3 then quiet until the horn 1-3 s later (1.55.0)

This commit is contained in:
larssand committed 2026-11-03 08:56:15 +01:00
1 parent a8996c4195
commit 3425da4b8f
16 files changed
+67 -31

No files matched your search

+1 -1
View File
@@ -101,7 +101,7 @@ export async function runRaceDayStartSequencesSmoke({ evaluate, navigate, waitFo
assert.ok([...observedCountdown].filter((text) => /^0:(0\d|10)$/.test(String(text || ""))).length >= 3, "count-down clock ticked down from 10 s: " + JSON.stringify([...observedCountdown]));
await waitFor(async () => (await findSession(sessions[0].id)).status === "running", "heat running after its count-down + light sequence", 20000);
const heatLog = (await savedState()).audioEventLog.slice(0, 12).map((entry) => entry.event);
assert.ok(heatLog.includes("prologue_count") && heatLog.includes("race_10_seconds"), "the count-down called 10 s and 9..3: " + JSON.stringify(heatLog));
assert.ok(heatLog.filter((event) => event === "prologue_count").length === 8 && !heatLog.includes("race_10_seconds"), "the count-down called 10, 9 … 3: " + JSON.stringify(heatLog));
assert.ok(!heatLog.includes("drivers_ready") && !heatLog.includes("race_30_seconds"), "no second count-down after the prologue: " + JSON.stringify(heatLog));
console.log("PASS heat start runs a real count-down + light sequence instead of starting instantly");
+1 -1
View File
@@ -79,7 +79,7 @@ test("flying start calls the EFRA 9.2b marks: 1 min, 30 s, 10 s (2 min is the op
});
test("grid start calls cars to the grid at 30 s and counts 10..3 second by second (IFMAR 4.2.5-4.2.6)", () => {
assert.deepEqual(collectCalls(90000, "position"), ["race_1_minute", "prologue_grid", "race_10_seconds", 9, 8, 7, 6, 5, 4, 3]);
assert.deepEqual(collectCalls(90000, "position"), ["race_1_minute", "prologue_grid", 10, 9, 8, 7, 6, 5, 4, 3]);
assert.equal(getPrologueHandoverMs("position"), 3000, "the start signal follows 0-5 s after the 3 s mark");
assert.equal(getPrologueHandoverMs("flying"), 0);
});
+23 -1
View File
@@ -112,7 +112,29 @@ test("after the prologue a grid start skips its own count-down and intro calls",
const calls = [];
const engine = createRecordingEngine(calls, { startCountdownSeconds: 30 });
await engine.runStartSequence({ id: "f1", type: "final", startMode: "position" }, { onTone: () => calls.push(["timing-start"]), skipCountdown: true, skipIntro: true });
assert.deepEqual(calls, [["wait", 2000], ["effect", "start_beep.wav"], ["timing-start"]], "only the 0-5 s delay and the horn are left");
assert.equal(calls.length, 3, "only the quiet and the horn are left");
assert.equal(calls[0][0], "wait");
assert.ok(calls[0][1] >= 1000 && calls[0][1] <= 3000, "1-3 s of quiet");
assert.deepEqual(calls.slice(1), [["effect", "start_beep.wav"], ["timing-start"]]);
});
test("after the count-down's 3 it is quiet until the horn 1-3 s later, with the lights inside that time", async () => {
for (const [roll, totalMs] of [[0, 1000], [1, 3000]]) {
const calls = [];
const engine = createRaceAudioEngine({
fetchImpl: async () => ({ ok: true, json: async () => manifest }),
audioFactory: (src) => ({ play: () => { calls.push(["effect", src.split("/").pop()]); return Promise.resolve(); }, volume: 1 }),
speak: async (text) => { calls.push(["voice", text]); return true; },
wait: async (ms) => calls.push(["wait", ms]),
random: () => roll,
getSettings: () => normalizeRaceAudioSettings({ startLights: true, lightIntervalMs: 1000, minStartDelay: 4, maxStartDelay: 8 }),
});
await engine.runStartSequence({ id: "f1", type: "final", startMode: "position" }, { skipCountdown: true, skipIntro: true });
assert.equal(calls.filter(([kind]) => kind === "voice").length, 0, "nothing is said");
const waited = calls.filter(([kind]) => kind === "wait").reduce((sum, [, ms]) => sum + ms, 0);
assert.ok(Math.abs(waited - totalMs) <= 6, `horn ${totalMs} ms after the 3, was ${waited}`);
assert.deepEqual(calls.at(-1), ["effect", "start_beep.wav"]);
}
});
test("during a race only the passing tone plays by default - no names, personal bests or leader calls", () => {
+1 -1
View File
@@ -115,7 +115,7 @@ test("SQLite API persists state, passings, and overlay session results", { timeo
const soundManifestResponse = await fetch(`${baseUrl}/race-sounds/sound_manifest.json`);
const soundManifest = await soundManifestResponse.json();
assert.equal(soundManifestResponse.status, 200);
assert.equal(soundManifest.events.start_tone.effect, "effects/start_beep.wav");
assert.equal(soundManifest.events.start_tone.effect, "effects/start_horn.wav");
assert.equal(soundManifest.voice_events.sv.track_call, "Stopp på banan. Stopp på banan.");
const ammcConfigResponse = await fetch(`${baseUrl}/api/ammc/config`, {