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

fixed performance notes negative tick durations bug #441

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

huispaty
Copy link
Collaborator

The fix modifies note_off_tick and duration_tick in a performance note array (in a somewhat inelegant way due to the fixed and default pps/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.

Copy link
Member

@CarlosCancino-Chacon CarlosCancino-Chacon left a 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(

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"],
)
)


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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants