Пример #1
0
 def p_leaf__leaf_body__post_events(self, p):
     r'''leaf : leaf_body post_events
     '''
     p[0] = p[1]
     if p[2]:
         annotation = indicatortools.Annotation('post events', p[2])
         attach(annotation, p[0])
Пример #2
0
 def _process_post_events(self, leaf, post_events):
     for post_event in post_events:
         # TODO: the conditional logic here will have to change;
         #       post events like StemTremolo no longer implement _attach.
         #       Is there a way to identify spanner LilyPondEvents?
         #       Then we can just (blindly) attach all other post events.
         nonspanner_post_event_types = (
             indicatortools.Articulation,
             indicatortools.BarLine,
             indicatortools.Dynamic,
             indicatortools.LilyPondCommand,
             indicatortools.PageBreak,
             indicatortools.StemTremolo,
             indicatortools.SystemBreak,
             markuptools.Markup,
         )
         if hasattr(post_event, '_attach'):
             attach(post_event, leaf)
         elif isinstance(post_event, nonspanner_post_event_types):
             attach(post_event, leaf)
         else:
             annotation = [
                 x for x in leaf._get_indicators(indicatortools.Annotation)
                 if x.name == 'spanners'
             ]
             if not annotation:
                 annotation = indicatortools.Annotation('spanners', [])
                 attach(annotation, leaf)
             else:
                 annotation = annotation[0]
             annotation.value.append(post_event)
Пример #3
0
 def __call__(self, beatspan):
     r'''Calls q-grid.
     '''
     result = self.root_node(beatspan)
     result_leaves = []
     for x in result:
         if isinstance(x, scoretools.Container):
             result_leaves.extend(x.select_leaves())
         else:
             result_leaves.append(x)
     for result_leaf, q_grid_leaf in zip(result_leaves, self.leaves[:-1]):
         if q_grid_leaf.q_event_proxies:
             q_events = [q_event_proxy.q_event
                 for q_event_proxy in q_grid_leaf.q_event_proxies]
             q_events.sort(
                 key=lambda x: 0 if x.index is None else x.index)
             annotation = indicatortools.Annotation(
                 'q_events', tuple(q_events))
             attach(annotation, result_leaf)
     return result
Пример #4
0
 def _make_unrelativable(self, music):
     if not self._is_unrelativable(music):
         annotation = indicatortools.Annotation('UnrelativableMusic')
         attach(annotation, music)