diff -u -r lilypond.02_partorder/usr/bin/musicxml2ly lilypond.03_dynamics/usr/bin/musicxml2ly --- lilypond.02_partorder/usr/bin/musicxml2ly 2007-08-17 17:59:44.000000000 +0200 +++ lilypond.03_dynamics/usr/bin/musicxml2ly 2007-08-17 23:22:18.000000000 +0200 @@ -274,6 +274,27 @@ return ev +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 + + for entry in dirtype.get_all_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 ) + + return res + instrument_drumtype_dict = { 'Acoustic Snare Drum': 'acousticsnare', 'Side Stick': 'sidestick', @@ -322,6 +343,7 @@ class LilyPondVoiceBuilder: def __init__ (self): self.elements = [] + self.pending_dynamics = [] self.end_moment = Rational (0) self.begin_moment = Rational (0) self.pending_multibar = Rational (0) @@ -349,6 +371,16 @@ self.begin_moment = self.end_moment self.end_moment = self.begin_moment + duration + # Insert all pending dynamics right after the note/rest: + if duration > Rational(0): + for d in self.pending_dynamics: + self.elements.append( d ) + self.pending_dynamics = [] + + def add_dynamics (self, dynamic): + # store the dynamic item(s) until we encounter the next note/rest: + self.pending_dynamics.append( dynamic ) + def add_bar_check (self, number): b = musicexp.BarCheck () b.bar_number = number @@ -399,6 +431,11 @@ if n.get_name () == 'forward': continue + if isinstance (n, musicxml.Direction): + for a in musicxml_direction_to_lily (n): + voice_builder.add_dynamics( a ) + continue + if not n.get_maybe_exist_named_child ('chord'): try: voice_builder.jumpto (n._when) @@ -526,6 +563,12 @@ ev = musicxml_articulation_to_lily_event( ch ) if ev: ev_chord.append(ev) + dynamics = notations.get_named_children('dynamics') + for a in dynamics: + for ch in a.get_all_children(): + ev = musicxml_dynamics_to_lily_event(ch) + if ev: ev_chord.append(ev) + mxl_beams = [b for b in n.get_named_children ('beam') if (b.get_type () in ('begin', 'end') and b.is_primary ())] diff -u -r lilypond.02_partorder/usr/share/lilypond/current/python/musicexp.py lilypond.03_dynamics/usr/share/lilypond/current/python/musicexp.py --- lilypond.02_partorder/usr/share/lilypond/current/python/musicexp.py 2007-08-17 17:59:44.000000000 +0200 +++ lilypond.03_dynamics/usr/share/lilypond/current/python/musicexp.py 2007-08-17 23:22:31.000000000 +0200 @@ -498,6 +498,29 @@ def ly_expression (self): return '~' +class DynamicsEvent(Event): + def __init__(self): + self.type = None + self.available_commands = [ "ppppp", "pppp", "ppp", "pp", "p", + "mp", "mf", + "f", "ff", "fff", "ffff", + "fp", "sf", "sff", "sp", "spp", "sfz", "rfz" ]; + def ly_expression(self): + if ( self.type == None ): + return; + elif ( self.type in self.available_commands ): + return '\%s' % self.type + else: + return '\markup{ \dynamic %s }' % self.type + + def print_ly (self, printer): + if ( self.type == None ): + return + elif ( self.type in self.available_commands ): + printer.dump( "\\%s" % self.type ) + else: + printer.dump( "\\markup{ \\dynamic %s }" % self.type ) + class ArticulationEvent(Event): def __init__(self): self.type = None BinÀrdateien lilypond.02_partorder/usr/share/lilypond/current/python/musicexp.pyc and lilypond.03_dynamics/usr/share/lilypond/current/python/musicexp.pyc sind verschieden. diff -u -r lilypond.02_partorder/usr/share/lilypond/current/python/musicxml.py lilypond.03_dynamics/usr/share/lilypond/current/python/musicxml.py --- lilypond.02_partorder/usr/share/lilypond/current/python/musicxml.py 2007-08-17 17:59:44.000000000 +0200 +++ lilypond.03_dynamics/usr/share/lilypond/current/python/musicxml.py 2007-08-17 23:22:31.000000000 +0200 @@ -354,14 +354,14 @@ for n in elements: voice_id = n.get_maybe_exist_typed_child (class_dict['voice']) - if not (voice_id or isinstance (n, Attributes)): + if not (voice_id or isinstance (n, Attributes) or isinstance(n, Direction) ): continue if isinstance (n, Attributes) and not start_attr: start_attr = n continue - if isinstance (n, Attributes): + if isinstance (n, Attributes) or isinstance(n, Direction): for v in voices.values (): v.add_element (n) continue BinÀrdateien lilypond.02_partorder/usr/share/lilypond/current/python/musicxml.pyc and lilypond.03_dynamics/usr/share/lilypond/current/python/musicxml.pyc sind verschieden.