]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/musicxml2ly.py
MusicXML: Fix invalid MusicXML files
[lilypond.git] / scripts / musicxml2ly.py
index 2f4b807080b82b615973bef22e00988dd4697d24..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:
@@ -2707,7 +2713,7 @@ information.""") % 'lilypond')
     p.add_option ('-l', '--language',
                   metavar = _ ("LANG"),
                   action = "store",
-                  help = _ ("use a different language file 'LANG.ly' and corresponding pitch names, e.g. 'deutsch' for deutsch.ly"))
+                  help = _ ("use LANG for pitch names, e.g. 'deutsch' for note names in German"))
 
     p.add_option ('--nd', '--no-articulation-directions',
                   action = "store_false",
@@ -3000,7 +3006,7 @@ def main ():
     if options.language:
         musicexp.set_pitch_language (options.language)
         needed_additional_definitions.append (options.language)
-        additional_definitions[options.language] = "\\include \"%s.ly\"\n" % options.language
+        additional_definitions[options.language] = "\\language \"%s\"\n" % options.language
     conversion_settings.ignore_beaming = not options.convert_beaming
     conversion_settings.convert_page_layout = options.convert_page_layout