Skip to content

[MusicXML] Fix octave-shift#34163

Open
rettinghaus wants to merge 8 commits into
musescore:mainfrom
rettinghaus:xml/octaveshift
Open

[MusicXML] Fix octave-shift#34163
rettinghaus wants to merge 8 commits into
musescore:mainfrom
rettinghaus:xml/octaveshift

Conversation

@rettinghaus

@rettinghaus rettinghaus commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Resolves: #34087

Fixes wrong (unterminated) import of ottava lines and extends support to 22va and 22ba lines. Furthermore it removes the superfluous placement for octave-shift directions.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4c86f2b4-6558-4e8e-a61d-6e28b63a9042

📥 Commits

Reviewing files that changed from the base of the PR and between e95bd0c and 9cd4eac.

📒 Files selected for processing (1)
  • src/importexport/musicxml/internal/export/exportmusicxml.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/importexport/musicxml/internal/export/exportmusicxml.cpp

📝 Walkthrough

Walkthrough

MusicXML octave-shift import and export now support size 22 and corresponding three-octave ottava types. Pitch conversion recognizes ±36-semitone deltas, while ottava serialization emits size 22 start and stop directions. Direction export no longer derives placement attributes from ottava spanners. A new octave-shift round-trip fixture and test were added, and existing expected XML fixtures were updated to omit direction placement attributes.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning It includes the issue reference and summary, but omits the required checklist and most template fields. Add the missing checklist items and any required template details, such as test, CLA, and commit notes, before merging.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and correctly summarizes the main MusicXML octave-shift fix.
Linked Issues check ✅ Passed The changes address #34087 by accepting size=22, handling stop without size, and adding round-trip coverage.
Out of Scope Changes check ✅ Passed The placement-attribute removals and test fixture updates appear tied to the ottava-shift fix, not unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were 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.

@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: 2

🤖 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/internal/import/importmusicxmlpass1.cpp`:
- Around line 3289-3297: The octave-shift size switch must distinguish the valid
stop value from other unknown sizes. Update the switch in the pass1 octave-shift
handling to map size 0 to the stop case, retain the existing mappings for 22,
15, and 8, and log an error for any other value instead of assigning sz = 1;
preserve pass2 synchronization by ensuring invalid sizes are not silently
treated as one-octave shifts.

In `@src/importexport/musicxml/tests/data/testOctaveShift.xml`:
- Around line 223-224: Add a focused MusicXML fixture or import assertion
covering an octave-shift stop element without the size attribute, alongside the
existing testOctaveShift coverage. Ensure the test verifies successful import
and the expected round-trip or canonicalized output, while retaining the
existing sized-stop cases.
🪄 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: 45df6b53-d7fe-4b54-8dc8-0317369d0e54

📥 Commits

Reviewing files that changed from the base of the PR and between 83bc55b and 9fa69b1.

📒 Files selected for processing (12)
  • src/importexport/musicxml/internal/export/exportmusicxml.cpp
  • src/importexport/musicxml/internal/import/importmusicxmlpass1.cpp
  • src/importexport/musicxml/internal/import/importmusicxmlpass2.cpp
  • src/importexport/musicxml/tests/data/testColorExport_ref.xml
  • src/importexport/musicxml/tests/data/testExcludeInvisibleElements_invisible_ref.xml
  • src/importexport/musicxml/tests/data/testExcludeInvisibleElements_noinvisible_ref.xml
  • src/importexport/musicxml/tests/data/testLayout.xml
  • src/importexport/musicxml/tests/data/testLines1.xml
  • src/importexport/musicxml/tests/data/testOctaveShift.xml
  • src/importexport/musicxml/tests/data/testOverlappingSpanners.xml
  • src/importexport/musicxml/tests/data/testTimeTickExport_ref.xml
  • src/importexport/musicxml/tests/musicxml_tests.cpp

Comment thread src/importexport/musicxml/internal/import/importmusicxmlpass1.cpp
Comment on lines +223 to +224
<octave-shift type="stop" size="8" number="1"/>
</direction-type>

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add coverage for a stop without size.

Every stop in this fixture includes size, so the new round-trip test does not verify the stated compatibility case. Add a focused import assertion or separate expected-output fixture, since export may canonicalize the stop by adding size.

Also applies to: 317-318, 411-412, 505-506, 599-600, 693-694

🤖 Prompt for 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.

In `@src/importexport/musicxml/tests/data/testOctaveShift.xml` around lines 223 -
224, Add a focused MusicXML fixture or import assertion covering an octave-shift
stop element without the size attribute, alongside the existing testOctaveShift
coverage. Ensure the test verifies successful import and the expected round-trip
or canonicalized output, while retaining the existing sized-stop cases.

Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 12, 2026
Backport of musescore#34163

Co-Authored-By: Klaus Rettinghaus <rettinghaus@users.noreply.github.com>
@miiizen miiizen self-requested a review July 13, 2026 15:24
Comment thread src/importexport/musicxml/internal/export/exportmusicxml.cpp Outdated
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Jul 14, 2026
Backport of musescore#34163

Co-Authored-By: Klaus Rettinghaus <rettinghaus@users.noreply.github.com>
Co-authored-by: James Mizen <jamesmmizen@gmail.com>
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 imports incorrect pitches for ottava

3 participants