feat(audio): car numbers in heat calls and staggered starts, names optional (1.89.11)
This commit is contained in:
1 parent
755844c22d
commit
3a0e871ebc
11 files changed
+96
-20
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { RACE_AUDIO_EVENT_DEFINITIONS, createRaceAudioEngine, normalizeRaceAudioSettings, isSilencedDuringRace, formatSpokenLapTime, formatSpokenGap, formatShortLapCall } from "../src/race_audio.js";
|
||||
import { RACE_AUDIO_EVENT_DEFINITIONS, createRaceAudioEngine, normalizeRaceAudioSettings, isSilencedDuringRace, formatSpokenLapTime, formatSpokenGap, formatShortLapCall, resolveDriverCallStyle, formatCarCall, formatHeatCallDrivers } from "../src/race_audio.js";
|
||||
|
||||
const manifest = {
|
||||
events: { transponder_pass: { effect: "effects/transponder_pass.wav" }, start_tone: { effect: "effects/start_beep.wav" } },
|
||||
@@ -66,10 +66,10 @@ test("start lights, random delay and tone precede the official start callback",
|
||||
assert.deepEqual(calls.slice(-3), [["wait", 2500], ["effect", "/race-sounds/sounds/effects/start_tone.wav"], ["timing-start"]]);
|
||||
});
|
||||
|
||||
test("staggered start mode calls out each car in grid order, 3s apart, after the official start", async () => {
|
||||
test("staggered start calls each car by its grid slot (\"Bil 1\"), never its transponder, 3s apart, after the official start", async () => {
|
||||
const calls = [];
|
||||
const engine = createRaceAudioEngine({
|
||||
fetchImpl: async () => ({ ok: true, json: async () => ({ ...manifest, voice_events: { sv: { ...manifest.voice_events.sv, staggered_release: "Bil {tp}." } } }) }),
|
||||
fetchImpl: async () => ({ ok: true, json: async () => ({ ...manifest, voice_events: { sv: { ...manifest.voice_events.sv, staggered_release: "{car}." } } }) }),
|
||||
audioFactory: (src) => ({ play: () => { calls.push(["effect", src]); return Promise.resolve(); }, volume: 1 }),
|
||||
speak: async (text) => { calls.push(["voice", text]); return true; },
|
||||
wait: async (ms) => calls.push(["wait", ms]),
|
||||
@@ -77,13 +77,13 @@ test("staggered start mode calls out each car in grid order, 3s apart, after the
|
||||
});
|
||||
await engine.runStartSequence(
|
||||
{ id: "q1h1", type: "qualification", startMode: "staggered" },
|
||||
{ onTone: () => calls.push(["timing-start"]), staggerOrder: ["111", "222", "333"] }
|
||||
{ onTone: () => calls.push(["timing-start"]), staggerOrder: [{ transponder: "111", call: "Bil 1" }, { transponder: "222", call: "Bil 2 Roy" }, { transponder: "333", call: "Bil 3" }] }
|
||||
);
|
||||
const afterStart = calls.slice(calls.findIndex((call) => call[0] === "timing-start") + 1);
|
||||
assert.deepEqual(afterStart, [
|
||||
["voice", "Bil 111."], ["wait", 3000],
|
||||
["voice", "Bil 222."], ["wait", 3000],
|
||||
["voice", "Bil 333."],
|
||||
["voice", "Bil 1."], ["wait", 3000],
|
||||
["voice", "Bil 2 Roy."], ["wait", 3000],
|
||||
["voice", "Bil 3."],
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -406,3 +406,17 @@ test("practice: the new-leader call is on by default and can be turned off; race
|
||||
assert.equal(isSilencedDuringRace("personal_best", { practiceLeaderCalls: "off" }, { type: "open_practice" }), false, "other practice calls stay");
|
||||
assert.equal(isSilencedDuringRace("new_leader", { practiceLeaderCalls: "off" }, { type: "final" }), false, "races follow their own leader setting");
|
||||
});
|
||||
|
||||
test("heat call and staggered start: car numbers in finals by default, names otherwise, or as chosen", () => {
|
||||
assert.equal(resolveDriverCallStyle("auto", "final"), "numbers");
|
||||
assert.equal(resolveDriverCallStyle(undefined, "qualification"), "names");
|
||||
assert.equal(resolveDriverCallStyle("both", "final"), "both");
|
||||
assert.equal(formatHeatCallDrivers(["Roy", "Eddie", "Anders"], "numbers", "sv"), "Bil 1, 2, 3. ");
|
||||
assert.equal(formatHeatCallDrivers(["Roy", "Eddie"], "both", "sv"), "Bil 1 Roy, bil 2 Eddie. ");
|
||||
assert.equal(formatHeatCallDrivers(["Roy", "", "Anders"], "names", "en"), "Drivers: Roy, Anders. ");
|
||||
assert.equal(formatHeatCallDrivers([], "numbers"), "");
|
||||
assert.equal(formatCarCall(4, "Anders", "both", "sv"), "Bil 5 Anders");
|
||||
assert.equal(formatCarCall(0, "Anders", "numbers", "en"), "Car 1");
|
||||
assert.equal(formatCarCall(1, "Roy", "names"), "Roy");
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user