From d7a78a3eab1e40ea339ab9bbe6eb97a554810735 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Sun, 5 Apr 2009 23:44:06 +0200 Subject: [PATCH] MusicXML: Fix missing tie end tag Some applications "forget" to export the end tag for ties. it's actually simpler to assume ties last only for one note and reset them afterwards automatically. This might break pieces with multiple overlapping voices, though... --- .../regression/musicxml/33i-Ties-NotEnded.xml | 134 ++++++++++++++++++ scripts/musicxml2ly.py | 10 +- 2 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 input/regression/musicxml/33i-Ties-NotEnded.xml diff --git a/input/regression/musicxml/33i-Ties-NotEnded.xml b/input/regression/musicxml/33i-Ties-NotEnded.xml new file mode 100644 index 0000000000..6a50f4d489 --- /dev/null +++ b/input/regression/musicxml/33i-Ties-NotEnded.xml @@ -0,0 +1,134 @@ + + + + + + Several ties that have their end tag missing. + + + + + + + + + + + + 1 + + 0 + major + + + + G + 2 + + + + + C + 5 + + 4 + + 1 + whole + + + + + end + A + + + + + + + + C + 5 + + 4 + 1 + whole + + end + B + + + + + + + + C + 5 + + 4 + + + 1 + whole + + + + + + end + C + + + + + + + + C + 5 + + 4 + + 1 + whole + + + + + end + D + + + + + + + + C + 5 + + 4 + + 1 + whole + + + + + end + E + + + + light-heavy + + + + + diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index ce8b11f49e..d9dfaf3be6 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -2108,6 +2108,7 @@ def musicxml_voice_to_lily_voice (voice): voice_builder.set_measure_length (current_measure_length) for n in voice._elements: + tie_started = False if n.get_name () == 'forward': continue staff = n.get_maybe_exist_named_child ('staff') @@ -2350,6 +2351,7 @@ def musicxml_voice_to_lily_voice (voice): if mxl_tie and mxl_tie.type == 'start': ev_chord.append (musicexp.TieEvent ()) is_tied = True + tie_started = True else: is_tied = False @@ -2445,7 +2447,13 @@ def musicxml_voice_to_lily_voice (voice): if not lnr in note_lyrics_processed: lyrics[lnr].append ("\skip4") - ## force trailing mm rests to be written out. + # Assume that a element only lasts for one note. + # This might not be correct MusicXML interpretation, but works for + # most cases and fixes broken files, which have the end tag missing + if is_tied and not tie_started: + is_tied = False + + ## force trailing mm rests to be written out. voice_builder.add_music (musicexp.ChordEvent (), Rational (0)) ly_voice = group_tuplets (voice_builder.elements, tuplet_events) -- 2.39.5