MusicXML import attaches after-graces at the end of a voice to the first note of the next voice/staff after <backup>
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start by reproducing the provided MusicXML with MuseScore4.exe -o out.mscz grace-after-backup.musicxml, then read the grace-note handling in importmusicxmlpass2.cpp around gcl/gac, addGraceChordsAfter(), addGraceChordsBefore(), and the <backup> branch. Check how pending after-graces are flushed at voice/track changes rather than only at measure end. Done means the D5 grace imports as <grace16after/> on the voice 1 C5 while the listed controls and normal before-graces still behave.
Written by the indexing model from the issue text.
Description
Issue type
Import/export issue
Description with steps to reproduce
When a voice ends with grace notes after its last principal note and the measure continues with a <backup> into another voice (or another staff of the same part), the MusicXML importer attaches those grace notes as before-graces to the first note of the following voice/staff instead of as after-graces to the preceding chord in their own voice.
This also breaks MuseScore's own roundtrip: MuseScore Studio exports after-graces as bare <grace/> at the end of their voice, immediately before <backup>. Re-importing such an export of a piano score moves the after-graces from voice 1 / staff 1 onto the first note of staff 2 as <grace16/> before-graces.
Steps:
- Save the MusicXML below as
grace-after-backup.musicxml. - Open it in MuseScore Studio 4.7.7 (or
MuseScore4.exe -o out.mscz grace-after-backup.musicxml) and inspect the result.
<?xml version="1.0" encoding="UTF-8"?>
<score-partwise version="4.0">
<part-list><score-part id="P1"><part-name>Piano</part-name></score-part></part-list>
<part id="P1">
<measure number="1">
<attributes><divisions>1</divisions><time><beats>4</beats><beat-type>4</beat-type></time><staves>1</staves>
<clef number="1"><sign>G</sign><line>2</line></clef></attributes>
<note><pitch><step>C</step><octave>5</octave></pitch><duration>4</duration><voice>1</voice><type>whole</type><staff>1</staff></note>
<note><grace/><pitch><step>D</step><octave>5</octave></pitch><voice>1</voice><type>16th</type><staff>1</staff></note>
<backup><duration>4</duration></backup>
<note><pitch><step>A</step><octave>4</octave></pitch><duration>4</duration><voice>2</voice><type>whole</type><staff>1</staff></note>
</measure>
</part>
</score-partwise>
Expected: D5 is a grace-note-after (<grace16after/>) of the voice 1 C5.
Actual: D5 is imported as a before-grace (<grace16/>) of the voice 2 A4.
Controls (all with MuseScore Studio 4.7.7):
- Removing the
<backup>and the voice 2 note: D5 is correctly imported as<grace16after/>of C5 (the end-of-measure conversion applies). - Changing
<grace/>to<grace steal-time-previous="25"/>: still imported as a before-grace of the voice 2 A4. - Same as the example, but with two staves and the second note in voice 5 / staff 2: D5 ends up as a before-grace on staff 2.
Possible cause (based on reading importmusicxmlpass2.cpp at 08d70c1): the pending grace chord list gcl/gac is shared across voices within the measure. When the next regular note arrives in another track, measure->findChord(prevSTime, msTrack + msVoice) finds no previous chord in that track, so addGraceChordsAfter() is skipped and addGraceChordsBefore(c, gcl) attaches the pending graces to the new note. Pending after-graces are only flushed at the end of the measure, not on <backup>/voice change.
Supporting files, videos and screenshots
The minimal example is included inline above.
What is the latest version of MuseScore Studio where this issue is present?
4.7.7 (revision b750c43)
Regression
I don't know
Operating system
Windows 11 (10.0.26300)
Additional context
Related but different: #34140 (closed; slur-based after-grace detection) and #35700 (mid-measure grace group with an intra-grace slur).
Checklist
- This report follows the guidelines for reporting bugs and issues
- I have verified that this issue has not been logged before, by searching the issue tracker for similar issues
- I have attached all requested files and information to this report
- I have attempted to identify the root problem as concisely as possible, and have used minimal reproducible examples where possible
- Dominant language
- C++
- Stars
- 15.5k
- Forks
- 3.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 124
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from musescore/MuseScore
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Edit string data dialog opens empty, with no strings and 0 frets, from "Instrument/Staff properties"Possibly taken @igorkorsukov claimed this 3 days ago. OpenP2 regression nightly UX/interaction
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
musescore/MuseScore#35829 · 1 assignee ·
Maintainers usually reply within 1 day
-
MusicXML export: overlapping dashed text lines (<dashes>) are all exported with duplicate number="1"Opencommunity MusicXML
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
MusicXML import loses explicit slur direction when the stop precedes the start in document orderOpenneeds review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
needs review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
All issues in musescore/MuseScore
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 2 days
-
bug low priority
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
eclipse-score/logging#531 ·
Maintainers usually reply within 2 days
-
scope:docs status:needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PX4/PX4-Autopilot#30166 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day