printer.dump ("-\\markup{ \\dynamic %s }" % self.type)
+class TextEvent (Event):
+ def __init__ (self):
+ self.Text = None
+ self.force_direction = None
+ self.markup = ''
+ def wait_for_note (self):
+ return True
+
+ def direction_mod (self):
+ return { 1: '^', -1: '_', 0: '-' }.get (self.force_direction, '-')
+
+ def ly_expression (self):
+ base_string = '%s\"%s\"'
+ if self.markup:
+ base_string = '%s\markup{ ' + self.markup + ' {%s} }'
+ return base_string % (self.direction_mod (), self.text)
+
class ArticulationEvent (Event):
def __init__ (self):
self.type = None
event.type = dynentry.get_name ()
return event
+def musicxml_words_to_lily_event (words):
+ event = musicexp.TextEvent ()
+ text = words.get_text ()
+ text = re.sub ('^ *\n? *', '', text)
+ text = re.sub (' *\n? *$', '', text)
+
+ if hasattr (words, 'default-y'):
+ if getattr (words, 'default-y') > 0:
+ event.force_direction = 1
+ else:
+ event.force_direction = -1
+
+ if hasattr (words, 'font-weight'):
+ font_weight = { "normal": '', "bold": '\\bold' }.get (getattr (words, 'font-weight'), '')
+ if font_weight:
+ event.markup += font_weight
+ if hasattr (words, 'font-size'):
+ font_size = { "xx-small": '\\smaller\\smaller\\smaller', "x-small": '\\smaller\\smaller', "small": '\\smaller', "medium": '', "large": '\\large', "x-large": '\\large\\large', "xx-large": '\\large\\large\\large' }.get (getattr (words, 'font-size'), '')
+ if font_size:
+ event.markup += font_size
+ #TODO: Convert the other attributes defined in %text-formatting in common.mod:
+ # color, font-family
+
+ event.text = text #re.replace (text, "^ *\n? *(.*) *\n? *", "\1")
+ return event
+
direction_spanners = [ 'octave-shift', 'pedal', 'wedge' ]
dirtype_children += dt.get_all_children ()
for entry in dirtype_children:
+
if entry.get_name () == "dynamics":
for dynentry in entry.get_all_children ():
ev = musicxml_dynamics_to_lily_event (dynentry)
if ev:
res.append (ev)
+ if entry.get_name () == "words":
+ ev = musicxml_words_to_lily_event (entry)
+ if ev:
+ res.append (ev)
+
# octave shifts. pedal marks, hairpins etc. are spanners:
if entry.get_name() in direction_spanners:
event = musicxml_spanner_to_lily_event (entry)