The sound system has been enhanced with comprehensive logging to debug why sounds aren't playing at expected times during a 30-minute period.
- Start the timer: Go to http://localhost:5050/tymer/ and start a 30-minute period
- Open browser console: Press F12 and go to Console tab
- Watch the logs: Look for the specific logging patterns described below
- Minute 6: "12 minutes elapsed" sound
- Minute 12: "12 minutes elapsed" sound
- Minute 18: "12 minutes remaining" sound
- Minute 24: "6 minutes remaining" sound
- Minute 30: "Time is up" sound (but should only play once)
Look for logs like:
π― [TIMER_NOTIFICATIONS] t=6min: { periodElapsed: "6min", ... }
Look for logs like:
π [ELAPSED] t=6min checking intervals: [12, 24, 36, ...]
π [ELAPSED] 12min target: 2024-..., timeDiff: -360s, inWindow: false, shouldPlay: false
Look for logs like:
π [REMAINING] t=18min (12min left) checking warnings: [24, 12, 6]
π [REMAINING] 12min remaining target: 2024-..., timeDiff: 0s, inWindow: true, shouldPlay: false
Look for logs like:
πͺ [WINDOW] isInCollectionWindow: currentTime=..., targetTime=..., diff=0s, window=3.5s, inWindow=true
π [WINDOW] Adding remaining/12 to window ... (1 sounds total)
Look for logs like:
π― [RESOLVE] Found 1 sounds in window: ["remaining/12"]
π [RESOLVE] Playing remaining sound: 12 (beat 0 other sounds)
π΅ [PLAY] Attempting to play sound: remaining/12
β
[PLAY] Sound remaining/12 started playing (ID: 1)
Look for logs like:
π [PERIOD_END] Called with: { nextPeriodType: "work", periodElapsed: "30min", ... }
π [PERIOD_END] Playing period-end notification for work (first time reaching end)
-
Are target times being calculated correctly?
- For 6min elapsed: Should see 12min elapsed target 6 minutes after period start
- For 18min elapsed: Should see 12min remaining target 18 minutes after period start
-
Is the collection window logic working?
isInCollectionWindowshould return true when within Β±3.5 seconds of targetshouldPlaySoundshould return true when past the collection window
-
Are sounds being added to windows?
- Look for "Adding ... to window" messages at the right times
-
Are windows being resolved?
- Look for "Resolving ... sound" messages when window closes
-
Why is period end playing twice?
- Look at the
playPeriodEndNotificationcalls and timing
- Look at the
t=0min: Timer starts
t=6min: Should see 12min elapsed target calculations, but target is at t=12min
t=12min: 12min elapsed sound should be added to window and play
t=18min: 12min remaining sound should be added to window and play
t=24min: 6min remaining sound should be added to window and play
t=30min: Period end sound should play once
/home/srb/code/tymer2/src/lib/sounds.js- Added comprehensive debugging logs
The logging will help identify exactly where the sound scheduling is failing.