]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Fix missing tie end tag
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 5 Apr 2009 21:44:06 +0000 (23:44 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 5 Apr 2009 21:47:34 +0000 (23:47 +0200)
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...

input/regression/musicxml/33i-Ties-NotEnded.xml [new file with mode: 0644]
scripts/musicxml2ly.py

diff --git a/input/regression/musicxml/33i-Ties-NotEnded.xml b/input/regression/musicxml/33i-Ties-NotEnded.xml
new file mode 100644 (file)
index 0000000..6a50f4d
--- /dev/null
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 2.0 Partwise//EN"\r
+                                "http://www.musicxml.org/dtds/partwise.dtd">\r
+<score-partwise version="2.0">\r
+  <identification>\r
+    <miscellaneous>\r
+      <miscellaneous-field name="description">Several ties that have their end tag missing.</miscellaneous-field>\r
+    </miscellaneous>\r
+  </identification>\r
+  <part-list>\r
+    <score-part id="P1">\r
+      <part-name></part-name>\r
+    </score-part>\r
+  </part-list>\r
+  <!--=========================================================-->\r
+  <part id="P1">\r
+    <measure number="1">\r
+      <attributes>\r
+        <divisions>1</divisions>\r
+        <key>\r
+          <fifths>0</fifths>\r
+          <mode>major</mode>\r
+        </key>\r
+        <time symbol="common">\r
+          <beats>4</beats>\r
+          <beat-type>4</beat-type>\r
+        </time>\r
+        <clef>\r
+          <sign>G</sign>\r
+          <line>2</line>\r
+        </clef>\r
+      </attributes>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>4</duration>\r
+        <tie type="start"/>\r
+        <voice>1</voice>\r
+        <type>whole</type>\r
+        <notations>\r
+          <tied type="start"/>\r
+        </notations>\r
+        <lyric number="1">\r
+          <syllabic>end</syllabic>\r
+          <text>A</text>\r
+        </lyric>\r
+      </note>\r
+    </measure>\r
+    <!--=======================================================-->\r
+    <measure number="2">\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>4</duration>\r
+        <voice>1</voice>\r
+        <type>whole</type>\r
+        <lyric number="1">\r
+          <syllabic>end</syllabic>\r
+          <text>B</text>\r
+        </lyric>\r
+      </note>\r
+    </measure>\r
+    <!--=======================================================-->\r
+    <measure number="3">\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>4</duration>\r
+        <tie type="stop"/>\r
+        <tie type="start"/>\r
+        <voice>1</voice>\r
+        <type>whole</type>\r
+        <notations>\r
+          <tied type="stop"/>\r
+          <tied type="start"/>\r
+        </notations>\r
+        <lyric number="1">\r
+          <syllabic>end</syllabic>\r
+          <text>C</text>\r
+        </lyric>\r
+      </note>\r
+    </measure>\r
+    <!--=======================================================-->\r
+    <measure number="4">\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>4</duration>\r
+        <tie type="start"/>\r
+        <voice>1</voice>\r
+        <type>whole</type>\r
+        <notations>\r
+          <tied type="start"/>\r
+        </notations>\r
+        <lyric number="1" name="verse">\r
+          <syllabic>end</syllabic>\r
+          <text>D</text>\r
+        </lyric>\r
+      </note>\r
+    </measure>\r
+    <!--=======================================================-->\r
+    <measure number="5">\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>4</duration>\r
+        <tie type="stop"/>\r
+        <voice>1</voice>\r
+        <type>whole</type>\r
+        <notations>\r
+          <tied type="stop"/>\r
+        </notations>\r
+        <lyric number="1" name="verse">\r
+          <syllabic>end</syllabic>\r
+          <text>E</text>\r
+        </lyric>\r
+      </note>\r
+      <barline location="right">\r
+        <bar-style>light-heavy</bar-style>\r
+      </barline>\r
+    </measure>\r
+  </part>\r
+  <!--=========================================================-->\r
+</score-partwise>\r
index ce8b11f49e35449b9f8610d4a73f2694fd599e8b..d9dfaf3be64171ae4de27938ac1f56be4b22434c 100644 (file)
@@ -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 <tie> 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)