Skip to content

Commit c3781b5

Browse files
committed
Make ScoreSection.merge_lyrics() also care about ties
1 parent 6b64308 commit c3781b5

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

ly/musicxml/xml_objs.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,24 @@ def merge_lyrics(self, lyrics, voice_context=None):
338338

339339
# If we are at the end or inside the slur, but not at the start
340340
inside_slur = False
341+
inside_tie = False
341342

342343
for bar in self.barlist:
343344
for obj in bar.obj_list:
344345
if isinstance(obj, BarNote) and \
345346
not obj.chord and \
346347
(not voice_context or obj.voice_context == voice_context):
347348

349+
tie_started = False
350+
tie_stopped = False
351+
352+
# Ties can both start and stop at the same note, prefer starts
353+
print(obj.tie)
354+
if 'start' in obj.tie:
355+
tie_started = True
356+
elif 'stop' in obj.tie:
357+
tie_stopped = True
358+
348359
slur_started = False
349360
slur_stopped = False
350361

@@ -357,7 +368,7 @@ def merge_lyrics(self, lyrics, voice_context=None):
357368
elif slur.slurtype == 'stop':
358369
slur_stopped = True
359370

360-
if not inside_slur:
371+
if not inside_tie and not inside_slur:
361372
try:
362373
l = lyrics.barlist[i]
363374
except IndexError:
@@ -371,6 +382,10 @@ def merge_lyrics(self, lyrics, voice_context=None):
371382
elif slur_stopped:
372383
inside_slur = False
373384

385+
if tie_started:
386+
inside_tie = True
387+
elif tie_stopped:
388+
inside_tie = False
374389

375390
class Snippet(ScoreSection):
376391
""" Short section intended to be merged.

0 commit comments

Comments
 (0)