]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Fix invalid MusicXML files
authorReinhold Kainhofer <reinhold@kainhofer.com>
Wed, 24 Nov 2010 17:10:41 +0000 (18:10 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Wed, 24 Nov 2010 17:10:41 +0000 (18:10 +0100)
Invalid MusicXML spotted by Richard Lanyon, richard.lanyon at avid . com

13 files changed:
input/regression/musicxml/03a-Rhythm-Durations.xml
input/regression/musicxml/11c-TimeSignatures-CompoundSimple.xml
input/regression/musicxml/13c-KeySignatures-NonTraditional.xml
input/regression/musicxml/13d-KeySignatures-Microtones.xml
input/regression/musicxml/21f-Chord-ElementInBetween.xml
input/regression/musicxml/22d-Parenthesized-Noteheads.xml
input/regression/musicxml/24d-AfterGrace.xml
input/regression/musicxml/31a-Directions.xml
input/regression/musicxml/32a-Notations.xml
input/regression/musicxml/33a-Spanners.xml
input/regression/musicxml/71f-AllChordTypes.xml
python/musicxml.py
scripts/musicxml2ly.py

index e0dab25041f4a9b29d94dac6f41a7cf41a11f99d..b9fc0b1508fddcb5e460f7e18b3346bd07300a92 100644 (file)
@@ -39,7 +39,7 @@
         </pitch>
         <duration>1024</duration>
         <voice>1</voice>
-        <type>longa</type>
+        <type>long</type>
       </note>
     </measure>
     <!--=======================================================-->
         </pitch>
         <duration>1536</duration>
         <voice>1</voice>
-        <type>longa</type>
+        <type>long</type>
         <dot/>
       </note>
     </measure>
         </pitch>
         <duration>1792</duration>
         <voice>1</voice>
-        <type>longa</type>
+        <type>long</type>
         <dot/>
         <dot/>
       </note>
index 576ad4e87c51f2c263f5279faaa39be078cf11f9..e0c5cb53ff69e8b33a0fa181abb5be96d53de494 100644 (file)
@@ -96,7 +96,6 @@
           <octave>4</octave>
         </pitch>
         <duration>8</duration>
-        <tie/>
         <voice>1</voice>
         <type>whole</type>
       </note>
index 60872a970b448bf2f9a8fdab3c1a46a5b8191c91..fa7780389024a1d71e60910e04b8f64b808a674b 100644 (file)
       <attributes>
         <divisions>1</divisions>
         <key>
-          <key-step>3</key-step>
+          <key-step>F</key-step>
           <key-alter>1</key-alter>
-          <key-step>5</key-step>
+          <key-step>A</key-step>
           <key-alter>-1</key-alter>
-          <key-step>6</key-step>
+          <key-step>B</key-step>
           <key-alter>-1</key-alter>
         </key>
         <time>
     <measure number="2">
       <attributes>
         <key>
-          <key-step>0</key-step>
+          <key-step>C</key-step>
           <key-alter>-2</key-alter>
-          <key-step>4</key-step>
+          <key-step>G</key-step>
           <key-alter>2</key-alter>
-          <key-step>1</key-step>
+          <key-step>D</key-step>
           <key-alter>-1</key-alter>
-          <key-step>6</key-step>
+          <key-step>B</key-step>
           <key-alter>1</key-alter>
-          <key-step>5</key-step>
+          <key-step>F</key-step>
           <key-alter>0</key-alter>
           <key-octave number="1">2</key-octave>
           <key-octave number="2">3</key-octave>
index 1115b5f5afb1a5e7edefd39876669f38b1da7631..9505e1555e9097d940a55c815632470ba089fcf0 100644 (file)
       <attributes>
         <divisions>1</divisions>
         <key>
-          <key-step>4</key-step>
+          <key-step>G</key-step>
           <key-alter>-1.5</key-alter>
-          <key-step>5</key-step>
+          <key-step>A</key-step>
           <key-alter>-1</key-alter>
-          <key-step>6</key-step>
+          <key-step>B</key-step>
           <key-alter>-0.5</key-alter>
-          <key-step>0</key-step>
+          <key-step>C</key-step>
           <key-alter>0</key-alter>
-          <key-step>1</key-step>
+          <key-step>D</key-step>
           <key-alter>0.5</key-alter>
-          <key-step>2</key-step>
+          <key-step>E</key-step>
           <key-alter>1</key-alter>
-          <key-step>3</key-step>
+          <key-step>F</key-step>
           <key-alter>1.5</key-alter>
         </key>
         <time>
index c0a0b87927599b771b514b12de9a405c6720eec1..6a7de1cd2f67cc00b1c58a04a83538e23c4238b1 100644 (file)
@@ -45,8 +45,8 @@
                 <chord/>
                 <pitch>
                     <step>F</step>
-                    <octave>4</octave>
                     <alter>1</alter>
+                    <octave>4</octave>
                 </pitch>
                 <duration>1</duration>
                 <voice>1</voice>
index 4e4fefad3fc3f99300983f43207e8ec51ed1abdf..297beed22c8743d5b1587ca5cec686bbcf0f8eba 100644 (file)
@@ -41,7 +41,7 @@
         <duration>1</duration>
         <voice>1</voice>
         <type>quarter</type>
-        <notehead parentheses="yes"/>
+        <notehead parentheses="yes">normal</notehead>
       </note>
       <note>
         <pitch>
@@ -71,7 +71,7 @@
         <duration>1</duration>
         <voice>1</voice>
         <type>quarter</type>
-        <notehead parentheses="yes"/>
+        <notehead parentheses="yes">normal</notehead>
       </note>
       <note>
         <chord/>
@@ -91,7 +91,7 @@
         <duration>1</duration>
         <voice>1</voice>
         <type>quarter</type>
-        <notehead parentheses="yes"/>
+        <notehead parentheses="yes">normal</notehead>
       </note>
       <note>
         <chord/>
         <duration>1</duration>
         <voice>1</voice>
         <type>quarter</type>
-        <notehead parentheses="yes"/>
+        <notehead parentheses="yes">normal</notehead>
       </note>
       <note>
         <chord/>
         <duration>1</duration>
         <voice>1</voice>
         <type>quarter</type>
-        <notehead parentheses="yes"/>
+        <notehead parentheses="yes">normal</notehead>
       </note>
       <note>
         <rest/>
         <duration>1</duration>
         <voice>1</voice>
         <type>quarter</type>
-        <notehead parentheses="yes"/>
+        <notehead parentheses="yes">normal</notehead>
       </note>
       <note>
         <rest>
         <duration>1</duration>
         <voice>1</voice>
         <type>quarter</type>
-        <notehead parentheses="yes"/>
+        <notehead parentheses="yes">normal</notehead>
       </note>
       <barline location="right">
         <bar-style>light-heavy</bar-style>
index 94816a2ca975fb99eb3a26ca7e317d608641c386..9e5f3136ccfa92c39f4b4d8d856542f3f8a6eb90 100644 (file)
@@ -5,7 +5,7 @@
   <identification>
     <miscellaneous>
       <miscellaneous-field name="description">Some grace notes and after-graces
-            (indicated by steal-time-previous and steal-time-next).</miscellaneous-field>
+            (indicated by steal-time-previous and steal-time-following).</miscellaneous-field>
     </miscellaneous>
   </identification>
   <part-list>
@@ -52,7 +52,7 @@
         <staff>1</staff>
       </note>
       <note>
-        <grace steal-time-next="20"/>
+        <grace steal-time-following="20"/>
         <pitch>
           <step>A</step>
           <octave>5</octave>
index 95f32abb68509831be8b6f3f13945eeef30a7e2b..4e1412426ac97cb7f452cbaccb4d3dc23b869944 100644 (file)
         <duration>1</duration>
         <voice>1</voice>
         <type>quarter</type>
-        <lyric number="1"><syllabic>continue</syllabic><text>change</text></lyric>
+        <lyric number="1"><syllabic>middle</syllabic><text>change</text></lyric>
       </note>
       <note>
         <pitch><step>C</step><octave>4</octave></pitch>
       <direction>
         <direction-type>
           <scordatura>
-              <accord string="0"><tuning-step>C</tuning-step><tuning-octave>3</tuning-octave></accord>
-              <accord string="1"><tuning-step>G</tuning-step><tuning-octave>5</tuning-octave></accord>
-              <accord string="2"><tuning-step>E</tuning-step><tuning-octave>5</tuning-octave></accord>
+              <accord string="3"><tuning-step>C</tuning-step><tuning-octave>3</tuning-octave></accord>
+              <accord string="2"><tuning-step>G</tuning-step><tuning-octave>5</tuning-octave></accord>
+              <accord string="1"><tuning-step>E</tuning-step><tuning-octave>5</tuning-octave></accord>
           </scordatura>
         </direction-type>
       </direction>
index 06be5dde21740cc73ade0403cd3f51fce2909ca7..ab92216ff21ac46e5833eae442cf172cba8e0fe7 100644 (file)
             <wavy-line placement="below" type="start"/>
           </ornaments>
         </notations>
-        <lyric number="1"><syllabic>continue</syllabic><text>wavy</text></lyric>
+        <lyric number="1"><syllabic>middle</syllabic><text>wavy</text></lyric>
       </note>
       <note>
         <pitch>
         <voice>1</voice>
         <type>quarter</type>
         <notations>
-          <ornaments><tremolo/></ornaments>
+          <ornaments><tremolo>3</tremolo></ornaments>
         </notations>
         <lyric number="1"><text>trem.</text></lyric>
       </note>
index 5fd05e6e5586ce82e518fd76fed447676b4b7ee7..dfcd0b2a381533ab02fa1fc85195212bd2695c7a 100644 (file)
     </measure>
     <!--=======================================================-->
     <measure number="19">
-      <direction>
-        <direction-type>
-          <grouping type="start"/>
-        </direction-type>
-      </direction>
+      <grouping type="start"/>
       <note>
         <pitch>
           <step>B</step>
         <voice>1</voice>
         <type>quarter</type>
       </note>
-      <direction>
-        <direction-type>
-          <grouping type="stop"/>
-        </direction-type>
-      </direction>
+      <grouping type="stop"/>
     </measure>
     <!--=======================================================-->
     <measure number="20">
         <voice>1</voice>
         <type>quarter</type>
         <notations>
-          <ornaments><tremolo type="stop"/></ornaments>
+          <ornaments><tremolo type="stop">2</tremolo></ornaments>
         </notations>
       </note>
       <note>
index f54ec1f61a613ed68b25f222cf7290db87fec78e..d6abafbb15ceac18c848d9dcf17f23f35a719b17 100644 (file)
           <root-step>C</root-step>
         </root>
         <kind>minor-ninth</kind>
-        <lyric number="1"><text>minor-ninth</text></lyric>
       </harmony>
       <note>
         <pitch><step>C</step><octave>4</octave></pitch>
index 76e33ceb7b6792b5acb3615cfe50ae3a4d920730..be3c61ca8f99a9bc4cf0ba8d7d0c992826359eba 100644 (file)
@@ -35,6 +35,8 @@ def musicxml_duration_to_log (dur):
              'longa': -2,
              'long': -2}.get (dur, 0)
 
+
+
 def interpret_alter_element (alter_elm):
     alter = 0
     if alter_elm:
@@ -253,9 +255,8 @@ class Pitch (Music_xml_node):
        return step
     def get_octave (self):
        ch = self.get_unique_typed_child (get_class (u'octave'))
-
-       step = ch.get_text ().strip ()
-       return int (step)
+       octave = ch.get_text ().strip ()
+       return int (octave)
 
     def get_alteration (self):
        ch = self.get_maybe_exist_typed_child (get_class (u'alter'))
@@ -417,7 +418,7 @@ class Attributes (Measure_element):
             current_step = 0
             for i in key.get_all_children ():
                 if isinstance (i, KeyStep):
-                    current_step = int (i.get_text ())
+                    current_step = i.get_text ().strip ()
                 elif isinstance (i, KeyAlter):
                     alterations.append ([current_step, interpret_alter_element (i)])
                 elif isinstance (i, KeyOctave):
@@ -1039,15 +1040,14 @@ class Rest (Music_xml_node):
     def get_step (self):
         ch = self.get_maybe_exist_typed_child (get_class (u'display-step'))
         if ch:
-            step = ch.get_text ().strip ()
-            return step
+            return ch.get_text ().strip ()
         else:
             return None
     def get_octave (self):
         ch = self.get_maybe_exist_typed_child (get_class (u'display-octave'))
         if ch:
-            step = ch.get_text ().strip ()
-            return int (step)
+            oct = ch.get_text ().strip ()
+            return int (oct)
         else:
             return None
 
index 6f70baea076de06f18ecc608fc496d16c084869a..a14119b32092157a989a31b930404eb5382e1ec5 100644 (file)
@@ -342,6 +342,13 @@ class PartGroupInfo:
         error_message (_ ("Unprocessed PartGroupInfo %s encountered") % self)
         return ''
 
+def musicxml_step_to_lily (step):
+    if step:
+        return (ord (step) - ord ('A') + 7 - 2) % 7
+    else:
+        return None
+
+
 def staff_attributes_to_string_tunings (mxl_attr):
     details = mxl_attr.get_maybe_exist_named_child ('staff-details')
     if not details:
@@ -896,7 +903,12 @@ def musicxml_key_to_lily (attributes):
 
     else:
         # Non-standard key signature of the form [[step,alter<,octave>],...]
-        change.non_standard_alterations = key_sig
+        # MusicXML contains C,D,E,F,G,A,B as steps, lily uses 0-7, so convert
+        alterations = []
+        for k in key_sig:
+            k[0] = musicxml_step_to_lily (k[0])
+            alterations.append (k)
+        change.non_standard_alterations = alterations
     return change
 
 def musicxml_transpose_to_lily (attributes):
@@ -2116,12 +2128,6 @@ class VoiceData:
         self.lyrics_dict = {}
         self.lyrics_order = []
 
-def musicxml_step_to_lily (step):
-    if step:
-       return (ord (step) - ord ('A') + 7 - 2) % 7
-    else:
-       return None
-
 def measure_length_from_attributes (attr, current_measure_length):
     len = attr.get_measure_length ()
     if not len: