winmidi: convert input timestamps from MidiClock ticks to nanoseconds - #263
Merged
Merged
Conversation
Windows MIDI Services timestamps are MidiClock ticks (100 ns on current Windows), but libremidi timestamps are in ns, so they came out 100x too small. Convert them using MidiClock::TimestampFrequency().
yuki-is-taka
added a commit
to yuki-is-taka/Libremidi4UE
that referenced
this pull request
Sep 28, 2026
…#263 The tick-to-ns fix went upstream on its own rather than in the fork batch. Once it is merged, bump the submodule and drop the ADR-0002 wrapper correction in the same change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
thanks for the patch ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The winmidi input backend passes the Windows MIDI Services timestamp through as-is:
That value is in MidiClock ticks (100 ns on current Windows, see
MidiClock::TimestampFrequency()), not nanoseconds, so on winmidi the Absolute/Relative timestamps come out 100x too small compared to the other backends.This converts both callback paths to ns using
TimestampFrequency(), read once in the constructor. The conversion is split into quotient/remainder so it can't overflow.Tested on Windows 11 with a USB MIDI controller over Windows MIDI Services: with the change, timestamps match QueryPerformanceCounter converted to ns (within ~30 µs).