-
Notifications
You must be signed in to change notification settings - Fork 402
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
In kern allow non-eighth type & non-slashed grace notes, improve default duration of non-first chord notes, decrease import time by ~15% #1684
Conversation
Is there any input on this pr? It fixes two bugs for me when reading kern files so I would like to see it integrated if possible. I can also file those two bugs as issues if that would help. Thanks. |
Hi Alex -- as I've mentioned on the list, I'm taking a hiatus from music21 except for paid support, unless I happen to have a bit of extra time. I'll try to get this when I can. Note that there's some conflict w/ the PR of Tim #1693 -- whichever gets merged first will need to have some edits on the other. |
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.
Hi -- sorry but I cannot accept this in the state it is in because I cannot follow the logic that it is supposed to use to speed up. The refactor adds much more complexity to an already overly complex routine.
music21/humdrum/spineParser.py
Outdated
@@ -2119,7 2122,27 @@ def getAllOccurring(self): | |||
return retEvents | |||
|
|||
|
|||
def hdStringToNote(contents): | |||
@lru_cache(maxsize=256) | |||
def _noteMemos(contents): |
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.
new music21 routines require typing. Can you type the input and output of this routine?
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.
Give some docs about what this does.
music21/humdrum/spineParser.py
Outdated
return (dur_regex, dotCount, matchedNote, step, accountedFor) | ||
|
||
|
||
def hdStringToNote(contents, defaultDuration=None): |
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.
add typing at least to the new attribute (but it'd be kind to add typing to all)
music21/humdrum/spineParser.py
Outdated
raise HumdrumException(f'Could not parse {contents} for note information') | ||
accountedFor = len(matchedNote.group(0)) | ||
step = matchedNote.group(1)[0].lower() | ||
return (dur_regex, dotCount, matchedNote, step, accountedFor) |
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.
don't mix underscore and camelCase in internal variable names. Choose one or the other.
music21/humdrum/spineParser.py
Outdated
dur = defaultDuration | ||
else: | ||
if 'q' in contents: | ||
dur = duration.Duration(.5, dots=dotCount) |
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.
style: 0.5 not .5
music21/humdrum/spineParser.py
Outdated
dur_regex, dotCount, matchedNote, step, accountedFor = _noteMemos(contents) | ||
|
||
if dur_regex: | ||
foundNumber, foundRational = dur_regex.groups() |
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.
all of this takes an already very complex set of routines and makes them even more complex -- now with a set of nested if statements. Together with the rewriting of the count routines, I can't make heads or tails of what has changed. Please refactor into a routine that gets the duration from contents and one that gets the pitch from contents. I have no idea what "accountedFor" means or what a dur_regex is supposed to represent.
This PR has some very minor substantive changes with accompanying tests and several small optimizations for kern import
Substantive changes:
Kern import optimizations (mostly in hdStringToNote)
if str.count('x'):
becomesif 'x' in str: