Skip to content

Comments

Get time from rtdmidi backend#193

Draft
rec wants to merge 1 commit intomido:mainfrom
rec:rtmidi-time
Draft

Get time from rtdmidi backend#193
rec wants to merge 1 commit intomido:mainfrom
rec:rtmidi-time

Conversation

@rec
Copy link
Contributor

@rec rec commented Feb 28, 2019

The time is just sitting there, waiting to be used. :-)

I understand that it's basically "time relative to the previous MIDI event" but that's actually really useful for me, at least, and it costs you nothing to do.

@rdoursenaud
Copy link
Member

rdoursenaud commented Feb 20, 2022

Beware!

As stated in #351 and the documentation, the Message.time parameter unit is ill defined and using it in this way may break things if another unit is expected down the processing line.

Do you know what’s the time unit provided by rtmidi?
Is it the same across operating systems APIs?

@rec
Copy link
Contributor Author

rec commented Feb 20, 2022

Well, this change won't "break" anything, because old code won't be trying to get that non-existent value, I think?

If you mean that it would be possible to write new code that used this time and that worked in some cases and not others, perhaps so.

This could be documented?

Having a way to measure the time between MIDI events would be really useful.

Having to compute that time in Python at the end after the event has come through a cascade of Python code just savages both the accuracy and the precision of the result.

@rec
Copy link
Contributor Author

rec commented Feb 20, 2022

Actually, calling it msg.rtmidi_time seems like a significantly better idea.

  1. It makes it clearer that it's something peculiar to rtmidi.
  2. You can immediately guess where to look for documentation.
  3. Other projects are probably already be hanging a time onto their messages, and msg.time would conflict.

I'm going to make this change and rebase it.

@rdoursenaud
Copy link
Member

I too would love to have that information available.
I was worried it would add to the confusion if someone tried to convert the messages with this time information to a MIDI file which expects time to be in ticks

Thanks for understanding !

@rec
Copy link
Contributor Author

rec commented Feb 20, 2022

The build failure seems to be some configuration issue where it can't even find Python 2.7 and nothing to do with my delta.

@rec
Copy link
Contributor Author

rec commented Feb 20, 2022

Hey, I have fallen into so many such traps before. :-D

Honestly, I'd rather the name were a bit too long, but clear to "the next guy". Typing doesn't slow me down, mistakes do!

Is there some way to discover the units of the time field at this point in the code, now you mention it?

@rdoursenaud
Copy link
Member

Not that I’m aware but I’m quite new here.
I’m willing to dig and contribute since this lib is a huge asset for a project of mine and I need it to be reliable and spec compliant ;)

@rdoursenaud
Copy link
Member

Upon looking at the rtmidi code, what they provide is a time delta since the previously received message (aka relative time) and its unit is in milliseconds.

@rec
Copy link
Contributor Author

rec commented Oct 11, 2022 via email

@rdoursenaud rdoursenaud added the feature:backend MIDI Backend(s) label Jan 19, 2023
Copy link
Member

@rdoursenaud rdoursenaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a bit of documentation about the new rtdata_time attribute and maybe rename it to something more generic like backend_delta_time so we can make use of it in other backends.
Thanks!

@rdoursenaud rdoursenaud added this to the Version 2.0.0 milestone Jan 19, 2023
@rdoursenaud rdoursenaud added the needs-changes Pull requests that need changes before merging label Sep 2, 2023
@rdoursenaud rdoursenaud marked this pull request as draft September 2, 2023 11:19
@stephen322
Copy link

I too would like to be able to retrieve midi timestamps.
Is there a status update on this?

@rdoursenaud
Copy link
Member

@stephen322 No ETA yet but I intend to ship this feature with MIDO 2.0. Got distracted implementing a native port backend for Windows in the meantime though. Once I finish debugging it, I'll resume work on version 2.
If you really need this now, I'd be happy to accept a PR against 1.x with the issues highlighted in this thread fixed ;)

@rec
Copy link
Contributor Author

rec commented Apr 5, 2024 via email

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

Labels

feature:backend MIDI Backend(s) needs-changes Pull requests that need changes before merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants