diff --git a/music21/musicxml/xmlToM21.py b/music21/musicxml/xmlToM21.py index 9c1ea7017..711f541da 100644 --- a/music21/musicxml/xmlToM21.py +++ b/music21/musicxml/xmlToM21.py @@ -6202,7 +6202,7 @@ def parseMeasureNumbers(self, mNumRaw=None): def updateVoiceInformation(self): # noinspection PyShadowingNames ''' - Finds all the "voice" information in tags and updates the set of + Finds all the "voice" information in and tags and updates the set of `.voiceIndices` to be a set of all the voice texts, and if there is more than one voice in the measure, sets `.useVoices` to True and creates a voice for each. @@ -6231,14 +6231,27 @@ def updateVoiceInformation(self): 2 >>> list(MP.stream.getElementsByClass(stream.Voice)) [, ] + >>> MP = musicxml.xmlToM21.MeasureParser() + >>> MP.mxMeasure = ET.fromstring('1' + ... + '2') + >>> MP.updateVoiceInformation() + >>> sorted(list(MP.voiceIndices)) + ['1', '2'] + >>> MP.useVoices + True + >>> len(MP.stream) + 2 + >>> list(MP.stream.getElementsByClass(stream.Voice)) + [, ] ''' mxm = self.mxMeasure - for mxn in mxm.findall('note'): - voice = mxn.find('voice') - if vIndex := strippedText(voice): - self.voiceIndices.add(vIndex) - # it is a set, so no need to check if already there - # additional time < 1 sec per ten million ops. + for tagSearch in ('note', 'forward'): + for mxn in mxm.findall(tagSearch): + voice = mxn.find('voice') + if vIndex := strippedText(voice): + self.voiceIndices.add(vIndex) + # it is a set, so no need to check if already there + # additional time < 1 sec per ten million ops. if len(self.voiceIndices) > 1: for vIndex in sorted(self.voiceIndices): diff --git a/music21/stream/filters.py b/music21/stream/filters.py index 105855818..ba9d19eff 100644 --- a/music21/stream/filters.py +++ b/music21/stream/filters.py @@ -490,7 +490,7 @@ def __call__(self, e, iterator=None): if not hasattr(iterator, 'iteratorStartOffsetInHierarchy'): raise FilterException('Can only run OffsetHierarchyFilter on a RecursiveIterator') - offset = s.elementOffset(e) + iterator.iteratorStartOffsetInHierarchy + offset = opFrac(s.elementOffset(e) + iterator.iteratorStartOffsetInHierarchy) return self.isElementOffsetInRange(e, offset, stopAfterEnd=False)