示例#1
0
 def _beam_rhythm_containers(self, rhythm_containers):
     beam_specifier = self.source_expression.beam_specifier
     beam_specifier = beam_specifier or rhythmmakertools.BeamSpecifier()
     beam_divisions_together = beam_specifier.beam_divisions_together
     beam_each_division = beam_specifier.beam_each_division
     if beam_divisions_together:
         for container in iterate(rhythm_containers).by_class():
             spanners = container._get_spanners(spannertools.Beam)
             for spanner in spanners:
                 spanner._sever_all_components()
         durations = [x._get_duration() for x in rhythm_containers]
         beam = spannertools.DuratedComplexBeam(
             durations=durations,
             span_beam_count=1,
             )
         attach(beam, rhythm_containers)
     elif beam_each_division:
         for container in iterate(rhythm_containers).by_class():
             spanners = container._get_spanners(spannertools.Beam)
             for spanner in spanners:
                 spanner._sever_all_components()
         for rhythm_container in rhythm_containers:
             duration = rhythm_container._get_duration()
             beam = spannertools.DuratedComplexBeam(
                 durations=[duration],
                 span_beam_count=1,
                 )
             attach(beam, rhythm_container)
示例#2
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)
示例#3
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
示例#4
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
示例#5
0
    def make_spanner_score_03(self):
        r'''Make 200-note voice with durated complex beam spanner
        on every 100 notes.

        ::

            2.12 (r9710) initialization:        251,606 function calls
            2.12 (r9724) initialization:        249,369 function calls

            2.12 (r9703) LilyPond format:       509,752 function calls
            2.12 (r9710) LilyPond format:       510,556 function calls
            2.12 (r9724) LilyPond format:       525,463 function calls

        '''
        from abjad.tools import scoretools
        from abjad.tools import sequencetools
        from abjad.tools import spannertools
        from abjad.tools import topleveltools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        for part in sequencetools.partition_sequence_by_counts(
                voice[:],
            [100],
                cyclic=True,
        ):
            beam = spannertools.DuratedComplexBeam()
            topleveltools.attach(beam, part)
        return voice
示例#6
0
    def make_spanner_score_02(self):
        r'''Make 200-note voice with durated complex beam spanner
        on every 20 notes.

        ::

            2.12 (r9710) initialization:        250,954 function calls
            2.12 (r9724) initialization:        248,717 function calls

            2.12 (r9703) LilyPond format:       495,768 function calls
            2.12 (r9710) LilyPond format:       496,572 function calls
            2.12 (r9724) LilyPond format:       511,471 function calls

        '''
        from abjad.tools import scoretools
        from abjad.tools import sequencetools
        from abjad.tools import spannertools
        from abjad.tools import topleveltools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        for part in sequencetools.partition_sequence_by_counts(
                voice[:],
            [20],
                cyclic=True,
        ):
            beam = spannertools.DuratedComplexBeam()
            topleveltools.attach(beam, part)
        return voice
示例#7
0
    def make_spanner_score_01(self):
        r'''Make 200-note voice with durated complex beam spanner
        on every 4 notes.

        ::

            2.12 (r9710) initialization:        248,654 function calls
            2.12 (r9724) initialization:        248,660 function calls

            2.12 (r9703) LilyPond format:       425,848 function calls
            2.12 (r9710) LilyPond format:       426,652 function calls
            2.12 (r9724) LilyPond format:       441,884 function calls

        '''
        from abjad.tools import scoretools
        from abjad.tools import sequencetools
        from abjad.tools import spannertools
        from abjad.tools import topleveltools
        voice = scoretools.Voice(200 * scoretools.Note("c'16"))
        for part in sequencetools.partition_sequence_by_counts(
                voice[:],
            [4],
                cyclic=True,
        ):
            beam = spannertools.DuratedComplexBeam()
            topleveltools.attach(beam, part)
        return voice
示例#8
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)
示例#9
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)