示例#1
0
 def _apply_beam_specifier(self, selections):
     from abjad.tools import rhythmmakertools
     beam_specifier = self.beam_specifier
     if beam_specifier is None:
         beam_specifier = rhythmmakertools.BeamSpecifier()
     if beam_specifier.beam_divisions_together:
         durations = []
         for x in selections:
             if isinstance(x, selectiontools.Selection):
                 duration = x.get_duration()
             else:
                 duration = x._get_duration()
             durations.append(duration)
         beam = spannertools.DuratedComplexBeam(
             durations=durations,
             span_beam_count=1,
         )
         components = []
         for x in selections:
             if isinstance(x, selectiontools.Selection):
                 components.extend(x)
             elif isinstance(x, scoretools.Tuplet):
                 components.append(x)
             else:
                 raise TypeError(x)
         attach(beam, components)
     elif beam_specifier.beam_each_division:
         for cell in selections:
             beam = spannertools.MultipartBeam()
             attach(beam, cell)
示例#2
0
 def _make_music(self, divisions, seeds):
     from abjad.tools import rhythmmakertools
     selections = []
     for division in divisions:
         assert isinstance(division, durationtools.Division), division
     for division in divisions:
         container = self._make_container(division)
         selection = selectiontools.Selection(container)
         selections.append(selection)
     beam_specifier = self.beam_specifier
     if not beam_specifier:
         beam_specifier = rhythmmakertools.BeamSpecifier()
     if beam_specifier.beam_divisions_together:
         durations = []
         for selection in selections:
             duration = selection.get_duration()
             durations.append(duration)
         beam = spannertools.DuratedComplexBeam(
             durations=durations,
             span_beam_count=1,
             nibs_towards_nonbeamable_components=False,
         )
         components = []
         for selection in selections:
             components.extend(selection)
         attach(beam, components)
     elif beam_specifier.beam_each_division:
         for selection in selections:
             beam = spannertools.MultipartBeam()
             attach(beam, selection)
     return selections
示例#3
0
 def _make_music(self, divisions, rotation):
     selections = []
     for division in divisions:
         prototype = mathtools.NonreducedFraction
         assert isinstance(division, prototype), division
     for division in divisions:
         container = self._make_container(division)
         selection = selectiontools.Selection(container)
         selections.append(selection)
     beam_specifier = self._get_beam_specifier()
     if beam_specifier.beam_divisions_together:
         durations = []
         for selection in selections:
             duration = selection.get_duration()
             durations.append(duration)
         beam = spannertools.DuratedComplexBeam(
             durations=durations,
             span_beam_count=1,
             nibs_towards_nonbeamable_components=False,
         )
         components = []
         for selection in selections:
             components.extend(selection)
         leaves = select(components).by_leaf()
         #attach(beam, components)
         attach(beam, leaves)
     elif beam_specifier.beam_each_division:
         for selection in selections:
             beam = spannertools.MultipartBeam()
             leaves = select(selection).by_leaf()
             #attach(beam, selection)
             attach(beam, leaves)
     return selections
示例#4
0
 def _apply(self, selections):
     if self.beam_divisions_together:
         durations = []
         for selection in selections:
             if isinstance(selection, selectiontools.Selection):
                 duration = selection.get_duration()
             else:
                 duration = selection._get_duration()
             durations.append(duration)
         beam = spannertools.DuratedComplexBeam(
             durations=durations,
             span_beam_count=1,
         )
         components = []
         for selection in selections:
             if isinstance(selection, selectiontools.Selection):
                 components.extend(selection)
             elif isinstance(selection, scoretools.Tuplet):
                 components.append(selection)
             else:
                 raise TypeError(selection)
         if self.stemlet_length is not None:
             grob_proxy = override(beam).staff.stem
             grob_proxy.stemlet_length = self.stemlet_length
         attach(beam, components)
     elif self.beam_each_division:
         for selection in selections:
             beam = spannertools.MultipartBeam(beam_rests=self.beam_rests)
             if self.stemlet_length is not None:
                 grob_proxy = override(beam).staff.stem
                 grob_proxy.stemlet_length = self.stemlet_length
             attach(beam, selection)
示例#5
0
    def __call__(self, selections):
        r'''Calls beam specifier on `selections`.

        Returns none.
        '''
        if self.beam_divisions_together:
            durations = []
            for selection in selections:
                if isinstance(selection, selectiontools.Selection):
                    duration = selection.get_duration()
                else:
                    duration = selection._get_duration()
                durations.append(duration)
            beam = spannertools.DuratedComplexBeam(
                durations=durations,
                span_beam_count=1,
            )
            components = []
            for selection in selections:
                if isinstance(selection, selectiontools.Selection):
                    components.extend(selection)
                elif isinstance(selection, scoretools.Tuplet):
                    components.append(selection)
                else:
                    raise TypeError(selection)
            if self.stemlet_length is not None:
                grob_proxy = override(beam).staff.stem
                grob_proxy.stemlet_length = self.stemlet_length
            leaves = select(components).by_leaf()
            #attach(beam, components)
            attach(beam, leaves)
        elif self.beam_each_division:
            for selection in selections:
                beam = spannertools.MultipartBeam(beam_rests=self.beam_rests)
                if self.stemlet_length is not None:
                    grob_proxy = override(beam).staff.stem
                    grob_proxy.stemlet_length = self.stemlet_length
                leaves = select(selection).by_leaf()
                attach(beam, leaves)
示例#6
0
 def _make_music(self, divisions, rotation):
     from abjad.tools import rhythmmakertools
     input_divisions = divisions[:]
     input_ = self._prepare_input(rotation)
     prefix_talea = input_[0]
     prefix_counts = input_[1]
     suffix_talea = input_[2]
     suffix_counts = input_[3]
     extra_counts_per_division = input_[4]
     split_divisions_by_counts = input_[5]
     taleas = (
         prefix_talea,
         suffix_talea,
         extra_counts_per_division,
         split_divisions_by_counts,
     )
     if self.incise_specifier is not None:
         talea_denominator = self.incise_specifier.talea_denominator
     else:
         talea_denominator = None
     input_ = self._scale_taleas(
         divisions,
         talea_denominator,
         taleas,
     )
     divisions = input_[0]
     lcd = input_[1]
     prefix_talea = input_[2]
     suffix_talea = input_[3]
     extra_counts_per_division = input_[4]
     split_divisions_by_counts = input_[5]
     secondary_divisions = self._make_secondary_divisions(
         divisions, split_divisions_by_counts)
     incise_specifier = self._get_incise_specifier()
     if not incise_specifier.outer_divisions_only:
         numeric_map = self._make_division_incised_numeric_map(
             secondary_divisions,
             prefix_talea,
             prefix_counts,
             suffix_talea,
             suffix_counts,
             extra_counts_per_division,
         )
     else:
         assert incise_specifier.outer_divisions_only
         numeric_map = self._make_output_incised_numeric_map(
             secondary_divisions,
             prefix_talea,
             prefix_counts,
             suffix_talea,
             suffix_counts,
             extra_counts_per_division,
         )
     result = []
     selections = \
         self._numeric_map_and_talea_denominator_to_leaf_selections(
         numeric_map, lcd)
     if not self.extra_counts_per_division:
         result.extend(selections)
     else:
         tuplets = self._make_tuplets(
             secondary_divisions,
             selections,
         )
         result.extend(tuplets)
     assert self._all_are_tuplets_or_all_are_leaf_selections(result)
     beam_specifier = self._get_beam_specifier()
     if beam_specifier.beam_divisions_together:
         beam = spannertools.MultipartBeam()
         attach(beam, result)
     elif beam_specifier.beam_each_division:
         for x in result:
             beam = spannertools.MultipartBeam()
             attach(beam, x)
     selections = [selectiontools.Selection(x) for x in result]
     selections = self._apply_output_masks(selections, rotation)
     duration_specifier = self._get_duration_spelling_specifier()
     if duration_specifier.rewrite_meter:
         selections = duration_specifier._rewrite_meter_(
             selections,
             input_divisions,
         )
     return selections