-
Notifications
You must be signed in to change notification settings - Fork 433
FretBend supports alter (interval), prebend, and release #1580
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
Conversation
mscuthbert
left a comment
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.
Well on its way! Ask around if you need help in writing tests, and for help on why music21's system of intervals is more complex than musicxml's.
(the changes to note.Note are rejected, so please remove them, thanks!)
music21/articulations.py
Outdated
| release: t.Optional[float] | ||
| withBar: t.Optional[bool] | ||
|
|
||
| def __init__(self, number=0, preBend=False, release=None, withBar=None, **keywords): |
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.
number is too generic a term -- and we usually reserve the term for identifying which of multiple simultaneous items (like slur number=1 vs slur number=2). Are fret-bends always chromatic intervals? it seems like you can also have a diatonic interval of a fretbend. hence why bendAlter was typed as IntervalBase not ChromaticInterval. It seems better to have bendAlter as described above interval.IntervalBase | None = None where None indicates unspecified. Having a default of 0, becoming ChromaticInterval(0) indicates that this fretBend does not alter the pitch at all, which would be a very strange fret bend. This would also make it so that interval.py does not need to be imported here.
The other keywords should be typed in the __init__ declaration in addition to the class.
We no longer use t.Optional[X] in the code base. Use X | None instead.
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.
Changed with d63c78a
music21/articulations.py
Outdated
| bend indication for fretted instruments | ||
| bend in musicxml | ||
| number is the interval of the bend in number of semitones, bend-alter in musicxml | ||
| preBend indicates wether the note is prebended or not | ||
| release is the offset value for releasing the bend, if Any | ||
| withBar indicates if the bend is done using a whammy bar movement |
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.
Capitalization and use asterisks and line breaks for documentation -- run documentation/build.py and look at the difference between the docs produced here and elsewhere in the system.
preBend indicates wether the note is prebended or not -- I don't know what prebended means.
what is release measured in? Is it an offset (which is relative to the start of the Measure/stream)? That doesn't sound right. Is it a quarterLength measured from the start of the note? or from the end of the note.
withBar doc is fine.
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.
I've tried to improve it in 03e6117
Let me know if that seems good to you
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.
tests are on their way
music21/musicxml/m21ToXml.py
Outdated
| bendAlterSubElement = SubElement(mxTechnicalMark, 'bend-alter') | ||
| bendAlterSubElement.text = str(articulationMark.bendAlter.semitones) |
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.
this has enough ifs that it should be brought out as its own small method that allows for easier documentation and testing. articulationMark will probably need to be cast as a FretBend.
We can solve the case of GenericInterval later, which doesn't have .semitones. Perhaps it always needs to be a full Interval object or 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.
New submethod added in 85cc6a8
Now I indeed have the problem that I need to retrieve the number of semitones. I could probably do something with GenericInterval.value but I don't know how to do the conversion properly
music21/musicxml/m21ToXml.py
Outdated
| releaseSubElement = SubElement(mxTechnicalMark, 'release') | ||
| releaseSubElement.set('offset', str(articulationMark.release)) |
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.
musicxml's definition of offset is very different from music21's and (despite me now being editor of the musicxml spec) we shouldn't use musicxml offsets anywhere in music21 -- these need to be converted according to the current divisionsPerQuarter setting.
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.
should work with d93af6d though I need to write the tests
music21/musicxml/xmlToM21.py
Outdated
| if mxObj.get('substitution') is not None: | ||
| tech.substitution = xmlObjects.yesNoToBoolean(mxObj.get('substitution')) | ||
| if tag == 'bend': | ||
| tech.bendAlter = interval.Interval(int(mxObj.find('bend-alter').text)) |
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.
this has too many potentials for crashing the processing. What if there is no bend-alter or no bend-alter.text? check that before typing to assign.
(Better to call out into a separate sub-method. This method was designed just for one-to-two lines per technical
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.
sub-method and bend-alter check in 2e1ea43
music21/musicxml/xmlToM21.py
Outdated
| if mxObj.find('pre-bend') is not None: | ||
| tech.preBend = True | ||
| if mxObj.find('release') is not None: | ||
| tech.release = int(mxObj.find('release').get('offset')) |
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.
as above -- offset needs to be converted to music21 quarterLengths.
except clause without Try.
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.
Both fixed with 58eeb04
music21/musicxml/xmlToM21.py
Outdated
| tech.release = int(mxObj.find('release').get('offset')) | ||
| except TypeError: | ||
| # offset is not mandatory | ||
| tech.release = 0 |
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.
release is a float. needs to be 0.0
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.
also fixed with 58eeb04
music21/note.py
Outdated
| from music21 import articulations | ||
|
|
||
| if t.TYPE_CHECKING: | ||
| from music21 import articulations |
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.
as above -- alphabetical and remove from type-checking if imported at top. (but won't be necessary).
music21/note.py
Outdated
| @property | ||
| def string(self): |
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.
this new property and all properties below are rejected. Note is the most common object in music21 and users who are not working with guitar music will never use these routines but will need to figure out what they mean in the docs. (we don't have "accent" or "staccato" etc. either) -- and parallel routines would need to be added to Chord, etc.
In general for any mature open-source project, don't make additions or substantive changes to core parts of the system without a prior discussion.
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.
oops sorry about that, they were just for my personal convenience. Removed with 0b2074f
|
Hello -- just as a note (from the music21list Google Group) I'm taking a sabbatical from reviewing music21 issues and PRs until at least Jan 1, 2024, so this PR will be deferred until then. |
|
Hello Michael, sorry for not being able to finish this PR sooner. Enjoy your sabbatical! Hopefully my PR will be ready for approval when you come back 🤞 |
|
Hello @mscuthbert ! I think I have addressed all your comments, let me know if there is anything I should improve further! Best, |
mscuthbert
left a comment
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 adhooge I'm realizing that for some reason you don't have permissions to run the Github Actions here automatically (I think you get them the first time you open a PR that passes)
Make sure that you're running python music21/test/multiprocessTest.py before pushing here -- you have tests that aren't passing -- as soon as I noticed that I stopped reviewing for now.
If you want to open up a dummy PR that changes one letter (like add a period somewhere it's missing) point to this comment and I'll merge it so you have full actions rights. (Or point me to some web resource that tells me how to exempt you from the hold back until you have it).
|
Hi |
|
It seems I got all the coveted green ticks! There might still be a few changes required. I'm thinking in particular about the fact that I had to import Thank you very much for your reactivity and detailed answers |
mscuthbert
left a comment
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.
Congrats! Looks great!
|
This is a really significant contribution for a first PR. Congrats! Hope it was a good enough experience that there will be many more. I'm planning on doing a release by July 1 or when we get the Piano Pedal PRs in whichever comes first. |
|
Thank you very much for your kind help throughout the process (that spanned over several years!!) I won't hesitate to contribute more in the future! |
Fixes #1471
Hi! First PR so I expect a few things to be added/modified but here's a first draft.
I've updated the
FretBendarticulation so that it includes the musicXML propertiesbendAlter,preBendandrelease.It goes round from musicXML to m21 back to mXML.
I've not written any tests yet because I'm not sure what to add. Let me know of what could be good to add!
as a PR newbie, I also have some irrelevant commits that I manually reverted. If that's a problem I'll try to clean that up.