More accurate spanner stop/start on musicxml import#1768
More accurate spanner stop/start on musicxml import#1768gregchapman-dev wants to merge 52 commits into
Conversation
…o longer trip over intervening <backup> and <forward> elements, and also so we take into account the offset attribute of the direction.
…here they were assigned.
…e endElement.offset and endElement.activeSite, which are cleared by the operation.
MusicXML export: final <forward> jump to end of measure was jumping too far.
|
Time to work on some test coverage. |
|
@mscuthbert This is ready for review. |
…fsets, making sure that (1) the spanners in the two imported scores have the same offsets in the score, and (2) that there are no overlapping GeneralNotes in the streams containing either end of each spanner.
mscuthbert
left a comment
There was a problem hiding this comment.
Hi Greg -- sorry to take some time on this. I'm noticing some changes on Crescendo attachment that I want to discuss a bit more -- returning to conversation.
| since bwv66.6 uses it) | ||
|
|
||
| * New in v7. | ||
| * New in v7. Stubbed out in v9.7. |
There was a problem hiding this comment.
For stubbed out, say "deprecated in v9.7 (not needed, so does nothing. To be removed in v10.0)"
|
I was being a bit lazy, perhaps? I can use self.nLast as the start element of a direction spanner, but only if it has the correct offset. Same with "whatever the next GeneralNote is", but that logic will be a bit trickier, since when that next note shows up is potentially a fair bit later (and in a few different places in the code), and we'll need to have the "correct offset" info saved off somewhere, so we can (1) check it, and (2) create and insert a SpannerAnchor at the correct offset if necessary. I'm not sure what happened to fill(), but I will say that it is used successfully for Ottavas all the time (so that transpose() can work properly), with a Stream argument (if you don't pass in a Stream, it falls back to using getFirst().activeSite). So perhaps the no-stream-argument case isn't well-tested (or activeSite was not the stream you wanted). I'll take a look. I will work on making both of these changes (only use SpannerAnchors if you have to, and fix Spanner.fill as necessary). |
|
Thanks! re fill(): Yeah, I don't see an example in the docs of filling between multiple measures so it's possible that hadn't been properly implemented. sigh. :-D |
…les where there is NO next note after a spanner start.
|
I think that fill() should require a stream argument (and perhaps allow a list of streams, for the case where pedal marks should be filled from both left and right hand staves of a piano part within an orchestral score). I think I was being too helpful when I allowed None, implying sp.getFirst().activeSite. That's almost never useful. |
|
Sigh... I merged 9.7.1 (master) back into this PR, and tests are failing. I'll investigate. |
I'm so sorry -- I don't remember making changes that were supposed to affect this. |
|
Oh I'm definitely not blaming you! My current theory is a bad merge (user error, or git error). I'll figure it out. |
|
It was indeed a bad merge of xmlToM21.py. |
|
@mscuthbert this is ready for review (unless you want me to remove the makeRests change). |
|
Converting to draft, waiting for the split-out PRs to land. Then I'll remerge, and make sure everything still tests clean. First step is to remove the makeRests change that was rejected. |
|
Hi -- is this about fixing behavior if |
|
No, now that I have removed the makeRests change you rejected, this PR no longer has anything to do with makeNotation=False. (I will double check the diffs to be sure.) |
|
For the record, run_tests (3.12) failure was a "coveralls is not responding" error. Hopefully that will be fixed well before I turn this back into a non-draft PR. |
…reAccurateSpannerStartStop
|
Greg -- I'm so sorry that I've let all this stall for a year -- after PyCon I want to look again. Thanks! |
|
I'm actually no longer sure that supporting offset fully for MusicXML elements is a good idea. Sometimes it's really important (e.g. I've seen pedal marks in MusicXML files that will miss a spanner element without it), and sometimes it's not so smart (e.g. I've seen directions in MusicXML files that are just being shifted left for typographical reasons, including to a negative offset within the measure). What do you think? |
|
|
I think that since Finale 2010ish and definitely in modern software like Dorico (and I think MuseScore), there is now an easy way of distinguishing between moving an element for typographical reasons and doing it for offset/playback reasons, so I think going forward more and more musicxml files will have correct offset elements, so we should respect it. Nice to have feature later would be to be able to pass converter.parse('x.xml', ignoreDirectionOffsets=True) so those old scores work out better -- but that's definitely a different PR/downstream. Let me know if you're on board with the new staffKey handling or if we need to think of something else. Oh, and xmlToM21.py line 8 addition in my recent push is long-long overdue. |

Import of
<direction>spanners now always generate SpannerAnchors, and take direction@offset into account. This also fixes some bugs where self.nLast and "whatever the next GeneralNote is" weren't the right things to use.Export of SpannerAnchor-based spanners produces "extra jumpy" MusicXML files (lots more
<backup>and<forward>elements), which are valid, but unusual, and import of those "extra jumpy" files needed some fixing here as well.