]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Fix problem with lyrics on notes with grace notes
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 27 Oct 2007 20:45:17 +0000 (22:45 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 27 Oct 2007 20:45:17 +0000 (22:45 +0200)
When a note had grace notes (and it was tied or part of a slur), sometimes
the lyrics for that note were completely ignored and all subsequent
lyrics were one note off. Now I simply ignore all slurs/ties of grace notes
and everything works just fine.

Also, clean up the staff change code. Now a staff change is not only applied
before a note, but also before other stuff (like clef change).

input/regression/musicxml/06f-Lyrics-GracedNotes-Finale.xml [new file with mode: 0644]
scripts/musicxml2ly.py

diff --git a/input/regression/musicxml/06f-Lyrics-GracedNotes-Finale.xml b/input/regression/musicxml/06f-Lyrics-GracedNotes-Finale.xml
new file mode 100644 (file)
index 0000000..d6fa55c
--- /dev/null
@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.0 Partwise//EN"\r
+                                "http://www.musicxml.org/dtds/partwise.dtd">\r
+<score-partwise>\r
+  <movement-title>Lyrics on notes with graces</movement-title>\r
+  <identification>\r
+    <encoding>\r
+      <software>Finale 2007 for Windows</software>\r
+      <software>Dolet Light for Finale 2007</software>\r
+      <encoding-date>2007-10-27</encoding-date>\r
+    </encoding>\r
+  </identification>\r
+  <part-list>\r
+    <score-part id="P1">\r
+      <part-name>MusicXML Part</part-name>\r
+      <score-instrument id="P1-I1">\r
+        <instrument-name>Grand Piano</instrument-name>\r
+      </score-instrument>\r
+      <midi-instrument id="P1-I1">\r
+        <midi-channel>1</midi-channel>\r
+        <midi-program>1</midi-program>\r
+      </midi-instrument>\r
+    </score-part>\r
+  </part-list>\r
+  <!--=========================================================-->\r
+  <part id="P1">\r
+    <measure number="1">\r
+      <attributes>\r
+        <divisions>2</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
+      <sound tempo="120"/>\r
+      <note>\r
+        <pitch>\r
+          <step>G</step>\r
+          <octave>4</octave>\r
+        </pitch>\r
+        <duration>2</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <stem>up</stem>\r
+        <notations>\r
+          <slur number="1" type="start"/>\r
+        </notations>\r
+        <lyric number="1">\r
+          <syllabic>begin</syllabic>\r
+          <text>Ly</text>\r
+        </lyric>\r
+      </note>\r
+      <note>\r
+        <grace slash="yes"/>\r
+        <pitch>\r
+          <step>D</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <voice>1</voice>\r
+        <type>eighth</type>\r
+        <stem>up</stem>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>2</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <stem>down</stem>\r
+        <notations>\r
+          <slur number="1" type="stop"/>\r
+        </notations>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>2</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <stem>down</stem>\r
+        <lyric number="1">\r
+          <syllabic>end</syllabic>\r
+          <text>rics</text>\r
+        </lyric>\r
+      </note>\r
+      <note>\r
+        <grace slash="yes"/>\r
+        <pitch>\r
+          <step>D</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <tie type="start"/>\r
+        <voice>1</voice>\r
+        <type>eighth</type>\r
+        <stem>up</stem>\r
+        <notations>\r
+          <tied type="start"/>\r
+        </notations>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>2</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <stem>down</stem>\r
+        <lyric number="1">\r
+          <syllabic>single</syllabic>\r
+          <text>on</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>2</duration>\r
+        <tie type="start"/>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <stem>down</stem>\r
+        <notations>\r
+          <tied type="start"/>\r
+        </notations>\r
+        <lyric number="1">\r
+          <syllabic>single</syllabic>\r
+          <text>notes</text>\r
+          <extend/>\r
+        </lyric>\r
+      </note>\r
+      <note>\r
+        <grace/>\r
+        <pitch>\r
+          <step>E</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <tie type="start"/>\r
+        <voice>1</voice>\r
+        <type>eighth</type>\r
+        <stem>up</stem>\r
+        <beam number="1">begin</beam>\r
+        <notations>\r
+          <tied type="start"/>\r
+        </notations>\r
+      </note>\r
+      <note>\r
+        <grace/>\r
+        <pitch>\r
+          <step>D</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <voice>1</voice>\r
+        <type>eighth</type>\r
+        <stem>up</stem>\r
+        <beam number="1">end</beam>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>2</duration>\r
+        <tie type="stop"/>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <stem>down</stem>\r
+        <notations>\r
+          <tied type="stop"/>\r
+        </notations>\r
+      </note>\r
+      <note>\r
+        <grace/>\r
+        <pitch>\r
+          <step>D</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <voice>1</voice>\r
+        <type>eighth</type>\r
+        <stem>up</stem>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>2</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <stem>down</stem>\r
+        <lyric number="1">\r
+          <syllabic>single</syllabic>\r
+          <text>with</text>\r
+        </lyric>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>2</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <stem>down</stem>\r
+        <lyric number="1">\r
+          <syllabic>single</syllabic>\r
+          <text>graces</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 8bb9b2560a7aaceaa3f8c3b9f5cecb8fbbac4700..4a8548630b85177381a90a1fa2bb36aa7c2b756c 100644 (file)
@@ -961,6 +961,12 @@ def musicxml_voice_to_lily_voice (voice):
     for n in voice._elements:
         if n.get_name () == 'forward':
             continue
+        staff = n.get_maybe_exist_named_child ('staff')
+        if staff:
+            staff = staff.get_text ()
+            if current_staff and staff <> current_staff and not n.get_maybe_exist_named_child ('chord'):
+                voice_builder.add_command (musicexp.StaffChange (staff))
+            current_staff = staff
 
         if isinstance (n, musicxml.Partial) and n.partial > 0:
             a = musicxml_partial_to_lily (n.partial)
@@ -986,12 +992,6 @@ def musicxml_voice_to_lily_voice (voice):
 
         is_chord = n.get_maybe_exist_named_child ('chord')
         if not is_chord:
-            s = n.get_maybe_exist_named_child ('staff')
-            if s:
-                staff = s.get_text ()
-                if current_staff and staff <> current_staff:
-                    voice_builder.add_command (musicexp.StaffChange (staff))
-                current_staff = staff
             try:
                 voice_builder.jumpto (n._when)
             except NegativeSkip, neg:
@@ -1103,19 +1103,21 @@ def musicxml_voice_to_lily_voice (voice):
                 if len (slurs) > 1:
                     error_message ('more than 1 slur?')
                 # record the slur status for the next note in the loop
-                if slurs[0].get_type () == 'start':
-                    inside_slur = True
-                elif slurs[0].get_type () == 'stop':
-                    inside_slur = False
+                if not grace:
+                    if slurs[0].get_type () == 'start':
+                        inside_slur = True
+                    elif slurs[0].get_type () == 'stop':
+                        inside_slur = False
                 lily_ev = musicxml_spanner_to_lily_event (slurs[0])
                 ev_chord.append (lily_ev)
 
-            mxl_tie = notations.get_tie ()
-            if mxl_tie and mxl_tie.type == 'start':
-                ev_chord.append (musicexp.TieEvent ())
-                is_tied = True
-            else:
-                is_tied = False
+            if not grace:
+                mxl_tie = notations.get_tie ()
+                if mxl_tie and mxl_tie.type == 'start':
+                    ev_chord.append (musicexp.TieEvent ())
+                    is_tied = True
+                else:
+                    is_tied = False
 
             fermatas = notations.get_named_children ('fermata')
             for a in fermatas: