MusicXML: `<sound dacapo="yes"/>` with a `<sound tocoda>` elsewhere plays to the end after the da capo instead of jumping to the coda
Is there an existing issue for this?
- [x] I have searched the existing issues
I have read the contribution rules
- [x] I have read CONTRIBUTING.md and, if any AI agent helped draft this issue, AGENTS.md.
AI authorship
AI-assisted (disclosure block included as described in AGENTS.md)
Current Behavior
[!NOTE] AI-authored disclosure (
alphatab-ai-authored-v1)Portions of this content were authored by an AI agent. The agent has read AGENTS.md and the human submitter accepts responsibility for compliance with the rules in that document.
A MusicXML score with a To Coda mark (<sound tocoda="coda1"/>) in bar 2, a
D.C. al Coda (<sound dacapo="yes"/>) in bar 3 and the Coda
(<sound coda="coda1"/>) in bar 4 plays
1 2 3 1 2 3 4
After the da capo, playback runs past the To Coda mark and through bar 3 again, and only then reaches the coda. The imported directions are
2: JumpDaCoda, 3: JumpDaCapo, 4: TargetCoda
(In this repro the <sound> elements are direct children of <measure>, so
that they are imported at all; see the separate report about
<direction>-level <sound>.)
Expected Behavior
1 2 3 1 2 4
In MusicXML the "al Coda" is not a separate attribute. "D.C. al Coda" is
expressed as dacapo on the D.C. bar plus tocoda on the bar where the jump
to the coda happens; tocoda applies on the pass after the da capo or dal
segno (https://www.w3.org/2021/06/musicxml40/musicxml-reference/elements/sound/).
Likewise dalsegno + tocoda means "D.S. al Coda", and dacapo/dalsegno
finemeans "al Fine". MuseScore, which wrote the real files we see this with, plays them that way. The same score entered in alphaTex with\jump DaCapoAlCodaplays1 2 3 1 2 4.
Steps To Reproduce
- Save this as
repro.musicxml(or unzip the included repro.zip)
<?xml version="1.0" encoding="UTF-8"?>
<score-partwise version="4.0">
<part-list><score-part id="P1"><part-name>Music</part-name></score-part></part-list>
<part id="P1">
<measure number="1">
<attributes><divisions>1</divisions><key><fifths>0</fifths></key><time><beats>4</beats><beat-type>4</beat-type></time><clef><sign>G</sign><line>2</line></clef></attributes>
<note><pitch><step>C</step><octave>4</octave></pitch><duration>4</duration><voice>1</voice><type>whole</type></note>
</measure>
<measure number="2">
<direction placement="above"><direction-type><words>To Coda</words></direction-type></direction>
<sound tocoda="coda1"/>
<note><pitch><step>D</step><octave>4</octave></pitch><duration>4</duration><voice>1</voice><type>whole</type></note>
</measure>
<measure number="3">
<direction placement="above"><direction-type><words>D.C. al Coda</words></direction-type></direction>
<sound dacapo="yes"/>
<note><pitch><step>E</step><octave>4</octave></pitch><duration>4</duration><voice>1</voice><type>whole</type></note>
</measure>
<measure number="4">
<direction placement="above"><direction-type><coda/></direction-type></direction>
<sound coda="coda1"/>
<note><pitch><step>F</step><octave>4</octave></pitch><duration>4</duration><voice>1</voice><type>whole</type></note>
</measure>
</part>
</score-partwise>
-
Load it with the player enabled and print
api.tickCache.masterBars.map(m => m.masterBar.index + 1).join(' ')or press play and follow the cursor.
-
Observe
1 2 3 1 2 3 4.
Link to jsFiddle, CodePen, Project
No response
Version and Environment
[AlphaTab][VersionInfo] alphaTab 1.8.4
[AlphaTab][VersionInfo] commit: 022a45c8e42370f9e12e68949d11eada370da83d
[AlphaTab][VersionInfo] build date: 2026-07-05T14:46:18.224Z
[AlphaTab][VersionInfo] High DPI: 1
[AlphaTab][VersionInfo] Platform: Browser
[AlphaTab][VersionInfo] WebPack: false
[AlphaTab][VersionInfo] Vite: false
[AlphaTab][VersionInfo] Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36
[AlphaTab][VersionInfo] Window Size: 2560x1392
[AlphaTab][VersionInfo] Screen Size: 2560x1440
(also reproduced on Firefox/155.0)
Platform
Web
Anything else?
Related to the report about <sound> inside <direction> not being imported
(#2859). Real-world source: MuseScore Studio 4.7.4 exports of choral pieces with
D.C. al Coda.
Thanks for the detailed report. I dug into this and want to share what I found before deciding what to do.
MusicXML spec
The MusicXML 4.0 spec doesn't actually define an "al Coda" semantic. The <sound> reference only documents two independent attributes with pass-default hints:
dacapo: "the jump should occur the first time through"tocoda: "the jump should occur the second time through"
There's no wording that says these two combine into al-Coda, no definition of what "times through a bar" means when jumps are involved, and no rule for how the attributes chain. Michael Good himself acknowledged in w3c/musicxml#322 that jump documentation is thin. So the framing in the issue reads like a spec citation but really it's an interpretation.
It's also worth being precise about the <words>D.C. al Coda</words> element. From a MusicXML perspective that's opaque text — a rendering hint about a string to print on the score with a given font, size and placement. The format doesn't parse it, doesn't attach any playback meaning to it, and doesn't distinguish it from <words>Andante</words> or <words>with feeling</words>. Two files with identical <sound> attributes and different <words> content are semantically identical as far as the format is concerned. So the intuition "the sheet clearly says 'D.C. al Coda', therefore the file expresses al-Coda" is a reasonable human reading of the printed score, but it isn't something MusicXML itself encodes. All the playback intent has to come from the <sound> attributes, and those only carry what the spec says they carry.
What the tools actually do
| Environment | Playback |
|---|---|
| MuseScore, native jump markers on a fresh file | 1 2 3 1 2 4 |
| MuseScore, its own MusicXML export re-imported | 1 2 3 4 |
MuseScore, importing the repro.musicxml from this issue |
1 2 3 4 |
| Guitar Pro, native jump markers on a fresh file | 1 2 3 1 2 4 |
| Guitar Pro, importing any of the tested MusicXML files | 1 2 3 4 |
| alphaTab, importing the Guitar Pro file with native jumps | 1 2 3 1 2 4 |
alphaTab, importing the repro.musicxml from this issue |
1 2 3 1 2 3 4 |
Both editors get it right natively, but none of the MusicXML importers — including MuseScore's own — reproduce 1 2 3 1 2 4 from the file. Every importer plays through without the al-Coda semantic. alphaTab plays 1 2 3 1 2 3 4, which honors each <sound> jump attribute exactly once in file order.
Where that leaves it
So this isn't really a spec-conformance bug, and it's not an interop parity fix either — there's no reference MusicXML consumer we'd be aligning to. It could be argued as a heuristic ("if dacapo and tocoda co-occur, map to JumpDaCapoAlCoda"), but doing that would make alphaTab an outlier producing different playback from every other tool for the same file, with nothing in the spec to point at.
My inclination is to leave the MusicXML importer as-is and treat this as expected behavior. For al-Coda playback, the paths that already work are the Guitar Pro import and alphaTex \jump DaCapoAlCoda.
That said, I don't want to close this too quickly. If you can find any of the following, I'll happily reopen the discussion:
- Actual spec text (not tutorials or issue discussions) that names the
dacapo+tocodacomposition or defines al-Coda for the format. - A MusicXML consumer — not an editor's native playback — that reads the repro file and produces
1 2 3 1 2 4, so there's a real convention to align to. - A MuseScore export where the jumps come with explicit
time-onlyvalues encoding the al-Coda pass semantics. That would be a narrow, well-defined thing to honor.
I'll give it some time. If nothing along those lines turns up, I'll close as expected behavior.