Import explicit MusicXML sound jump attributes regardless of inferTextType#33802
Import explicit MusicXML sound jump attributes regardless of inferTextType#33802jonashogstrom wants to merge 1 commit into
Conversation
…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>
📝 WalkthroughWalkthroughThis PR refactors repeat type recognition in MusicXML import. The 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsLinked repositories: Your configuration references 1 linked repositories, but your current plan allows 0. Analyzed ``, skipped 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
src/importexport/musicxml/internal/import/importmusicxmlpass2.cppsrc/importexport/musicxml/tests/data/testDCalCoda_ref.xmlsrc/importexport/musicxml/tests/data/testDSalCodaMisplaced_ref.mscxsrc/importexport/musicxml/tests/data/testDSalCoda_ref.mscxsrc/importexport/musicxml/tests/musicxml_tests.cpp
…tType Backprt of musescore#33802 Co-Authored-By: Jonas Högström <jonas.hogstrom@pobox.com>
Resolves: #33801
The
<sound>element attributesdacapo,dalsegno,fine,segno,codaandtocodaare 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 entirehandleRepeats()function was gated behind it. With default settings, such directions were imported as plainStaffText, 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-basedmatchRepeat()fallback depends on the preference. Additionally, the words accompanying adacapo/dalsegnosound attribute may now refine the jump type within the same family: "D.C. al Fine" withdacapo="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" withdalsegnoimports as a D.S. al Coda jump that actually takes the coda.Test changes:
dcalFineNoInferTextTypeverifies that aDC_AL_FINEjump andFINEmarker are created withimportInferTextType = 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.mscxregenerated: the "D.S. al Coda" jump now hasplayUntil=coda/continueAt=codabinstead ofplayUntil=end/continueAt=""(the old references enshrined a jump that never took the coda).dcalCodaconverted from a roundtrip test to a reference comparison: the exported<sound tocoda>value is now linked to the coda marker's label (tocoda="codab"matchingcoda="codab") instead of the unlinkedtocoda="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 Cwith default settings; previously it producedC D E D E F(jump dropped), orC D E D E F C D E Fwith the preference enabled (jump taken but Fine ignored).