]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/musicxml2ly.py
MusicXML: Fix invalid MusicXML files
[lilypond.git] / scripts / musicxml2ly.py
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: