Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearer name for time attribute #527

Open
page200 opened this issue Aug 2, 2023 · 1 comment
Open

Clearer name for time attribute #527

page200 opened this issue Aug 2, 2023 · 1 comment
Assignees
Labels
enhancement feature:midifile Standard MIDI File (SMF) implementation feature:protocol MIDI Protocol implementation
Milestone

Comments

@page200
Copy link

page200 commented Aug 2, 2023

The attribute name time doesn't explain whether it is for time since the beginning of the song or since the previous MIDI message, nor whether it is given in seconds or milliseconds or ticks.

Moreover, the units (ticks vs. seconds) are inconsistent, e.g. print(mid) and print([*mid]) shows different time values, despite the attribute being called time in both cases.

Instead, there can be two attributes: delta_ticks and delta_seconds. "Delta" in the name indicates that these are the ticks/seconds since the previous MIDI message, rather than since the beginning of the song.

Converting between the two requires knowing the previous tempo-change message. That might be the reason why the time in seconds is computed only during a loop through all messages (i.e. during __iter__()) and then discarded. One option is to keep it that way. (An alternative is to keep track of tempo changes and let the setters of delta_ticks and delta_seconds set both attributes at once. As we look into keeping track of pitch-bend range changes in issue #514, insights about keeping track of tempo changes might emerge.)

@page200
Copy link
Author

page200 commented Aug 2, 2023

delta_seconds should use fractions, see issue #528.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature:midifile Standard MIDI File (SMF) implementation feature:protocol MIDI Protocol implementation
Projects
None yet
Development

No branches or pull requests

2 participants