From 45f0e14582e8237ce511d02e73e797fdad264fcf Mon Sep 17 00:00:00 2001 From: lucas lelievre Date: Fri, 5 Dec 2025 18:17:19 +0100 Subject: [PATCH] Make reset sound loop better when more than 3s (#1640) --- gui/src/sounds/sounds.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gui/src/sounds/sounds.ts b/gui/src/sounds/sounds.ts index ab16f2d49..8d9206619 100644 --- a/gui/src/sounds/sounds.ts +++ b/gui/src/sounds/sounds.ts @@ -122,12 +122,23 @@ export function handleResetSounds( if (status === ResetStatus.STARTED) { if (progress === 0) { - performance.mark('sound_start'); restartAndPlay(sounds.initial, volume); } if (sounds.tick) { - const tickIndex = (progress / 1000) % sounds.tick.length; + const arrayLength = sounds.tick.length; + + const cycleLength = arrayLength * 2 - 2; + const positionInCycle = Math.floor(progress / 1000) % cycleLength; + + let tickIndex; + + if (positionInCycle < arrayLength) { + tickIndex = positionInCycle; + } else { + tickIndex = cycleLength - positionInCycle; + } + if (progress >= 1000 && sounds.tick[tickIndex]) { restartAndPlay(sounds.tick[tickIndex], volume); } @@ -135,9 +146,6 @@ export function handleResetSounds( } if (status === ResetStatus.FINISHED) { - performance.mark('sound_end'); - console.log(performance.measure('sound', 'sound_start', 'sound_end')); - restartAndPlay(sounds.end, volume); restartAndPlay(sounds.mew, volume); }