Fix invalid MusicXML for an unpitched grace note in a voice#1973
Merged
jacobtylerwalls merged 2 commits intoJul 5, 2026
Merged
Conversation
unpitchedToXml inserted <unpitched> before the earliest of <duration> or <type>, but a grace note has no <duration>, so anything noteToXml had appended in between (voice, tie, instrument, footnote, level) came out ahead of <unpitched> and the file failed schema validation. List every element that can follow <unpitched> within <note> so the insertion point is right with or without a duration. Bump version to 11.0.0b7 for the musicxml writer change. Fixes cuthbertLab#1732.
8f651af to
c9ffb2a
Compare
jacobtylerwalls
left a comment
Member
There was a problem hiding this comment.
Thanks for the PR -- One question for your consideration.
Only <grace>, <cue>, and <chord> may precede <unpitched> within <note>, so a new insertAfterElements helper places it after those instead of maintaining a list of everything that can follow it.
Member
|
Thanks all. This is great! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1732. Following up on the September 2024 comment that you'd be glad to take a fix for this one.
An unpitched grace note in a voice exported
<voice>ahead of<unpitched>, which fails schema validation, since<unpitched>has to come right after<grace>in the note content model.unpitchedToXmlretrofits<unpitched>into the already-built<note>by inserting before the earliest of<duration>or<type>, but a grace note has no<duration>, so anythingnoteToXmlhad appended in between slipped ahead. The tagList now lists every element that can follow<unpitched>within<note>, which also fixes the same misplacement for a tied grace note (<tie>landed ahead of<unpitched>too).Before, from the issue's repro:
After:
Added a doctest for the voice case, a regression test in test_m21ToXml.py, and bumped the version to 11.0.0b7 for the writer change. pylint (10.00/10), ruff, mypy, and the musicxml module tests all pass locally.