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

Fix for #547 : Initial proposal for ArpeggioMark and ArpeggioMarkSpanner classes. #1337

Merged
merged 15 commits into from Aug 6, 2022

Conversation

gregchapman-dev
Copy link
Contributor

@gregchapman-dev gregchapman-dev commented Jul 3, 2022

Fixes #547

@gregchapman-dev
Copy link
Contributor Author

MusicXML parser/writer are next (of course).

@coveralls
Copy link

coveralls commented Jul 3, 2022

Coverage Status

Coverage increased (+0.02%) to 93.1% when pulling c08321e on gregchapman-dev:gregc/arpeggio into d782d4d on cuthbertLab:master.

@gregchapman-dev
Copy link
Contributor Author

OK, support for ArpeggioMark (including m21ToXml.py and xmlToM21.py) is there. I have made no attempt to support ArpeggioMarkSpanner for cross-staff arpeggios, since I have no MusicXML examples to parse.

Can I get this reviewed, please? Maybe we can merge it as is (minus the declaration of ArpeggioMarkSpanner) and write a new issue for ArpeggioMarkSpanner?

@jacobtylerwalls jacobtylerwalls self-requested a review July 4, 2022 20:42
Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

Forgive me for doing the trivial bits of the review first, but I have takeout to go pick up :-)

music21/expressions.py Outdated Show resolved Hide resolved
music21/expressions.py Outdated Show resolved Hide resolved
music21/expressions.py Outdated Show resolved Hide resolved
music21/musicxml/m21ToXml.py Outdated Show resolved Hide resolved
Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

Gave it a more substantive look. Looking good! Noticed one potential behavior change.

music21/musicxml/m21ToXml.py Outdated Show resolved Hide resolved
music21/musicxml/test_m21ToXml.py Show resolved Hide resolved
music21/musicxml/test_xmlToM21.py Outdated Show resolved Hide resolved
music21/musicxml/xmlToM21.py Show resolved Hide resolved
music21/musicxml/xmlToM21.py Outdated Show resolved Hide resolved
@gregchapman-dev
Copy link
Contributor Author

OK, I think I've addressed all of @jacobtylerwalls' review.

Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

Great, thanks for the updates!

@gregchapman-dev
Copy link
Contributor Author

I'm still working on MusicXML parser/writer support for ArpeggioMarkSpanner (multi-chord/note arpeggios). I have the writer working (I'll push it for your perusal shortly), but I can't test it very well without the parser (well, I can, since I have a version of my Humdrum parser that can parse multi-chord arpeggios, but no-one else can, at least not very easily). On to the parser!

@gregchapman-dev
Copy link
Contributor Author

Here is the parser support for multi-chord arpeggios.

@gregchapman-dev
Copy link
Contributor Author

Hmmm. Time to write more tests.

@gregchapman-dev
Copy link
Contributor Author

OK, this should be ready for final review.

@gregchapman-dev
Copy link
Contributor Author

Once a week ping :-)
Arpeggio support is ready for final review.

music21/musicxml/m21ToXml.py Outdated Show resolved Hide resolved
music21/expressions.py Outdated Show resolved Hide resolved
music21/musicxml/m21ToXml.py Outdated Show resolved Hide resolved
music21/musicxml/m21ToXml.py Outdated Show resolved Hide resolved
@gregchapman-dev
Copy link
Contributor Author

gregchapman-dev commented Aug 1, 2022

Wow, flake8 got a lot pickier throughout music21. Hope that doesn't block me from getting this in.
Ah, flake8 v5 where it used to be flake8 v4. Big update!

@mscuthbert
Copy link
Member

ArpeggioMark is totally approved. That can be merged. Thank you!

I think from the discussion in #1142 (HammerOn, HammerOff) -- I'm still not willing to go with spanners being inside music21 objects because of the way that they're gathered -- what happens if we only show Staff 2 but the spanner is the .expressions on an object in Staff 1. If the spanner is in Staff 1, music21 is smart enough to do the right thing (or if it's not, there's one place we need to fix it). I'm also still scared by the circular reference -- note-holds-spanner-holds-note-holds-spanner...etc. And it's even harder for cases like chords (what if a chord has notes 0,1,2 in staff 1 and notes 3,4 in staff 2, but only notes 2-3 are arpeggiated?) Then we have chord holds spanner which holds notes which aren't in the Stream. I think that the general solution to the problem raised in #1142 needs to be solved before going with ArpeggioMarks inside of expressions.

Maybe there is something like a spanner that references an ordered list of other m21 objects that could be made, since the entire infrastructure of spanner doesn't seem to be needed here.

@gregchapman-dev
Copy link
Contributor Author

gregchapman-dev commented Aug 3, 2022

ArpeggioMarkSpanner is never put in obj.expressions, and shouldn't ever contain notes that are within chords. I have pushed another update to make the ArpeggioMarkSpanner docs more clear on this subject.

@mscuthbert
Copy link
Member

ArpeggioMarkSpanner is never put in obj.expressions, and shouldn't ever contain notes that are within chords. I have pushed another update to make the ArpeggioMarkSpanner docs more clear on this subject.

Ah... I totally misread this. Let me check further.

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.

Got it! This is great! A few small changes/refactors for readability, etc. then let's merge this today. (@jacobtylerwalls feel free also to merge if you see that the changes are made and I don't check in later today).

music21/musicxml/m21ToXml.py Outdated Show resolved Hide resolved
music21/musicxml/m21ToXml.py Outdated Show resolved Hide resolved
music21/musicxml/m21ToXml.py Outdated Show resolved Hide resolved
music21/musicxml/m21ToXml.py Outdated Show resolved Hide resolved
1. Sort chord in place at top of chordToXML, and get rid of all that index calculation.
2. Factor out a new method: arpeggioMarkToMxExpression.
@gregchapman-dev
Copy link
Contributor Author

I believe this is ready to go (I hope!)

mxArpeggio = Element('non-arpeggiate')
mxArpeggio.set('type', 'bottom')
elif topNoteIndex == noteIndexInChord:
elif noteIndexInChord == len(obj.notes):
Copy link
Member

Choose a reason for hiding this comment

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

this will never happen, off by one error. len(obj.notes) - 1 can we have a test to make sure these are generated correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, my multiStaffArpeggio test doesn't have any non-arpeggiates in it. I'll fix that (and then this bug).

Copy link
Member

Choose a reason for hiding this comment

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

it's in my newest PR

@mscuthbert
Copy link
Member

Unfortunately, after adding some tests, the ArpeggioMarkSpanner for non-arpeggiate is not working, because the marks don't go on the lowest and highest notes of a single chord, but the lowest and highest notes of the entire ArpeggioMarkSpanner, so we'll need to extract that information instead.

@mscuthbert
Copy link
Member

It's working now. Just need to lint

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.

Support <arpeggiate/> for xmlToM21.py
4 participants