Skip to content

Commit 1fe795e

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

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ly/musicxml/xml_objs.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,23 @@ 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+
if 'start' in obj.tie:
354+
tie_started = True
355+
elif 'stop' in obj.tie:
356+
tie_stopped = True
357+
348358
slur_started = False
349359
slur_stopped = False
350360

@@ -357,7 +367,7 @@ def merge_lyrics(self, lyrics, voice_context=None):
357367
elif slur.slurtype == 'stop':
358368
slur_stopped = True
359369

360-
if not inside_slur:
370+
if not inside_tie and not inside_slur:
361371
try:
362372
l = lyrics.barlist[i]
363373
except IndexError:
@@ -371,6 +381,10 @@ def merge_lyrics(self, lyrics, voice_context=None):
371381
elif slur_stopped:
372382
inside_slur = False
373383

384+
if tie_started:
385+
inside_tie = True
386+
elif tie_stopped:
387+
inside_tie = False
374388

375389
class Snippet(ScoreSection):
376390
""" Short section intended to be merged.

0 commit comments

Comments
 (0)