Skip to content

fix(musicxml): correct barre fret export for shifted chord diagrams#32959

Open
skoliveira wants to merge 1 commit intomusescore:masterfrom
skoliveira:master
Open

fix(musicxml): correct barre fret export for shifted chord diagrams#32959
skoliveira wants to merge 1 commit intomusescore:masterfrom
skoliveira:master

Conversation

@skoliveira
Copy link
Copy Markdown

@skoliveira skoliveira commented Apr 8, 2026

Barre notes written via the 'unwritten barres' fallback path in writeMusicXml(FretDiagram) were emitting relative fret numbers instead of absolute ones, while every other code path (dots, first-fret tag) correctly applied fretOffset.

This caused any chord diagram with first-fret > 1 to render the barre at the wrong position in importing applications.

Fix: add item->fretOffset() to the fret value in both the bStarts and bEnds loops, consistent with how dot frets are already handled.

Example: a Csus4 barre at position 3 (fretOffset=2) was exporting fret=1 instead of the correct fret=3.

Fixes: barre chords in all shifted chord diagrams (first-fret > 1)

Resolves: #32958

  • I signed the CLA
  • 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
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

The MusicXML export for FretDiagram objects now adds the diagram's fretOffset() when writing <fret> values for barre-related frame-note elements. In writeMusicXml(const FretDiagram* item, XmlWriter& xml), both loops emitting barre start notes and barre end notes use j + item->fretOffset() instead of j, so exported <fret> entries reflect the diagram's fret offset.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 clearly and concisely describes the main change: correcting barre fret export for shifted chord diagrams, which is the primary objective of the PR.
Linked Issues check ✅ Passed The code changes directly address the core requirement from issue #32958: applying fretOffset() to barre fret exports to use absolute numbering, matching non-barre note handling.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the barre fret export issue; no unrelated modifications or out-of-scope changes are present in the changeset.
Description check ✅ Passed PR description comprehensively covers the bug, its impact, the implemented fix, and references the resolved issue #32958. All required template sections are completed with checkboxes marked appropriately.

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

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

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.

Barre notes written via the 'unwritten barres' fallback path in
writeMusicXml(FretDiagram) were emitting relative fret numbers
instead of absolute ones, while every other code path (dots,
first-fret tag) correctly applied fretOffset.

This caused any chord diagram with first-fret > 1 to render the
barre at the wrong position in importing applications.

Fix: add item->fretOffset() to the fret value in both the
bStarts and bEnds loops, consistent with how dot frets are
already handled.

Example: a Csus4 barre at position 3 (fretOffset=2) was
exporting fret=1 instead of the correct fret=3.

Fixes: barre chords in all shifted chord diagrams (first-fret > 1)
@skoliveira skoliveira reopened this Apr 13, 2026
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.

Barre chord fret data export in MusicXML — absolute vs. relative frets

2 participants