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

Store "numbered ending" within barline #1686

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

Conversation

OmreeG
Copy link

@OmreeG OmreeG commented Feb 7, 2024

When parsing musicxml files which contain numbered endings, it would be nice to be able to access them within the "Measure" object.
I believe one reasonable way to do this would be to store the numbered ending in the Barline
object, be it a "Repeat" or not. Then it is easily accessed by the "numberedEnding" field.

Copy link
Member

@mscuthbert mscuthbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi OmreeG -- thanks for the first contribution to the project. I have some concerns about the code, but more about the general concept here. What does this solve that isn't better solved by calling .getContextByClass(spanner.RepeatBracket).number on the measure object? This way if the RepeatBracket's number is changed then the information propagates to all other sources.

Since it's a niche use case that hasn't come up for discussion before and there is an easy way to solve it, I'm inclined to reject the PR (But so grateful for the contribution!)

Comment on lines +162 to +163
def setNumberedEnding(self, value):
self.numberedEnding = value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Python we don't generally use setters for things that can be set directly.

@@ -129,6 +129,8 @@ class Barline(base.Music21Object):
classSortOrder = -5

equalityAttributes = ('type', 'pause', 'location')

numberedEnding = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All new attributes need to be typed. numberedEnding: int | None = None

@@ -4825,6 +4825,7 @@ def xmlBarline(self, mxBarline):
# barline objects also store ending objects, that mark begin
# and end of repeat bracket designations
mxEndingObj = mxBarline.find('ending')
barline.setNumberedEnding(mxEndingObj)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What type of variable is this storing? Is it a str? int?

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