Skip to content

In MusicXML, a clef with no number is for staff 1, not for all staves in a part#1905

Open
gregchapman-dev wants to merge 3 commits into
cuthbertLab:masterfrom
gregchapman-dev:gregc/clefWithoutNumberIsNotInAllStaves
Open

In MusicXML, a clef with no number is for staff 1, not for all staves in a part#1905
gregchapman-dev wants to merge 3 commits into
cuthbertLab:masterfrom
gregchapman-dev:gregc/clefWithoutNumberIsNotInAllStaves

Conversation

@gregchapman-dev
Copy link
Copy Markdown
Contributor

Looked it up, and this applies also to staff-layout and staff-details.

@coveralls
Copy link
Copy Markdown

coveralls commented May 31, 2026

Coverage Status

coverage: 93.046%. remained the same — gregchapman-dev:gregc/clefWithoutNumberIsNotInAllStaves into cuthbertLab:master

@gregchapman-dev gregchapman-dev changed the title In MusicXML, a clef with no number is for staff 1, not for all staves In MusicXML, a clef with no number is for staff 1, not for all staves in a part Jun 1, 2026
@gregchapman-dev
Copy link
Copy Markdown
Contributor Author

I thought I had a good example MusicXML file, but I was wrong. I made this fix locally several months ago, and am having trouble remembering exactly what files prompted it; I do remember realizing that there were quite a few files with this issue (non-numbered clefs in multi-staff parts) out in the wild, and I tested against Finale and Musescore, who both parsed them correctly (putting the non-numbered clef in staff 1 of a multi-staff part), where music21 was incorrectly putting the clef in both staves of a multi-staff part. I am scanning all my test files to find examples of non-numbered clefs in multi-staff parts.

@gregchapman-dev
Copy link
Copy Markdown
Contributor Author

gregchapman-dev commented Jun 2, 2026

Ah, I see. It is music21's MusicXML writer that is writing non-numbered clefs in multi-staff parts. I attach two MusicXML files, one (with clefs numbered) that was read by music21, and the other (some clefs not numbered) that was subsequently written by music21. The written MusicXML file, when read again by music21 (without this PR), ends up with the clef change incorrectly happening in both piano staves, instead of just in the right hand staff. I attach both MusicXML files, as well as PDFs of both as rendered by music21, with the extra inserted clefs called out (in red, with text notation) by musicdiff.

BrahWiMeSample.musicxml.txt
BrahWiMeSample_Written.musicxml.txt
BrahWiMeSample.pdf
BrahWiMeSample_Written.pdf

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.

2 participants