]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Include figured bass in the score; simplify test file
authorReinhold Kainhofer <reinhold@kainhofer.com>
Wed, 2 Apr 2008 22:40:47 +0000 (00:40 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Wed, 2 Apr 2008 22:40:47 +0000 (00:40 +0200)
input/regression/musicxml/18a-FiguredBass.xml
python/musicexp.py
scripts/musicxml2ly.py

index 753c41377a2a1bb6fdb6de61c8deb618adf4cd30..986ab1eca4e03fc27ecd5f41ce98b7a0aa7d6546 100644 (file)
@@ -3,9 +3,7 @@
                                 "http://www.musicxml.org/dtds/partwise.dtd">
 <score-partwise version="1.1">
   <movement-title>Figured Bass</movement-title>
-  <identification>
-    <creator type="composer">Reinhold Kainhofer</creator>
-  </identification>
+  <identification/>
   <part-list>
     <score-part id="P1">
       <part-name>MusicXML Part</part-name>
@@ -59,8 +57,6 @@
         <figure><figure-number>1</figure-number><prefix>sharp</prefix></figure>
         <figure><figure-number>3</figure-number><prefix>flat</prefix></figure>
         <figure><figure-number>5</figure-number><prefix>natural</prefix></figure>
-        <figure><figure-number>7</figure-number><suffix>slash</suffix></figure>
-        <figure><figure-number>9</figure-number><prefix>flat</prefix><suffix>slash</suffix></figure>
         <duration>6</duration>
       </figured-bass>
       <note>
         <type>16th</type>
         <stem>up</stem>
       </note>
+      <figured-bass>
+        <figure><figure-number>5</figure-number><suffix>slash</suffix></figure>
+        <figure><figure-number>127</figure-number><prefix>flat</prefix><suffix>slash</suffix></figure>
+        <duration>8</duration>
+      </figured-bass>
+      <note>
+        <pitch><step>G</step><octave>4</octave></pitch>
+        <duration>8</duration>
+        <voice>1</voice>
+        <type>eighth</type>
+        <dot/>
+        <stem>up</stem>
+      </note>
       <figured-bass>
       </figured-bass>
       <note>
index 3219c689d249e6a50520707945b4b1ddb83cf711..2014b0f203a33f484d1bc1703e6f4bc09072677c 100644 (file)
@@ -1440,7 +1440,7 @@ class Staff (StaffGroup):
             printer.newline ()
             n = 0
             nr_voices = len (voices)
-            for [v, lyrics] in voices:
+            for [v, lyrics, figuredbass] in voices:
                 n += 1
                 voice_count_text = ''
                 if nr_voices > 1:
@@ -1452,6 +1452,8 @@ class Staff (StaffGroup):
                 for l in lyrics:
                     printer ('\\new Lyrics \\lyricsto "%s" \\%s' % (v,l))
                     printer.newline()
+                if figuredbass:
+                    printer ('\context FiguredBass = "%s" \\%s' % (figuredbass, figuredbass))
             printer ('>>')
 
     def print_ly (self, printer):
index d65dd4a7e16cb63c4577579f43742befe2dddd46..e8ae92c2196875e686b41b7f50cc5c60d8aad72e 100644 (file)
@@ -1484,6 +1484,7 @@ class LilyPondVoiceBuilder:
 
 class VoiceData:
     def __init__ (self):
+        self.voicename = None
         self.voicedata = None
         self.ly_voice = None
         self.figured_bass = None
@@ -2015,8 +2016,8 @@ def music_xml_lyrics_name_to_lily_name (part_id, name, lyricsnr):
     str = "Part%sVoice%sLyrics%s" % (part_id, name, lyricsnr)
     return musicxml_id_to_lily (str) 
 
-def music_xml_figuredbass_name_to_lily_name (part_id, name):
-    str = "Part%sVoice%sFiguredBass" % (part_id, name)
+def music_xml_figuredbass_name_to_lily_name (part_id, voicename):
+    str = "Part%sVoice%sFiguredBass" % (part_id, voicename)
     return musicxml_id_to_lily (str) 
 
 def print_voice_definitions (printer, part_list, voices):
@@ -2046,19 +2047,22 @@ def uniq_list (l):
 # format the information about the staff in the form 
 #     [staffid,
 #         [
-#            [voiceid1, [lyricsid11, lyricsid12,...] ...],
-#            [voiceid2, [lyricsid21, lyricsid22,...] ...],
+#            [voiceid1, [lyricsid11, lyricsid12,...], figuredbassid1],
+#            [voiceid2, [lyricsid21, lyricsid22,...], figuredbassid2],
 #            ...
 #         ]
 #     ]
-# raw_voices is of the form [(voicename, lyricsids)*]
+# raw_voices is of the form [(voicename, lyricsids, havefiguredbass)*]
 def format_staff_info (part_id, staff_id, raw_voices):
     voices = []
-    for (v, lyricsids) in raw_voices:
+    for (v, lyricsids, figured_bass) in raw_voices:
         voice_name = music_xml_voice_name_to_lily_name (part_id, v)
         voice_lyrics = [music_xml_lyrics_name_to_lily_name (part_id, v, l)
                    for l in lyricsids]
-        voices.append ([voice_name, voice_lyrics])
+        figured_bass_name = ''
+        if figured_bass:
+            figured_bass_name = music_xml_figuredbass_name_to_lily_name (part_id, v)
+        voices.append ([voice_name, voice_lyrics, figured_bass_name])
     return [staff_id, voices]
 
 def update_score_setup (score_structure, part_list, voices):
@@ -2080,12 +2084,12 @@ def update_score_setup (score_structure, part_list, voices):
             staves = uniq_list (staves)
             staves.sort ()
             for s in staves:
-                thisstaff_raw_voices = [(voice_name, voice.lyrics_order) 
+                thisstaff_raw_voices = [(voice_name, voice.lyrics_order, voice.figured_bass
                     for (voice_name, voice) in nv_dict.items ()
                     if voice.voicedata._start_staff == s]
                 staves_info.append (format_staff_info (part_id, s, thisstaff_raw_voices))
         else:
-            thisstaff_raw_voices = [(voice_name, voice.lyrics_order) 
+            thisstaff_raw_voices = [(voice_name, voice.lyrics_order, voice.figured_bass
                 for (voice_name, voice) in nv_dict.items ()]
             staves_info.append (format_staff_info (part_id, None, thisstaff_raw_voices))
         score_structure.set_part_information (part_id, staves_info)