-
Notifications
You must be signed in to change notification settings - Fork 21
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
fixed performance notes negative tick durations bug #441
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the bug fix! I have just a minor comment regarding raising a deprecation warning for renaming one of the functions (for compatibility reasons), and a couple of questions.
@@ -257,7 +266,7 @@ def from_note_array( | |||
return cls(id=id, part_name=part_name, notes=notes, controls=None) | |||
|
|||
|
|||
def adjust_offsets_w_sustain( | |||
def adjust_note_offsets_with_sustain( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we can add a deprecation warning for the old name of the method? I image that this might not be a method commonly used on its own, but otherwise it could break compatibility.
Maybe we can add something like this:
import warnings
def adjust_offsets_w_sustain(*args, **kwargs):
"""Deprecated function! use adjust_note_offsets_with_sustain instead."""
warnings.warn(
"`adjust_offsets_w_sustain` is deprecated and will be removed in a future version. Use `adjust_note_offsets_with_sustain` instead.",
DeprecationWarning,
stacklevel=2,
)
return adjust_note_offsets_with_sustain(*args, **kwargs)
@@ -273,7 +274,26 @@ def load_performance_midi( | |||
x["track"], | |||
) | |||
) | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to adjust the timing of the notes before assigning the ids? (this is a question rather than a comment on this change 😉)
) - note_on_tick | ||
else: | ||
note_off_tick = n["note_off_tick"] | ||
duration_tick = note_off_tick - note_on_tick |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it might be worthwhile to add another "layer" to avoid negative durations by e.g., clipping negative durations at this point (e.g., duration_tick = max(duration_tick, 0)
). On the other hand this might introduce some issues that might be hard to debug.
The fix modifies
note_off_tick
andduration_tick
in a performance note array (in a somewhat inelegant way due to the fixed and defaultpps
/pqs
). If the notes used to generate the note array have an (adjusted)tick_off
value, that value is used; otherwise, the previous approach is maintained.