]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Implement page and system breaks
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 4 Apr 2009 13:19:51 +0000 (15:19 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 4 Apr 2009 13:19:51 +0000 (15:19 +0200)
input/regression/musicxml/52b-Breaks.xml [new file with mode: 0644]
python/musicexp.py
python/musicxml.py
scripts/musicxml2ly.py

diff --git a/input/regression/musicxml/52b-Breaks.xml b/input/regression/musicxml/52b-Breaks.xml
new file mode 100644 (file)
index 0000000..6232618
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.1 Partwise//EN"
+                                "http://www.musicxml.org/dtds/partwise.dtd">
+<score-partwise>
+  <identification>
+    <miscellaneous>
+      <miscellaneous-field name="description">System and page breaks, given in 
+              a &lt;print&gt; element</miscellaneous-field>
+    </miscellaneous>
+  </identification>
+  <part-list>
+    <score-part id="P1">
+      <part-name print-object="no">MusicXML Part</part-name>
+    </score-part>
+  </part-list>
+  <!--=========================================================-->
+  <part id="P1">
+    <measure number="1">
+      <attributes>
+        <divisions>1</divisions>
+        <time symbol="common">
+          <beats>4</beats>
+          <beat-type>4</beat-type>
+        </time>
+      </attributes>
+      <note>
+        <pitch>
+          <step>C</step>
+          <octave>5</octave>
+        </pitch>
+        <duration>4</duration>
+        <voice>1</voice>
+        <type>whole</type>
+      </note>
+    </measure>
+    <!--=======================================================-->
+    <measure number="2">
+      <print new-system="yes"/>
+      <note>
+        <pitch>
+          <step>C</step>
+          <octave>5</octave>
+        </pitch>
+        <duration>4</duration>
+        <voice>1</voice>
+        <type>whole</type>
+      </note>
+    </measure>
+    <!--=======================================================-->
+    <measure number="3">
+      <print new-page="yes"/>
+      <note>
+        <pitch>
+          <step>C</step>
+          <octave>5</octave>
+        </pitch>
+        <duration>4</duration>
+        <voice>1</voice>
+        <type>whole</type>
+      </note>
+    </measure>
+  </part>
+  <!--=========================================================-->
+</score-partwise>
index 0e8b212c85360c7ffb309e51244eb37db5867720..61598f28e51e7c58258cc5532c163ce84e45bcb3 100644 (file)
@@ -1707,6 +1707,14 @@ class MultiMeasureRest(Music):
         return 'R%s' % self.duration.ly_expression ()
 
 
         return 'R%s' % self.duration.ly_expression ()
 
 
+class Break (Music):
+    def __init__ (self, tp="break"):
+        Music.__init__ (self)
+        self.type = tp
+    def print_ly (self, printer):
+        if self.type:
+            printer.dump ("\\%s" % self.type)
+
 class StaffGroup:
     def __init__ (self, command = "StaffGroup"):
         self.stafftype = command
 class StaffGroup:
     def __init__ (self, command = "StaffGroup"):
         self.stafftype = command
index b6a5bbeac87fde3fbef733ffde49c03d318a722a..db53bc49106fa5217d4cec879849c91737672079 100644 (file)
@@ -828,7 +828,7 @@ class Part (Music_xml_node):
            if not (isinstance (n, Note) or isinstance (n, Attributes) or
                     isinstance (n, Direction) or isinstance (n, Partial) or
                     isinstance (n, Barline) or isinstance (n, Harmony) or
            if not (isinstance (n, Note) or isinstance (n, Attributes) or
                     isinstance (n, Direction) or isinstance (n, Partial) or
                     isinstance (n, Barline) or isinstance (n, Harmony) or
-                    isinstance (n, FiguredBass) ):
+                    isinstance (n, FiguredBass) or isinstance (n, Print)):
                continue
 
            if isinstance (n, Attributes) and not start_attr:
                continue
 
            if isinstance (n, Attributes) and not start_attr:
@@ -844,7 +844,7 @@ class Part (Music_xml_node):
                             voices[v].add_element (staff_attributes)
                 continue
 
                             voices[v].add_element (staff_attributes)
                 continue
 
-            if isinstance (n, Partial) or isinstance (n, Barline):
+            if isinstance (n, Partial) or isinstance (n, Barline) or isinstance (n, Print):
                 for v in voices.keys ():
                     voices[v].add_element (n)
                 continue
                 for v in voices.keys ():
                     voices[v].add_element (n)
                 continue
@@ -1147,6 +1147,9 @@ class BeatUnitDot (Music_xml_node):
 class PerMinute (Music_xml_node):
     pass
 
 class PerMinute (Music_xml_node):
     pass
 
+class Print (Music_xml_node):
+    pass
+
 
 
 ## need this, not all classes are instantiated
 
 
 ## need this, not all classes are instantiated
@@ -1197,6 +1200,7 @@ class_dict = {
         'pedal': Pedal,
         'per-minute': PerMinute,
        'pitch': Pitch,
         'pedal': Pedal,
         'per-minute': PerMinute,
        'pitch': Pitch,
+        'print': Print,
        'rest': Rest,
         'root': Root,
         'score-part': Score_part,
        'rest': Rest,
         'root': Root,
         'score-part': Score_part,
index 33c0aca03925e8830ff73a6178b18c259aaabae1..5ac94e9359e3a1e6ac0ab8194b2544dca27003c8 100644 (file)
@@ -930,6 +930,30 @@ def musicxml_attributes_to_lily (attrs):
                 elts.append (ev)
     
     return elts
                 elts.append (ev)
     
     return elts
+    
+def musicxml_print_to_lily (el):
+    # TODO: Implement other print attributes
+    #  <!ELEMENT print (page-layout?, system-layout?, staff-layout*,
+    #          measure-layout?, measure-numbering?, part-name-display?, 
+    #          part-abbreviation-display?)>
+    #  <!ATTLIST print
+    #      staff-spacing %tenths; #IMPLIED
+    #      new-system %yes-no; #IMPLIED
+    #      new-page %yes-no-number; #IMPLIED
+    #      blank-page NMTOKEN #IMPLIED
+    #      page-number CDATA #IMPLIED 
+    #  >
+    elts = []
+    if (hasattr (el, "new-system")):
+        val = getattr (el, "new-system")
+        if (val == "yes"):
+            elts.append (musicexp.Break ("break"))
+    if (hasattr (el, "new-page")):
+        val = getattr (el, "new-page")
+        if (val == "yes"):
+            elts.append (musicexp.Break ("pageBreak"))
+    return elts
+
 
 class Marker (musicexp.Music):
     def __init__ (self):
 
 class Marker (musicexp.Music):
     def __init__ (self):
@@ -2126,6 +2150,12 @@ def musicxml_voice_to_lily_voice (voice):
                     chordnames_builder.add_barline (a, False)
             continue
 
                     chordnames_builder.add_barline (a, False)
             continue
 
+
+        if isinstance (n, musicxml.Print):
+            for a in musicxml_print_to_lily (n):
+                voice_builder.add_command (a, False)
+            continue
+
         # Continue any multimeasure-rests before trying to add bar checks!
         # Don't handle new MM rests yet, because for them we want bar checks!
         rest = n.get_maybe_exist_typed_child (musicxml.Rest)
         # Continue any multimeasure-rests before trying to add bar checks!
         # Don't handle new MM rests yet, because for them we want bar checks!
         rest = n.get_maybe_exist_typed_child (musicxml.Rest)