Skip to content

Fix cumulative fast-drift in tick scheduler#130

Open
louietyj wants to merge 1 commit into
patzly:mainfrom
louietyj:fix/tick-scheduler-drift
Open

Fix cumulative fast-drift in tick scheduler#130
louietyj wants to merge 1 commit into
patzly:mainfrom
louietyj:fix/tick-scheduler-drift

Conversation

@louietyj

Copy link
Copy Markdown

(60000 / tempo) / subdivisions integer-divides twice, so each accumulator step drops a fractional ms and the metronome runs progressively fast -- e.g. 140bpm with triplets is ~0.6% fast (~22s per hour), audible against a reference click within a minute. Tempos and subdivisions whose intervals divide 60000 cleanly (60, 100, 120 plain, 200 plain, etc.) are unaffected.

Switches nextScheduleTime to double and casts back to long only at postDelayed. getInterval() stays long so count-in / timer / UI math is unchanged.

`(60000 / tempo) / subdivisions` integer-divides twice, so each
accumulator step drops a fractional ms and the metronome runs
progressively fast — e.g. 140bpm with triplets is ~0.6% fast (~22s
per hour), audible against a reference click within a minute. Tempos
and subdivisions whose intervals divide 60000 cleanly (60, 100, 120
plain, 200 plain, etc.) are unaffected.

Switches `nextScheduleTime` to `double` and casts back to `long` only
at `postDelayed`. `getInterval()` stays `long` so count-in / timer /
UI math is unchanged.
@patzly

patzly commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Thank you for your contribution! I will look into it in about one week.

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