Clearer name for time
attribute
#527
Labels
enhancement
feature:midifile
Standard MIDI File (SMF) implementation
feature:protocol
MIDI Protocol implementation
Milestone
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)
andprint([*mid])
shows different time values, despite the attribute being calledtime
in both cases.Instead, there can be two attributes:
delta_ticks
anddelta_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 ofdelta_ticks
anddelta_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.)The text was updated successfully, but these errors were encountered: