]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Implement lyrics extenders
authorReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 8 Dec 2008 21:28:56 +0000 (22:28 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 8 Dec 2008 22:22:45 +0000 (23:22 +0100)
input/regression/musicxml/61a-Lyrics.xml
input/regression/musicxml/61k-Lyrics-SpannersExtenders.xml [new file with mode: 0644]
python/musicxml.py
scripts/musicxml2ly.py

index 81e0d60835cb25cdcd1f86e8f97c7d3b85c80472..69642ea874567e9a9b77e18f2a3c33e813c9d480 100644 (file)
@@ -82,7 +82,6 @@
         <lyric number="1">
           <syllabic>single</syllabic>
           <text>Ja!</text>
-          <extend/>
         </lyric>
       </note>
     </measure>
         <lyric number="1">
           <syllabic>end</syllabic>
           <text>ra!</text>
-          <extend/>
         </lyric>
       </note>
     </measure>
         <duration>1</duration>
         <voice>1</voice>
         <type>quarter</type>
-        <lyric number="1">
-          <extend/>
-        </lyric>
       </note>
       <note>
         <pitch>
         <voice>1</voice>
         <type>quarter</type>
         <lyric number="1">
-          <syllabic>begin</syllabic>
+          <syllabic>single</syllabic>
           <text>Bah!</text>
-          <extend/>
         </lyric>
       </note>
       <note>
         <duration>2</duration>
         <voice>1</voice>
         <type>half</type>
-        <lyric number="1">
-          <extend/>
-        </lyric>
       </note>
       <barline location="right">
         <bar-style>light-heavy</bar-style>
diff --git a/input/regression/musicxml/61k-Lyrics-SpannersExtenders.xml b/input/regression/musicxml/61k-Lyrics-SpannersExtenders.xml
new file mode 100644 (file)
index 0000000..9529312
--- /dev/null
@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.1 Partwise//EN"\r
+                                "http://www.musicxml.org/dtds/partwise.dtd">\r
+<score-partwise version="1.1">\r
+  <identification>\r
+    <miscellaneous>\r
+      <miscellaneous-field name="description">Lyrics spanners: continued \r
+            syllables and extenders, possibly spanning multiple notes. The \r
+            intermediate notes do not have any &lt;lyric&gt; \r
+            element.</miscellaneous-field>\r
+    </miscellaneous>\r
+  </identification>\r
+  <part-list>\r
+    <score-part id="P1">\r
+      <part-name print-object="no">MusicXML Part</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>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <lyric justify="left" number="1">\r
+          <syllabic>single</syllabic>\r
+          <text>A</text>\r
+          <extend/>\r
+        </lyric>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <lyric number="1">\r
+          <syllabic>begin</syllabic>\r
+          <text>b</text>\r
+        </lyric>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\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>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <lyric justify="left" number="1">\r
+          <syllabic>end</syllabic>\r
+          <text>CC</text>\r
+          <extend/>\r
+        </lyric>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\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>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+        <lyric justify="left" number="1">\r
+          <syllabic>single</syllabic>\r
+          <text>e</text>\r
+          <extend/>\r
+        </lyric>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+      </note>\r
+      <note>\r
+        <pitch>\r
+          <step>C</step>\r
+          <octave>5</octave>\r
+        </pitch>\r
+        <duration>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\r
+      </note>\r
+      <note>\r
+        <rest/>\r
+        <duration>1</duration>\r
+        <voice>1</voice>\r
+        <type>quarter</type>\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 9a918ba6b3756bfd7a5c2dff77bae9fcb806d36d..b6a5bbeac87fde3fbef733ffde49c03d318a722a 100644 (file)
@@ -539,6 +539,8 @@ class Syllabic (Music_xml_node):
         return (text == "begin") or (text == "middle")
 class Elision (Music_xml_node):
     pass
+class Extend (Music_xml_node):
+    pass
 class Text (Music_xml_node):
     pass
 
@@ -1173,6 +1175,7 @@ class_dict = {
         'direction-type': DirType,
        'duration': Duration,
         'elision': Elision,
+        'extend': Extend,
         'frame': Frame,
         'frame-note': Frame_Note,
         'figured-bass': FiguredBass,
index dca950e8f7ae2a062eeb7ae05394807f18f4bfb5..e37702686ea1dc60e03a12b9068cd1bf23e081d2 100644 (file)
@@ -1763,6 +1763,7 @@ def musicxml_note_to_lily_main_event (n):
 def musicxml_lyrics_to_text (lyrics):
     # TODO: Implement text styles for lyrics syllables
     continued = False
+    extended = False
     text = ''
     for e in lyrics.get_all_children ():
         if isinstance (e, musicxml.Syllabic):
@@ -1775,15 +1776,24 @@ def musicxml_lyrics_to_text (lyrics):
             if text:
                 text += " "
             continued = False
+            extended = False
+        elif isinstance (e, musicxml.Extend):
+            if text:
+                text += " "
+            extended = True
 
     if text == "-" and continued:
         return "--"
-    elif text == "_" and continued:
+    elif text == "_" and extended:
         return "__"
     elif continued and text:
         return musicxml.escape_ly_output_string (text) + " --"
     elif continued:
         return "--"
+    elif extended and text:
+        return musicxml.escape_ly_output_string (text) + " __"
+    elif extended:
+        return "__"
     elif text:
         return musicxml.escape_ly_output_string (text)
     else: