Skip to content
Closed
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
73 changes: 73 additions & 0 deletions music21/musicxml/test_xmlToM21.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,79 @@ def testImpliedTuplet(self):
tuplets = [n.duration.tuplets[0] for n in s.recurse().notes]
self.assertEqual([tup.bracket for tup in tuplets], [True, True, True, False, False, False])

def testTremoloImpliedTuplet(self):
'''
Test that between-note tremolos with time-modification of 2:1 do not
get tuplets with show-number None, as they should not be drawn as
tuplets.
'''
from music21 import converter

mxString = '''<?xml version="1.0" encoding="UTF-8"?>
<score-partwise version="4.0">
<part-list>
<score-part id="P1">
<part-name>P</part-name>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>256</divisions>
<time>
<beats>2</beats>
<beat-type>2</beat-type>
</time>
<clef>
<sign>F</sign>
<line>4</line>
</clef>
</attributes>
<note>
<pitch>
<step>E</step>
<octave>3</octave>
</pitch>
<duration>512</duration>
<voice>1</voice>
<type>whole</type>
<time-modification>
<actual-notes>2</actual-notes>
<normal-notes>1</normal-notes>
</time-modification>
<notations>
<ornaments>
<tremolo type="start">4</tremolo>
</ornaments>
</notations>
</note>
<note>
<pitch>
<step>G</step>
<octave>3</octave>
</pitch>
<duration>512</duration>
<voice>1</voice>
<type>whole</type>
<time-modification>
<actual-notes>2</actual-notes>
<normal-notes>1</normal-notes>
</time-modification>
<notations>
<ornaments>
<tremolo type="stop">4</tremolo>
</ornaments>
</notations>
</note>
</measure>
</part>
</score-partwise>'''

s = converter.parse(mxString, format='musicxml')
tuplets = [n.duration.tuplets[0] for n in s.recurse().notes]
self.assertEqual([tup.bracket for tup in tuplets], [False, False])
self.assertEqual([tup.tupletActualShow for tup in tuplets], [None, None])

def test34MeasureRestWithoutTag(self):
from xml.etree.ElementTree import fromstring as EL

Expand Down
3 changes: 3 additions & 0 deletions music21/musicxml/xmlToM21.py
Original file line number Diff line number Diff line change
Expand Up @@ -4833,6 +4833,9 @@ def xmlToTuplets(self, mxNote: ET.Element) -> list[duration.Tuplet]:
remainderFraction.numerator)
remainderTuplet.durationNormal = timeModTup.durationNormal
remainderTuplet.durationActual = timeModTup.durationActual
remainderTuplet.bracket = False
remainderTuplet.tupletActualShow = None
remainderTuplet.tupletNormalShow = None
returnTuplets[-1] = remainderTuplet

# now we can remove stops for future notes.
Expand Down
Loading