Skip to content

Import explicit MusicXML sound jump attributes regardless of inferTextType#33802

Open
jonashogstrom wants to merge 1 commit into
musescore:mainfrom
jonashogstrom:fix-musicxml-explicit-sound-repeats
Open

Import explicit MusicXML sound jump attributes regardless of inferTextType#33802
jonashogstrom wants to merge 1 commit into
musescore:mainfrom
jonashogstrom:fix-musicxml-explicit-sound-repeats

Conversation

@jonashogstrom

@jonashogstrom jonashogstrom commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Resolves: #33801

The <sound> element attributes dacapo, dalsegno, fine, segno, coda and tocoda are the explicit, machine-readable MusicXML representation of jump/marker semantics. Since 07eb65e they were only imported when the "Infer text type based on content where possible" preference (default off) was enabled, because the entire handleRepeats() function was gated behind it. With default settings, such directions were imported as plain StaffText, so playback and MIDI export silently ignored the jumps.

This PR restructures handleRepeats() so that the explicit <sound> attribute handling always runs, and only the purely text-based matchRepeat() fallback depends on the preference. Additionally, the words accompanying a dacapo/dalsegno sound attribute may now refine the jump type within the same family: "D.C. al Fine" with dacapo="yes" imports as a D.C. al Fine jump (stopping at the Fine marker) instead of a plain D.C. that plays to the end, and "D.S. al Coda" with dalsegno imports as a D.S. al Coda jump that actually takes the coda.

Test changes:

  • New test dcalFineNoInferTextType verifies that a DC_AL_FINE jump and FINE marker are created with importInferTextType = false (previously no Jump/Marker was created at all; the existing tests force the preference on, which is why CI never caught this).
  • testDSalCoda_ref.mscx / testDSalCodaMisplaced_ref.mscx regenerated: the "D.S. al Coda" jump now has playUntil=coda / continueAt=codab instead of playUntil=end / continueAt="" (the old references enshrined a jump that never took the coda).
  • dcalCoda converted from a roundtrip test to a reference comparison: the exported <sound tocoda> value is now linked to the coda marker's label (tocoda="codab" matching coda="codab") instead of the unlinked tocoda="1" in the source file.

Verified end-to-end: a 4-measure score (C ‖: D E :‖ F with Fine after m.1 and D.C. al Fine in m.4) now exports MIDI as C D E D E F C with default settings; previously it produced C D E D E F (jump dropped), or C D E D E F C D E F with the preference enabled (jump taken but Fine ignored).

  • I signed the CLA as jonas.hogstrom
  • The title of the PR describes the problem it addresses.
  • Each commit's message describes its purpose and effects, and references the issue it resolves. If changes are extensive, there is a sequence of easily reviewable commits.
  • The code in the PR follows the coding rules.
  • I understand all aspects of the code I'm contributing and I'm able to explain it if requested.
  • The code compiles and runs on my machine, preferably after each commit individually. I have manually tested and verified that my changes fulfil their intended purpose.
  • No prior attempts to resolve this problem exist, or if they do, I listed them in my PR description and described how I avoided repeating past mistakes.
  • There are no unnecessary changes.
  • I created a unit test or vtest to verify the changes I made (if applicable).

…tType

The <sound> element attributes dacapo, dalsegno, fine, segno, coda and
tocoda are the explicit, machine-readable MusicXML representation of
jump/marker semantics. They were only imported when the "infer text type"
preference (default off) was enabled, because the entire handleRepeats()
function was gated behind it, so with default settings these directions
were imported as plain staff text and playback ignored the jumps.

Now only the purely text-based matchRepeat() fallback depends on the
preference. Additionally, the words accompanying a dacapo/dalsegno sound
attribute may refine the jump type, so "D.C. al Fine" with dacapo="yes"
imports as a D.C. al Fine jump (stopping at the Fine marker) instead of
a plain D.C. that plays to the end.

Resolves: musescore#33801

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR refactors repeat type recognition in MusicXML import. The handleRepeats method now unconditionally processes explicit repeat types from <sound> attributes (coda, da capo, dal segno, fine, segno, to coda) regardless of text inference configuration. Text-based fallback detection (matchRepeat) is only applied when text inference is enabled. Test coverage was expanded with new fixtures for D.C. al Coda scenarios and a validation test confirming explicit recognition works without text inference.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the core change: allowing explicit MusicXML sound jump attributes to be imported regardless of the inferTextType preference.
Linked Issues check ✅ Passed The PR fully addresses issue #33801: explicit attributes are always handled, text-based fallback gated by preference, words refine jump types, tests updated for default-preference path, and end-to-end MIDI behavior verified.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the linked issue: the core logic fix in handleRepeats(), new test dcalFineNoInferTextType, reference regeneration, and test harness updates—no unrelated modifications present.
Description check ✅ Passed The PR description comprehensively covers all required template sections with detailed explanations of the changes, motivation, and testing approach.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Linked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped musescore/muse_framework.git.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/importexport/musicxml/tests/musicxml_tests.cpp`:
- Around line 532-560: The test dcalFineNoInferTextType mutates the global
preference PREF_IMPORT_MUSICXML_INFERTEXT via setValue(false) and doesn't
restore it, risking cross-test leakage; fix by capturing the current preference
(via the getter used in tests) before calling setValue and restoring it at the
end of the test (or ensure the test fixture teardown resets
PREF_IMPORT_MUSICXML_INFERTEXT to its original value) so the global state is
always restored even if an ASSERT_* aborts the test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 07dd6dc0-e250-4281-936e-a85e41806699

📥 Commits

Reviewing files that changed from the base of the PR and between d53a8ed and cfddbc8.

📒 Files selected for processing (5)
  • src/importexport/musicxml/internal/import/importmusicxmlpass2.cpp
  • src/importexport/musicxml/tests/data/testDCalCoda_ref.xml
  • src/importexport/musicxml/tests/data/testDSalCodaMisplaced_ref.mscx
  • src/importexport/musicxml/tests/data/testDSalCoda_ref.mscx
  • src/importexport/musicxml/tests/musicxml_tests.cpp

Comment thread src/importexport/musicxml/tests/musicxml_tests.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants