You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem summary
Voices that don't fill the measure are represented in MusicXML with <forward> tags, from which m21 creates hidden rests. The hidden rests are made late enough that they never get a staffReference, and so they are not excluded during PartStaff separation, and so we get hidden rests in both parts.
More information
This was the existing bug I was referring to in #986 (comment), discovered while working on #986.
Suggested fix
This diff fixes it, but I'm not convinced it's the best place to do this checking. (And it needs refactoring to pass the Pylint check for nested blocks.) Perhaps we should just create hidden rests in xmlForward() instead of relying on makeRests() after the fact? The problem with that is that <forward> tags don't have staff numbers. AH -- they do!
diff --git a/music21/musicxml/xmlToM21.py b/music21/musicxml/xmlToM21.py
index 35faa2ea5..3b6034ba6 100644
--- a/music21/musicxml/xmlToM21.py+++ b/music21/musicxml/xmlToM21.py@@ -2385,12 +2385,36 @@ class MeasureParser(XMLParserBase):
# the musicDataMethods use insertCore, thus the voices need to run
# coreElementsChanged
v.coreElementsChanged()
+ elementsBefore = v.elements
# Fill mid-measure gaps, and find end of measure gaps by ref to measure stream
# https://github.com/cuthbertlab/music21/issues/444
v.makeRests(refStreamOrTimeRange=self.stream,
fillGaps=True,
inPlace=True,
hideRests=True)
+ elementsAdded = [e for e in v.elements if e not in elementsBefore]+ if not elementsAdded:+ continue++ for e in elementsAdded:+ next_element = e.next()+ staffKey = None+ for k, listOfEls in self.staffReference.items():+ if next_element in listOfEls:+ staffKey = k+ break+ if staffKey is None:+ # use max of keys in self.staffReference?+ continue+ if next_element.offset < e.offset:+ staffKey -= 1+ if staffKey < 0:+ continue+ if staffKey not in self.staffReference:+ self.staffReference[staffKey] = []+ self.staffReference[staffKey].append(e)+
self.stream.coreElementsChanged()
The text was updated successfully, but these errors were encountered:
music21 version
dev (and reproduced on 3.1.0)
Problem summary
Voices that don't fill the measure are represented in MusicXML with
<forward>
tags, from which m21 creates hidden rests. The hidden rests are made late enough that they never get a staffReference, and so they are not excluded duringPartStaff
separation, and so we get hidden rests in both parts.Steps to reproduce
More information
This was the existing bug I was referring to in #986 (comment), discovered while working on #986.
Suggested fix
This diff fixes it, but I'm not convinced it's the best place to do this checking. (And it needs refactoring to pass the Pylint check for nested blocks.) Perhaps we should just create hidden rests in
xmlForward()
instead of relying onmakeRests()
after the fact?The problem with that is thatAH -- they do!<forward>
tags don't have staff numbers.The text was updated successfully, but these errors were encountered: