Example #1
0
    def __call__(self, pulse_duration):
        r'''Generate Abjad score components:

        ::

            >>> leaf = rhythmtreetools.RhythmTreeLeaf(5)
            >>> leaf((1, 4))
            Selection(Note("c'1"), Note("c'4"))

        Returns sequence of components.
        '''
        pulse_duration = durationtools.Duration(pulse_duration)
        total_duration = pulse_duration * self.preprolated_duration
        if self.is_pitched:
            return scoretools.make_notes(0, total_duration)
        return scoretools.make_rests(total_duration)
Example #2
0
    def __call__(self, pulse_duration):
        r'''Generate Abjad score components:

        ::

            >>> leaf = rhythmtreetools.RhythmTreeLeaf(5)
            >>> leaf((1, 4))
            Selection(Note("c'1"), Note("c'4"))

        Returns sequence of components.
        '''
        pulse_duration = durationtools.Duration(pulse_duration)
        total_duration = pulse_duration * self.preprolated_duration
        if self.is_pitched:
            return scoretools.make_notes(0, total_duration)
        return scoretools.make_rests(total_duration)
Example #3
0
 def _simplify_tuplets(self, selections):
     tuplet_spelling_specifier = self._get_tuplet_spelling_specifier()
     if not tuplet_spelling_specifier.simplify_tuplets:
         return
     for tuplet in iterate(selections).by_class(scoretools.Tuplet):
         if tuplet.is_trivial:
             continue
         duration = tuplet._get_duration()
         if all(isinstance(x, scoretools.Rest) for x in tuplet):
             rests = scoretools.make_rests([duration])
             tuplet[:] = rests
         elif all(isinstance(x, scoretools.Note) for x in tuplet):
             logical_ties = set([x._get_logical_tie() for x in tuplet])
             if len(logical_ties) == 1:
                 notes = scoretools.make_notes([0], [duration])
                 tuplet[:] = notes
Example #4
0
 def _simplify_tuplets(self, selections):
     tuplet_spelling_specifier = self._get_tuplet_spelling_specifier()
     if not tuplet_spelling_specifier.simplify_tuplets:
         return
     for tuplet in iterate(selections).by_class(scoretools.Tuplet):
         if tuplet.is_trivial:
             continue
         duration = tuplet._get_duration()
         if all(isinstance(x, scoretools.Rest) for x in tuplet):
             rests = scoretools.make_rests([duration])
             tuplet[:] = rests
         elif all(isinstance(x, scoretools.Note) for x in tuplet):
             logical_ties = set([x._get_logical_tie() for x in tuplet])
             if len(logical_ties) == 1:
                 notes = scoretools.make_notes([0], [duration])
                 tuplet[:] = notes
Example #5
0
 def _rewrite_rest_filled_tuplets(self, selections):
     tuplet_spelling_specifier = self._get_tuplet_spelling_specifier()
     if not tuplet_spelling_specifier.rewrite_rest_filled_tuplets:
         return selections
     new_selections = []
     for selection in selections:
         new_selection = []
         for component in selection:
             if not (isinstance(component, scoretools.Tuplet)
                     and component._is_rest_filled):
                 new_selection.append(component)
                 continue
             duration = inspect_(component).get_duration()
             new_rests = scoretools.make_rests([duration])
             mutate(component[:]).replace(new_rests)
             new_selection.append(component)
         new_selection = selectiontools.Selection(new_selection)
         new_selections.append(new_selection)
     return new_selections
Example #6
0
 def _rewrite_rest_filled_tuplets(self, selections):
     tuplet_spelling_specifier = self._get_tuplet_spelling_specifier()
     if not tuplet_spelling_specifier.rewrite_rest_filled_tuplets:
         return selections
     new_selections = []
     for selection in selections:
         new_selection = []
         for component in selection:
             if not (isinstance(component, scoretools.Tuplet) and 
                 component._is_rest_filled):
                 new_selection.append(component)
                 continue
             duration = inspect_(component).get_duration()
             new_rests = scoretools.make_rests([duration])
             mutate(component[:]).replace(new_rests)
             new_selection.append(component)
         new_selection = selectiontools.Selection(new_selection)
         new_selections.append(new_selection)
     return new_selections