Skip to content

Commit 4f5d1bd

Browse files
committed
Search thrugh all sections for possible voice contexts
1 parent 9f36669 commit 4f5d1bd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

ly/musicxml/ly2xml_mediator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,10 @@ def check_lyrics(self, voice_id):
273273
if voice_section:
274274
voice_section.merge_lyrics(lyrics_section, voice_id)
275275
else:
276-
# A potentially slow path
277-
voice_section = self.score.find_section_for_voice(voice_id)
276+
voice_section = self.score.find_section_for_voice(voice_id, self.sections)
277+
if not voice_section:
278+
# A potentially slow path, search the whole score
279+
voice_section = self.score.find_section_for_voice(voice_id)
278280
if voice_section:
279281
# Must explicitly only merge with notes with the same voice_id
280282
voice_section.merge_lyrics(lyrics_section, voice_id)

ly/musicxml/xml_objs.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,14 @@ def debug_group(g):
274274
for i in self.partlist:
275275
debug_group(i)
276276

277-
def find_section_for_voice(self, voice_context, parent = None):
278-
partlist = self.partlist
279-
280-
if parent:
281-
partlist = parent.partlist
277+
def find_section_for_voice(self, voice_context, partlist = None):
278+
if not partlist:
279+
partlist = self.partlist
282280

283281
for section in partlist[::-1]:
284282
# Iterate over sections in partlist, in reverser order (newest to oldest)
285283
if isinstance(section, ScorePartGroup):
286-
section_candidate = self.find_section_for_voice(voice_context, section)
284+
section_candidate = self.find_section_for_voice(voice_context, section.partlist)
287285
if section_candidate:
288286
return section_candidate
289287
elif isinstance(section, ScoreSection):

0 commit comments

Comments
 (0)