% self.duration.lisp_expression ())
class RestEvent (RhythmicEvent):
+ def __init__ (self):
+ RhythmicEvent.__init__ (self)
+ self.pitch = None
def ly_expression (self):
- return 'r%s' % self.duration.ly_expression ()
+ if self.pitch:
+ return "%s%s\\rest" % (self.pitch.ly_expression (), self.duration.ly_expression ())
+ else:
+ return 'r%s' % self.duration.ly_expression ()
def print_ly (self, printer):
- printer('r')
- self.duration.print_ly (printer)
+ if self.pitch:
+ self.pitch.print_ly (printer)
+ self.duration.print_ly (printer)
+ printer ('\\rest')
+ else:
+ printer('r')
+ self.duration.print_ly (printer)
class SkipEvent (RhythmicEvent):
def ly_expression (self):
self._is_whole_measure = False
def is_whole_measure (self):
return self._is_whole_measure
+ def get_step (self):
+ ch = self.get_maybe_exist_typed_child (get_class (u'display-step'))
+ if ch:
+ step = ch.get_text ().strip ()
+ return step
+ else:
+ return None
+ def get_octave (self):
+ ch = self.get_maybe_exist_typed_child (get_class (u'display-octave'))
+ if ch:
+ step = ch.get_text ().strip ()
+ return int (step)
+ else:
+ return None
class Type (Music_xml_node):
pass
event.cautionary = acc.editorial
elif n.get_maybe_exist_typed_child (musicxml.Rest):
+ # rests can have display-octave and display-step, which are
+ # treated like an ordinary note pitch
+ rest = n.get_maybe_exist_typed_child (musicxml.Rest)
event = musicexp.RestEvent()
+ pitch = musicxml_restdisplay_to_lily (rest)
+ event.pitch = pitch
elif n.instrument_name:
event = musicexp.NoteEvent ()
drum_type = instrument_drumtype_dict.get (n.instrument_name)
p.octave = mxl_pitch.get_octave () - 4
return p
+def musicxml_restdisplay_to_lily (mxl_rest):
+ p = None
+ step = mxl_rest.get_step ()
+ if step:
+ p = musicexp.Pitch()
+ p.step = (ord (step) - ord ('A') + 7 - 2) % 7
+ octave = mxl_rest.get_octave ()
+ if octave and p:
+ p.octave = octave - 4
+ return p
+
def voices_in_part (part):
"""Return a Name -> Voice dictionary for PART"""
part.interpret ()