Skip to content

webmidi: report input timestamps on the monotonic clock's scale - #260

Merged
jcelerier merged 1 commit into
masterfrom
webmidi-timestamp-origin
Sep 21, 2026
Merged

jcelerier merged 1 commit into
masterfrom
webmidi-timestamp-origin

Conversation

@jcelerier

Copy link
Copy Markdown
Member

MIDIMessageEvent.timeStamp counts milliseconds from the page's time origin,
while absolute_timestamp() answers with the monotonic clock, which emscripten
reports as timeOrigin + performance.now().

A consumer subtracting the two — placing an incoming message inside the current
audio buffer, say — was therefore off by the time origin, some 1.8e12 ms. In
libossia's execution_state the subtraction hit the < 0 clamp, so every
message landed on frame 0 of the buffer: no crash, no error, just no
sample-accuracy on the web.

Found while tracking down an unrelated abort in the same path. Reasoned from the
generated JS and emscripten's clock implementation; I have not measured a message
landing on a non-zero frame, so this side of it is unverified.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SCvayD61okH7PATstw4whi

MIDIMessageEvent.timeStamp counts milliseconds from the page's time
origin, while absolute_timestamp() answers with the monotonic clock,
which emscripten reports as timeOrigin + performance.now(). A consumer
subtracting the two — placing an incoming message inside the current
audio buffer, say — was therefore off by the time origin, some 1.8e12
milliseconds, and every message landed at the start of the buffer.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SCvayD61okH7PATstw4whi
@jcelerier
jcelerier merged commit b2db3f5 into master Sep 21, 2026
39 of 90 checks passed
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.

1 participant