Skip to content

Fix bar counting and markup placement in MusicXML export - #193

Open
FelippeRoza wants to merge 1 commit into
masterfrom
fix-failing-xml-tests
Open

FelippeRoza wants to merge 1 commit into
masterfrom
fix-failing-xml-tests

Conversation

@FelippeRoza

Copy link
Copy Markdown
Collaborator

test_partial and test_markup pass now, so the xfail markers are gone. Fixes #174.

Both broke at 5d89981. Bars close on accumulated note duration, not barchecks, and
several things were miscounted:

  • set_pickup() discarded the \partial duration, so the pickup bar swallowed the next
    measure. Now <measure number="0" implicit="yes">.
  • Note-attached markup is parsed after its note, so it landed one measure late. Now
    detected from its Postfix parent.
  • Chord notes after the first, and grace notes, went into the wrong bar. Both pre-existing.
  • \partial and bar duration leaked between parts.

chord_duration.xml regenerated: its expectation held the split chord (#171). A tuplet
closing a pickup bar still splits (#124).

The xfail tests test_partial and test_markup both broke at 5d89981. Bars
close on accumulated note duration rather than at barchecks, and several
things were not counted right:

* set_pickup() discarded the \partial duration, so the pickup bar never
  closed and swallowed the measure after it. Its length is now recorded
  and used, and the bar is exported as
  <measure number="0" implicit="yes">.
* Note-attached markup is parsed after its note, so it landed one measure
  late and texts from different bars were concatenated into one <words>.
  Whether a markup trails its note is now taken from its Postfix parent
  instead of the current bar's contents.
* Chord notes after the first were added to whichever bar was current by
  then, leaving an orphaned <chord/> opening the next measure.
* Grace notes were counted toward bar duration, so one could close a bar
  on its own and strand itself with no principal note to ornament.
* \partial and bar duration leaked from one part into the next.

The last three happen without \partial too. chord_duration.xml is
regenerated because its expectation held the split chord it was added to
catch in #171.

Fixes #174
wang1zhen pushed a commit to wang1zhen/python-ly that referenced this pull request Oct 7, 2026
The postfix events after a note (-., ^\markup, ...) follow the note in
the music tree, so the note was completed before them. When the note
completed a measure, its markup was put in the next measure, together
with the markup of that one.

The postfix events are now part of the note they follow, as for the
\rest command. This makes test_markup pass; the case with a \mark is
from frescobaldi#193, which addresses the same problem.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMyxTwm2w6VtbxBdt5dL1T

This branch has not been deployed

No deployments
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.

MusicXML: failing tests

1 participant