Exemple #1
0
def test_systemtools_StorageFormatAgent_get_import_statements_04():
    subject = rhythmmakertools.IncisedRhythmMaker(
        incise_specifier=rhythmmakertools.InciseSpecifier(
            prefix_talea=(1, ),
            prefix_counts=(0, ),
            suffix_talea=(1, ),
            suffix_counts=(1, ),
            talea_denominator=16,
            body_ratio=mathtools.Ratio((1, )),
            outer_divisions_only=True,
        ),
        beam_specifier=rhythmmakertools.BeamSpecifier(
            beam_each_division=False,
            beam_divisions_together=False,
        ),
        duration_spelling_specifier=rhythmmakertools.DurationSpellingSpecifier(
            decrease_durations_monotonically=True,
            forbidden_written_duration=durationtools.Duration(1, 2),
        ),
        tuplet_spelling_specifier=rhythmmakertools.TupletSpellingSpecifier(
            avoid_dots=True,
            is_diminution=True,
            simplify_redundant_tuplets=True,
        ),
    )
    agent = systemtools.StorageFormatAgent(subject)
    assert agent.get_import_statements() == (
        'from abjad.tools import durationtools',
        'from abjad.tools import mathtools',
        'from abjad.tools import rhythmmakertools',
    )
Exemple #2
0
    def _prepare_input(self, seeds):
        from abjad.tools import rhythmmakertools
        helper_functions = self.helper_functions or {}
        incise_specifier = self.incise_specifier
        if incise_specifier is None:
            incise_specifier = rhythmmakertools.InciseSpecifier()
        prefix_talea = incise_specifier.prefix_talea or ()
        helper = helper_functions.get('prefix_talea')
        helper = self._none_to_trivial_helper(helper)
        prefix_talea = helper(prefix_talea, seeds)
        prefix_talea = datastructuretools.CyclicTuple(prefix_talea)

        prefix_counts = incise_specifier.prefix_counts or (0,)
        helper = helper_functions.get('prefix_counts')
        helper = self._none_to_trivial_helper(helper)
        prefix_counts = helper(prefix_counts, seeds)
        prefix_counts = datastructuretools.CyclicTuple(prefix_counts)

        suffix_talea = incise_specifier.suffix_talea or ()
        helper = helper_functions.get('suffix_talea')
        helper = self._none_to_trivial_helper(helper)
        suffix_talea = helper(suffix_talea, seeds)
        suffix_talea = datastructuretools.CyclicTuple(suffix_talea)

        suffix_counts = incise_specifier.suffix_counts or (0,)
        helper = helper_functions.get('suffix_counts')
        helper = self._none_to_trivial_helper(helper)
        suffix_counts = helper(suffix_counts, seeds)
        suffix_counts = datastructuretools.CyclicTuple(suffix_counts)

        extra_counts_per_division = self.extra_counts_per_division or ()
        helper = helper_functions.get('extra_counts_per_division')
        helper = self._none_to_trivial_helper(helper)
        extra_counts_per_division = helper(extra_counts_per_division, seeds)
        if extra_counts_per_division:
            extra_counts_per_division = datastructuretools.CyclicTuple(
                extra_counts_per_division)
        else:
            extra_counts_per_division = datastructuretools.CyclicTuple([0])

        split_divisions_by_counts = self.split_divisions_by_counts or ()
        helper = helper_functions.get('split_divisions_by_counts')
        helper = self._none_to_trivial_helper(helper)
        split_divisions_by_counts = helper(split_divisions_by_counts, seeds)
        split_divisions_by_counts = datastructuretools.CyclicTuple(
            split_divisions_by_counts)

        return (
            prefix_talea,
            prefix_counts,
            suffix_talea,
            suffix_counts,
            extra_counts_per_division,
            split_divisions_by_counts,
            )
Exemple #3
0
 def _make_middle_of_numeric_map_part(self, middle):
     from abjad.tools import rhythmmakertools
     incise_specifier = self.incise_specifier
     if incise_specifier is None:
         incise_specifier = rhythmmakertools.InciseSpecifier()
     if incise_specifier.fill_with_notes:
         if not incise_specifier.outer_divisions_only:
             if 0 < middle:
                 if incise_specifier.body_ratio is not None:
                     shards = mathtools.divide_number_by_ratio(
                         middle, incise_specifier.body_ratio)
                     return tuple(shards)
                 else:
                     return (middle,)
             else:
                 return ()
         elif incise_specifier.outer_divisions_only:
             if 0 < middle:
                 return (middle,)
             else:
                 return ()
         else:
             message = 'must incise divisions or output.'
             raise Exception(message)
     else:
         if not incise_specifier.outer_divisions_only:
             if 0 < middle:
                 return (-abs(middle),)
             else:
                 return ()
         elif incise_specifier.outer_divisions_only:
             if 0 < middle:
                 return (-abs(middle),)
             else:
                 return ()
         else:
             message = 'must incise divisions or output.'
             raise Exception(message)
Exemple #4
0
 def _get_incise_specifier(self):
     from abjad.tools import rhythmmakertools
     if self.incise_specifier is not None:
         return self.incise_specifier
     return rhythmmakertools.InciseSpecifier()
     forbid_repetitions=True,
     pitch_specifier=abbreviations.agitato_pitch_specifier,
     register_specifier=consort.RegisterSpecifier(
         base_pitch='G3',
         phrase_inflections=consort.RegisterInflection
             .zigzag(3)
             .reverse()
             .align(),
         segment_inflections=consort.RegisterInflection
             .descending(width=3)
             .align()
         ),
     ),
 rhythm_maker=consort.CompositeRhythmMaker(
     default=rhythmmakertools.TaleaRhythmMaker(
         extra_counts_per_division=[0, 0, 1],
         talea=rhythmmakertools.Talea(
             counts=[1, -1, 1, -2, 1, -3],
             denominator=16,
             ),
         ),
     last=rhythmmakertools.IncisedRhythmMaker(
         incise_specifier=rhythmmakertools.InciseSpecifier(
             fill_with_notes=False,
             prefix_counts=[1],
             prefix_talea=[1],
             talea_denominator=16,
             ),
         ),
     ),
 )
from abjad.tools import indicatortools
from abjad.tools import rhythmmakertools
from abjad.tools import scoretools
from abjad.tools import selectortools
from abjad.tools import spannertools

right_hand_pizzicati_music_specifier = consort.MusicSpecifier(
    attachment_handler=consort.AttachmentHandler(
        bow_contact_points=consort.AttachmentExpression(
            attachments=(indicatortools.BowContactPoint(None), ),
            selector=selectortools.Selector().by_leaf().flatten(),
        ),
        bow_contact_spanner=spannertools.BowContactSpanner(),
        dynamic_expressions=consort.DynamicExpression(dynamic_tokens='mf', ),
        string_contact_points=consort.AttachmentExpression(
            attachments=indicatortools.StringContactPoint('pizzicato'),
            scope=scoretools.Voice,
            selector=selectortools.Selector().by_leaf()[0]),
        string_contact_spanner=consort.StringContactSpanner(),
    ),
    rhythm_maker=rhythmmakertools.IncisedRhythmMaker(
        incise_specifier=rhythmmakertools.InciseSpecifier(
            fill_with_notes=False,
            prefix_counts=(1, 1, 1, 1, 2, 1),
            prefix_talea=(1, ),
            suffix_talea=(1, ),
            suffix_counts=(0, ),
            talea_denominator=16,
        ), ),
)
Exemple #7
0
 def _make_music(self, divisions, seeds):
     from abjad.tools import rhythmmakertools
     input_ = self._prepare_input(seeds)
     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.incise_specifier
     if incise_specifier is None:
         incise_specifier = rhythmmakertools.InciseSpecifier()
     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.beam_specifier
     if beam_specifier is None:
         beam_specifier = rhythmmakertools.BeamSpecifier()
     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)
     return selections
            ),
            scope=scoretools.Voice,
            selector=selectortools.Selector().append_callback(
                consort.PhrasedSelectorCallback()).by_counts(
                    [1, -2, 1, -2, 1, -1],
                    cyclic=True,
                    nonempty=True,
                    overhang=True,
                ).flatten()),
        string_contact_spanner=consort.StringContactSpanner(),
    ),
    rhythm_maker=consort.CompositeRhythmMaker(
        last=rhythmmakertools.IncisedRhythmMaker(
            incise_specifier=rhythmmakertools.InciseSpecifier(
                prefix_counts=[0],
                suffix_talea=[1],
                suffix_counts=[1],
                talea_denominator=16,
            ), ),
        default=rhythmmakertools.EvenDivisionRhythmMaker(
            denominators=(4, ),
            extra_counts_per_division=(0, 0, 0, 1, 0, 0, 1, 0, 1),
            duration_spelling_specifier=rhythmmakertools.
            DurationSpellingSpecifier(
                decrease_durations_monotonically=True,
                forbidden_written_duration=durationtools.Duration(1, 4),
                forbid_meter_rewriting=True,
            ),
        ),
    ),
)