Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a bug in musicxml/partStaffExporter.py where a clef-octave-change… #1334

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions music21/musicxml/partStaffExporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ def setEarliestAttributesAndClefsPartStaff(self, group: StaffGroup):
Multiple meters (not very well supported by MusicXML readers):

>>> from music21.musicxml import testPrimitive
>>> s = converter.parse(testPrimitive.pianoStaffPolymeter)
>>> s = converter.parse(testPrimitive.pianoStaffPolymeterWithClefOctaveChange)
>>> SX = musicxml.m21ToXml.ScoreExporter(s)
>>> root = SX.parse()
>>> m1 = root.find('part/measure')
Expand All @@ -529,8 +529,9 @@ def setEarliestAttributesAndClefsPartStaff(self, group: StaffGroup):
<line>2</line>
</clef>
<clef number="2">
<sign>F</sign>
<line>4</line>
<sign>G</sign>
<line>2</line>
<clef-octave-change>-1</clef-octave-change>
</clef>
</attributes>
...
Expand Down Expand Up @@ -615,6 +616,10 @@ def isMultiAttribute(m21Class: t.Type[M21ObjType],
newLine.text = (foundLine.text
if (foundLine := oldClef.find('line')) is not None
else '')
foundOctave = oldClef.find('clef-octave-change')
if foundOctave is not None:
newOctave = SubElement(newClef, 'clef-octave-change')
newOctave.text = foundOctave.text
helpers.insertBeforeElements(
mxAttributes,
newClef,
Expand Down
53 changes: 53 additions & 0 deletions music21/musicxml/testPrimitive.py
Original file line number Diff line number Diff line change
Expand Up @@ -18115,6 +18115,59 @@
</score-partwise>
'''

# pianoStaffPolymeterWithClefOctaveChange is a copy of pianoStaffPolymeter (above)
# with clef #2 changed from BassClef to Treble8vbClef.

pianoStaffPolymeterWithClefOctaveChange = (
'''<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 0.6b Partwise//EN"
"http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise>
<identification>
<miscellaneous>
<miscellaneous-field name="description">Polymeter on a grand staff</miscellaneous-field>
</miscellaneous>
</identification>
<part-list>
<score-part id="P1">
<part-name>MusicXML Part</part-name>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>96</divisions>
<key><fifths>0</fifths></key>
<time number="1"><beats>4</beats><beat-type>4</beat-type></time>
<time number="2"><beats>2</beats><beat-type>2</beat-type></time>
<staves>2</staves>
<clef number="1"><sign>G</sign><line>2</line></clef>
<clef number="2">
<sign>G</sign>
<line>2</line>
<clef-octave-change>-1</clef-octave-change>
</clef>
</attributes>
<note>
<pitch><step>F</step><octave>4</octave></pitch>
<duration>384</duration>
<voice>1</voice>
<type>whole</type>
<staff>1</staff>
</note>
<backup><duration>384</duration></backup>
<note>
<pitch><step>B</step><octave>2</octave></pitch>
<duration>384</duration>
<voice>2</voice>
<type>whole</type>
<staff>2</staff>
</note>
</measure>
</part>
</score-partwise>
''')


ALL = [
Copy link
Member

Choose a reason for hiding this comment

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

@gregchapman-dev you might add this to ALL when you have a chance.

articulations01, pitches01a, directions31a, lyricsMelisma61d, notations32a, # 0
Expand Down