]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Print out a \score around the contents
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 1 Nov 2008 21:26:46 +0000 (22:26 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 1 Nov 2008 21:29:16 +0000 (22:29 +0100)
Implemented a dedicated Score class in musicexp.py for this...
It now prints
\score {
  [Contents]
  \layout {}
  % To create MIDI output, uncomment the following line:
  % \midi {}
}

python/musicexp.py
scripts/musicxml2ly.py

index 01cd446f481fc0b83c33fed9e5783aea3d78c00f..1b1f3d91830f9b42cbb307f0abc2866390646d04 100644 (file)
@@ -1617,6 +1617,34 @@ class DrumStaff (Staff):
 class RhythmicStaff (Staff):
     def __init__ (self, command = "RhythmicStaff"):
         Staff.__init__ (self, command)
+        
+class Score ():
+    def __init__ (self):
+        self.contents = None
+        self.create_midi = False
+
+    def set_contents (self, contents):
+        self.contents = contents
+    
+    def set_part_information (self, part_id, staves_info):
+        if self.contents:
+          self.contents.set_part_information (part_id, staves_info)
+
+    def print_ly (self, printer):
+        printer.dump ("\\score {");
+        printer.newline ()
+        if self.contents:
+            self.contents.print_ly (printer);
+        printer.dump ("\\layout {}");
+        printer.newline ()
+        if not self.create_midi:
+            printer.dump ("% To create MIDI output, uncomment the following line:");
+            printer.newline ();
+            printer.dump ("% ");
+        printer.dump ("\\midi {}");
+        printer.newline ()
+        printer.dump ("}");
+        printer.newline ()
 
 
 def test_pitch ():
index 6cdd72e430996ba47c1f58fd9ac3db68d941e283..113552939cabb870da23c87dfde21ea652563148 100644 (file)
@@ -308,7 +308,10 @@ def staff_attributes_to_lily_staff (mxl_attr):
 
 
 def extract_score_structure (part_list, staffinfo):
+    score = musicexp.Score ()
     structure = musicexp.StaffGroup (None)
+    score.set_contents (structure)
+    
     if not part_list:
         return structure
 
@@ -436,7 +439,7 @@ def extract_score_structure (part_list, staffinfo):
         return staves[0]
     for i in staves:
         structure.append_staff (i)
-    return structure
+    return score
 
 
 def musicxml_duration_to_lily (mxl_note):
@@ -2423,14 +2426,14 @@ def convert (filename, options):
     parts = tree.get_typed_children (musicxml.Part)
     (voices, staff_info) = get_all_voices (parts)
 
-    score_structure = None
+    score = None
     mxl_pl = tree.get_maybe_exist_typed_child (musicxml.Part_list)
     if mxl_pl:
-        score_structure = extract_score_structure (mxl_pl, staff_info)
+        score = extract_score_structure (mxl_pl, staff_info)
         part_list = mxl_pl.get_named_children ("score-part")
 
     # score information is contained in the <work>, <identification> or <movement-title> tags
-    update_score_setup (score_structure, part_list, voices)
+    update_score_setup (score, part_list, voices)
     # After the conversion, update the list of settings for the \layout block
     update_layout_information ()
 
@@ -2467,7 +2470,7 @@ def convert (filename, options):
     printer.newline ()
     printer.dump ("% The score definition")
     printer.newline ()
-    score_structure.print_ly (printer)
+    score.print_ly (printer)
     printer.newline ()
 
     return voices