From: Reinhold Kainhofer Date: Thu, 6 Sep 2007 14:20:04 +0000 (+0200) Subject: MusicXML: Fix issues with dynamics attached to notes (not measure position) X-Git-Tag: release/2.11.33-1~4^2~17^2~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=396efb18a48b61b3a1484f7b089ab43ad5c41b1c;p=lilypond.git MusicXML: Fix issues with dynamics attached to notes (not measure position) -) 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 element) are also correctly converted. -) When we convert unknown dynamics texts using \markup, we need to prepend "-". -) Handle multiple children in a element. --- diff --git a/python/musicexp.py b/python/musicexp.py index 0163939b90..797494ddb1 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -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): diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 478bf83de4..d77f301bdc 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -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 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'):