]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Fix issues with dynamics attached to notes (not measure position)
authorReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 6 Sep 2007 14:20:04 +0000 (16:20 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 6 Sep 2007 14:20:04 +0000 (16:20 +0200)
-) Implement the missing musicxml_dynamics_to_lily_event function (simply
   moving code around!), so that dynamics attached to a single note (as
   opposed to given in a <direction> element) are also correctly converted.
-) When we convert unknown dynamics texts using \markup, we need to prepend
   "-".
-) Handle multiple <direction-type> children in a <direction> element.

python/musicexp.py
scripts/musicxml2ly.py

index 0163939b9041aa300b485d3e9e2db406daa67ba7..797494ddb1f2637c95115edbd44ed45b2f28fc8a 100644 (file)
@@ -616,7 +616,7 @@ class DynamicsEvent (Event):
         elif self.type in self.available_commands:
             return '\%s' % self.type
         else:
-            return '\markup{ \dynamic %s }' % self.type
+            return '-\markup{ \dynamic %s }' % self.type
         
     def print_ly (self, printer):
         if self.type == None:
@@ -624,7 +624,7 @@ class DynamicsEvent (Event):
         elif self.type in self.available_commands:
             printer.dump ("\\%s" % self.type)
         else:
-            printer.dump ("\\markup{ \\dynamic %s }" % self.type)
+            printer.dump ("-\\markup{ \\dynamic %s }" % self.type)
 
 
 class ArticulationEvent (Event):
index 478bf83de4162a7c64fbca96750244755817685d..d77f301bdce0e9fa0a6a83055ec5ce4f3844b851 100644 (file)
@@ -355,27 +355,33 @@ def musicxml_articulation_to_lily_event (mxl_event):
     return ev
 
 
-def musicxml_direction_to_lily( n ):
+def musicxml_dynamics_to_lily_event (dynentry):
+    dynamics_available = ( "p", "pp", "ppp", "pppp", "ppppp", "pppppp",
+        "f", "ff", "fff", "ffff", "fffff", "ffffff",
+        "mp", "mf", "sf", "sfp", "sfpp", "fp",
+        "rf", "rfz", "sfz", "sffz", "fz" )
+    if not dynentry.get_name() in dynamics_available:
+        return
+    event = musicexp.DynamicsEvent ()
+    event.type = dynentry.get_name ()
+    return event
+
+
+direction_spanners = [ 'octave-shift', 'pedal' ]
+
+def musicxml_direction_to_lily (n):
     # TODO: Handle the <staff> element!
     res = []
-    dirtype = n.get_maybe_exist_typed_child (musicxml.DirType)
-    if not dirtype: 
-      return res
-
-    direction_spanners = [ 'octave-shift', 'pedal' ]
+    dirtype_children = []
+    for dt in n.get_typed_children (musicxml.DirType):
+        dirtype_children += dt.get_all_children ()
 
-    for entry in dirtype.get_all_children ():
+    for entry in dirtype_children:
         if entry.get_name () == "dynamics":
             for dynentry in entry.get_all_children ():
-                dynamics_available = ( "p", "pp", "ppp", "pppp", "ppppp", "pppppp", 
-                    "f", "ff", "fff", "ffff", "fffff", "ffffff", 
-                    "mp", "mf", "sf", "sfp", "sfpp", "fp", 
-                    "rf", "rfz", "sfz", "sffz", "fz" )
-                if not dynentry.get_name() in dynamics_available: 
-                    continue
-                event = musicexp.DynamicsEvent ()
-                event.type = dynentry.get_name ()
-                res.append (event)
+                ev = musicxml_dynamics_to_lily_event (dynentry)
+                if ev:
+                    res.append (ev)
       
         if entry.get_name() == "wedge":
             if hasattr (entry, 'type'):