feat: play double-beep sound when rest timer completes
All checks were successful
CI / update (push) Successful in 3m35s

This commit is contained in:
2026-04-06 21:23:38 +02:00
parent 8364a4fb23
commit dd526ead0f
2 changed files with 22 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "homepage",
"version": "1.4.0",
"version": "1.4.1",
"private": true,
"type": "module",
"scripts": {

View File

@@ -162,11 +162,32 @@ export function createWorkout() {
}
}
function _playRestDoneSound() {
if (typeof window === 'undefined') return;
try {
const ctx = new AudioContext();
// Double beep — sine wave for a clean tone
for (let rep = 0; rep < 2; rep++) {
const offset = rep * 0.25;
const osc = ctx.createOscillator();
const gain = ctx.createGain();
osc.type = 'sine';
osc.frequency.value = 880; // A5
gain.gain.setValueAtTime(0.3, ctx.currentTime + offset);
gain.gain.exponentialRampToValueAtTime(0.001, ctx.currentTime + offset + 0.3);
osc.connect(gain).connect(ctx.destination);
osc.start(ctx.currentTime + offset);
osc.stop(ctx.currentTime + offset + 0.3);
}
} catch {}
}
function _computeRestSeconds() {
if (!_restActive || !_restStartedAt) return;
const elapsed = Math.floor((Date.now() - _restStartedAt) / 1000);
_restSeconds = Math.max(0, _restTotal - elapsed);
if (_restSeconds <= 0) {
_playRestDoneSound();
_stopRestTimer();
_persist();
}