You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When appending events in absolute mode and the tick of the event added is less than the previous events, the event order is kept, resulting in an invalid order if the mode is kept as absolute, or negative and invalid tick values if restored to relative.
While, from the list inheritance point of view this makes sense, it does not from the midi file perspective.
The previous code will result in an invalid order of absolute ticks (and inconsistent results in a saved file) and, most importantly, negative values whenever the pattern is set back to relative mode: in this case, the saved file results like this:
I've not yet understood how the write_midifile() actually behaves whenever the make_ticks methods are inconsistent between pattern and tracks, maybe I'll do some digging about this.
The workaround is to do a [track.sort(key=lambda e: e.tick) for track in pattern if not track.tick_relative] before actually exporting the midi file.
Maybe it is better to implement append() and use bisect_right whenever the track is using the absolute tick mode, but the insert() method might need some further investigation too.
The text was updated successfully, but these errors were encountered:
When appending events in absolute mode and the tick of the event added is less than the previous events, the event order is kept, resulting in an invalid order if the mode is kept as absolute, or negative and invalid tick values if restored to relative.
While, from the list inheritance point of view this makes sense, it does not from the midi file perspective.
The previous code will result in an invalid order of absolute ticks (and inconsistent results in a saved file) and, most importantly, negative values whenever the pattern is set back to relative mode: in this case, the saved file results like this:
I've not yet understood how the write_midifile() actually behaves whenever the make_ticks methods are inconsistent between pattern and tracks, maybe I'll do some digging about this.
The workaround is to do a
[track.sort(key=lambda e: e.tick) for track in pattern if not track.tick_relative]
before actually exporting the midi file.Maybe it is better to implement
append()
and use bisect_right whenever the track is using the absolute tick mode, but theinsert()
method might need some further investigation too.The text was updated successfully, but these errors were encountered: