]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/musicxml2ly.py
Merge branch 'master' of git://git.sv.gnu.org/lilypond
[lilypond.git] / scripts / musicxml2ly.py
index bf41a467790d2764e0993e402158f0e32d191254..14c09dadbded444d28d8077e1d695c70481af767 100644 (file)
@@ -756,27 +756,41 @@ def musicxml_spanner_to_lily_event (mxl_event):
     return ev
 
 def musicxml_direction_to_indicator (direction):
-    return { "above": 1, "upright": 1, "up":1, "below": -1, "downright": -1, "down": -1 }.get (direction, 0)
+    return { "above": 1, "upright": 1, "up":1, "below": -1, "downright": -1, "down": -1, "inverted": -1 }.get (direction, 0)
 
 def musicxml_fermata_to_lily_event (mxl_event):
     ev = musicexp.ArticulationEvent ()
-    ev.type = "fermata"
+    txt = mxl_event.get_text ()
+    # The contents of the element defined the shape, possible are normal, angled and square
+    ev.type = { "angled": "shortfermata", "square": "longfermata" }.get (txt, "fermata")
     if hasattr (mxl_event, 'type'):
       dir = musicxml_direction_to_indicator (mxl_event.type)
       if dir and options.convert_directions:
         ev.force_direction = dir
     return ev
 
-
 def musicxml_arpeggiate_to_lily_event (mxl_event):
     ev = musicexp.ArpeggioEvent ()
     ev.direction = musicxml_direction_to_indicator (getattr (mxl_event, 'direction', None))
     return ev
 
-
 def musicxml_tremolo_to_lily_event (mxl_event):
     ev = musicexp.TremoloEvent ()
-    ev.bars = mxl_event.get_text ()
+    txt = mxl_event.get_text ()
+    if txt:
+      ev.bars = txt
+    else:
+      ev.bars = "3"
+    return ev
+
+def musicxml_falloff_to_lily_event (mxl_event):
+    ev = musicexp.BendEvent ()
+    ev.alter = -4
+    return ev
+
+def musicxml_doit_to_lily_event (mxl_event):
+    ev = musicexp.BendEvent ()
+    ev.alter = 4
     return ev
 
 def musicxml_bend_to_lily_event (mxl_event):
@@ -784,6 +798,12 @@ def musicxml_bend_to_lily_event (mxl_event):
     ev.alter = mxl_event.bend_alter ()
     return ev
 
+def musicxml_caesura_to_lily_event (mxl_event):
+    ev = musicexp.MarkupEvent ()
+    # FIXME: default to straight or curved caesura?
+    ev.contents = "\\musicglyph #\"scripts.caesura.straight\""
+    ev.force_direction = 1
+    return ev
 
 def musicxml_fingering_event (mxl_event):
     ev = musicexp.ShortArticulationEvent ()
@@ -834,13 +854,13 @@ articulations_dict = {
     "accidental-mark": musicxml_accidental_mark,
     "bend": musicxml_bend_to_lily_event,
     "breath-mark": (musicexp.NoDirectionArticulationEvent, "breathe"),
-    #"caesura": "caesura",
+    "caesura": musicxml_caesura_to_lily_event,
     #"delayed-turn": "?",
     "detached-legato": (musicexp.ShortArticulationEvent, "_"), # or "portato"
-    #"doit": "",
+    "doit": musicxml_doit_to_lily_event,
     #"double-tongue": "",
     "down-bow": "downbow",
-    #"falloff": "",
+    "falloff": musicxml_falloff_to_lily_event,
     "fingering": musicxml_fingering_event,
     #"fingernails": "",
     #"fret": "",
@@ -867,7 +887,7 @@ articulations_dict = {
     "strong-accent": (musicexp.ShortArticulationEvent, "^"), # or "marcato"
     #"tap": "",
     "tenuto": (musicexp.ShortArticulationEvent, "-"), # or "tenuto"
-    #"thumb-position": "",
+    "thumb-position": "thumb",
     #"toe": "",
     "turn": "turn",
     "tremolo": musicxml_tremolo_to_lily_event,
@@ -1480,12 +1500,6 @@ def musicxml_voice_to_lily_voice (voice):
             #         shake | wavy-line | mordent | inverted-mordent | 
             #         schleifer | tremolo | other-ornament, accidental-mark
             ornaments = notations.get_named_children ('ornaments')
-            for a in ornaments:
-                for ch in a.get_named_children ('tremolo'):
-                    ev = musicxml_tremolo_to_lily_event (ch)
-                    if ev: 
-                        ev_chord.append (ev)
-
             ornaments += notations.get_named_children ('articulations')
             ornaments += notations.get_named_children ('technical')