Skip to content

Precision chime timing and BBC pips support#71

Open
heath-toby wants to merge 1 commit intohkatic:masterfrom
heath-toby:precision-timing-and-bbc-pips
Open

Precision chime timing and BBC pips support#71
heath-toby wants to merge 1 commit intohkatic:masterfrom
heath-toby:precision-timing-and-bbc-pips

Conversation

@heath-toby
Copy link
Copy Markdown

Summary

When auto-announce is set to "Speech and sound", chime sounds previously started playing at the minute boundary (:00), meaning the spoken time didn't arrive until several seconds later. This PR makes chimes start early so they finish at :00, with speech announcing the live current time immediately after — just like a broadcast time signal.

What changed

  • Precision lead-in timing (clockHandler.py): The Clock class now calculates each chime's WAV duration and begins playback that many seconds before the minute boundary. Speech is deferred via wx.CallLater and reads datetime.now() at the moment it fires, so the announced time is always the true current time.
  • BBC pips (clock_cuckoo7.wav): Receives dedicated handling. The file contains five short pips followed by a sixth long pip. Rather than aligning the end of the file with :00, the code aligns the onset of the sixth pip (at 5.22 s) with the boundary, faithfully reproducing a broadcast-style time signal. Speech fires with the sixth pip.
  • Sound-only mode: BBC pips retains its precision timing (sixth pip on :00). All other chime sounds simply play at :00, as before.
  • Speech-only mode: Unchanged — speaks the time at :00 with no chime.
  • NVDA 2024.2+ compatibility (formats.py): Added safeGetTimeFormatEx and safeGetDateFormatEx wrappers that normalise None0 for the flags parameter, since newer ctypes no longer accepts None for DWORD arguments. Date display format building is also wrapped to prevent import-time crashes from locale or API changes.

How it works

Mode Non-BBC chimes BBC pips (clock_cuckoo7)
Speech + sound Chime finishes at :00, speech immediately after 6th pip lands on :00, speech fires with it
Sound only Plays at :00 6th pip lands on :00
Speech only Speaks at :00 Speaks at :00

Files changed

  • addon/globalPlugins/clock/clockHandler.py — precision timing logic, BBC pips handling, live time announcement
  • addon/globalPlugins/clock/formats.py — safe wrappers for NVDA 2024.2+ ctypes compatibility
  • readme.md — documented precision timing behaviour in the configuration section
  • changelog.md — added entry for this release

Test plan

  • Set auto-announce to "Speech and sound" with any non-BBC chime → chime should finish right on :00 and speech should follow immediately
  • Set chime to clock_cuckoo7 (BBC pips) with "Speech and sound" → five short pips then the sixth long pip on :00, speech fires with the sixth pip
  • Set to "Sound only" with BBC pips → sixth pip on :00, no speech
  • Set to "Sound only" with any other chime → plays at :00, no speech
  • Set to "Speech only" → speaks at :00, no chime
  • Verify quiet hours still suppress all announcements
  • Verify separate hour/intermediate chime selection still works
  • Test on NVDA 2024.2+ to confirm no ctypes errors from formats.py

🤖 Generated with Claude Code

Chime sounds now start playing before the minute boundary so they
finish exactly at :00, with speech announcing the live current time
immediately after.  Previously both sound and speech fired at :00,
causing the spoken time to lag by the chime duration.

BBC pips (clock_cuckoo7.wav) receives special handling: the five
short pips lead into a sixth long pip timed to land precisely on
the minute boundary, replicating a broadcast time signal.  Speech
fires with the sixth pip.

Sound-only mode: BBC pips keeps its precision timing; all other
chimes play at :00.  Speech-only mode is unchanged.

Also adds safeGetTimeFormatEx/safeGetDateFormatEx wrappers in
formats.py for NVDA 2024.2+ ctypes compatibility (None no longer
accepted for DWORD arguments).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zstanecic
Copy link
Copy Markdown
Collaborator

@heath-toby have you tested this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants