def music( location, rmaker, *args, forget=False, preprocessor=None, rewrite_meter=None, ): commands = [] arguments = [] for arg in args: if issubclass(arg.__class__, rmakers.Command): commands.append(arg) else: arguments.append(arg) if rewrite_meter is not None: stack = rmakers.stack( rmaker, *commands, rmakers.trivialize(lambda _: abjad.Selection(_).tuplets()), rmakers.rewrite_rest_filled( lambda _: abjad.Selection(_).tuplets()), rmakers.rewrite_sustained(lambda _: abjad.Selection(_).tuplets()), rmakers.extract_trivial(), rmakers.RewriteMeterCommand( boundary_depth=rewrite_meter, reference_meters=[ abjad.Meter((4, 4)) ], # reference meters is for constructing special offset inventories (i.e. akasha 6/8) ), preprocessor=preprocessor, ) handler = RhythmHandler( stack, forget=forget, ) else: stack = rmakers.stack( rmaker, *commands, rmakers.trivialize(lambda _: abjad.Selection(_).tuplets()), rmakers.rewrite_rest_filled( lambda _: abjad.Selection(_).tuplets()), rmakers.rewrite_sustained(lambda _: abjad.Selection(_).tuplets()), rmakers.extract_trivial(), preprocessor=preprocessor, ) handler = RhythmHandler( stack, forget=forget, ) out = MusicCommand( location, handler, *arguments, ) return out
def make_fused_tuplet_monads( *, measures: typings.SliceTyping = None, tuplet_ratio: typing.Tuple[int] = None, ) -> RhythmCommand: """ Makes fused tuplet monads. """ tuplet_ratios = [] if tuplet_ratio is None: tuplet_ratios.append((1, )) else: tuplet_ratios.append(tuplet_ratio) return RhythmCommand( rmakers.stack( rmakers.tuplet(tuplet_ratios), rmakers.beam(), rmakers.rewrite_rest_filled(), rmakers.trivialize(), rmakers.extract_trivial(), rmakers.force_repeat_tie(), preprocessor=lambda _: classes.Sequence( [classes.Sequence(_).sum()]), tag=_site(inspect.currentframe()), ), annotation_spanner_color="#darkcyan", frame=inspect.currentframe(), measures=measures, )
def clb_rhythm( section: str, member: int, counts: typing.Sequence[abjad.IntegerSequence], wrap: int, ): if section in ("First.Violin", "Second.Violin", "Viola"): assert member in range(1, 18 + 1), repr(member) elif section == "Cello": assert member in range(1, 14 + 1), repr(member) elif section == "Contrabass": assert member in range(1, 6 + 1), repr(member) else: assert ValueError(section) section_to_offset = { "First.Violin": 0, "Second.Violin": 18, "Viola": 36, "Cello": 54, "Contrabass": 68, } total_players = 74 index = section_to_offset[section] + member - 1 counts_ = baca.sequence.helianthate(counts, -1, -1) counts_ = abjad.sequence.flatten(counts_) counts_ = abjad.sequence.repeat_to_weight(counts_, total_players * wrap) shards = abjad.sequence.split(counts_, [wrap], cyclic=True, overhang=abjad.Exact) assert len(shards) == total_players assert abjad.sequence.weight(shards) == abjad.sequence.weight(counts_) counts_ = shards[index] extra_counts = None if index % 9 in [2, 3, 6, 7]: extra_counts = [-1] def preprocessor(divisions): result = baca.sequence.fuse(divisions) result = baca.sequence.quarters(result) return result return baca.rhythm( rmakers.talea(counts_, 16, extra_counts=extra_counts), rmakers.beam(), rmakers.rewrite_rest_filled(), rmakers.trivialize(), rmakers.force_diminution(), rmakers.extract_trivial(), rmakers.rewrite_meter(), preprocessor=preprocessor, tag=abjad.Tag("animales.clb_rhythm()"), )
def downbeat_attack(count=1, denominator=8): return baca.rhythm( rmakers.talea([count], denominator), rmakers.force_rest(baca.selectors.lts((1, None)), ), rmakers.beam(), rmakers.rewrite_rest_filled(), rmakers.extract_trivial(), rmakers.rewrite_meter(), tag=abjad.Tag("animales.downbeat_attack()"), )
def brass_manifest_rhythm(part): assert part in range(1, 12 + 1), repr(part) counts, delay, extra_counts = { 1: ([8, 8, -2], 9, [0, 0, 0, 1]), 2: ([8, 8, -2], 13, [0, 1, 0, 0]), 3: ([8, 8, -2], None, [0, 0, 1, 0]), 4: ([8, 8, -2], 4, [1, 0, 0, 0]), 5: ([7, 7, -2], 6, [0, 0, 0, 1]), 6: ([7, 7, -2], 10, [0, 1, 0, 0]), 7: ([7, 7, -2], None, [0, 0, 1, 0]), 8: ([7, 7, -2], 4, [1, 0, 0, 0]), 9: ([6, 6, 6, -2], 9, [0, 0, 0, 1]), 10: ([6, 6, 6, -2], 13, [0, 1, 0, 0]), 11: ([6, 6, 6, -2], None, [0, 0, 1, 0]), 12: ([6, 6, 6, -2], 4, [1, 0, 0, 0]), }[part] if delay is None: preamble = () else: preamble = [-delay] def preprocessor(divisions): result = baca.sequence.fuse(divisions) result = baca.sequence.quarters(divisions) return result return baca.rhythm( rmakers.talea(counts, 8, extra_counts=extra_counts, preamble=preamble), rmakers.beam(), rmakers.rewrite_rest_filled(), rmakers.trivialize(), rmakers.extract_trivial(), rmakers.rewrite_meter(), preprocessor=preprocessor, persist="brass_manifest_rhythm", tag=abjad.Tag("animales.brass_manifest_rhythm()"), )
def pennant_rhythm(extra_counts=None, silences=None): commands = [] if silences is not None: specifier = rmakers.force_rest(baca.selectors.tuplets(silences), ) commands.append(specifier) def preprocessor(divisions): result = baca.sequence.fuse(divisions) result = baca.sequence.quarters(divisions) return result return baca.rhythm( rmakers.talea([1], 16, extra_counts=extra_counts), *commands, rmakers.beam(), rmakers.rewrite_rest_filled(), rmakers.force_diminution(), rmakers.trivialize(), rmakers.extract_trivial(), rmakers.rewrite_meter(), preprocessor=preprocessor, tag=abjad.Tag("animales.pennant_rhythm()"), )
rmaker_one = evans.RTMMaker(rtm=[ "(1 ((3 (1 1 1)) 1 2 2))", "(1 (1 2 2 3))", "(1 ((2 (1 1)) 2 3 1))", "(1 ((2 (1 1)) 3 1 2))", ]) rmaker_two = rmakers.stack( rmakers.talea( [3, -1, 2, -2, 3, 1, 2, 2, -3, 1, -2, 2], 4, extra_counts=[0, 3, -1, 2, -2, 0, 3, 1, 2, 2, 0, -3, 1, -2, 2], ), rmakers.trivialize(abjad.select().tuplets()), rmakers.extract_trivial(abjad.select().tuplets()), rmakers.rewrite_rest_filled(abjad.select().tuplets()), rmakers.rewrite_sustained(abjad.select().tuplets()), ) rmaker_three = evans.RTMMaker(rtm=[ "(1 (2 2 1 3))", "(1 (2 2 1 4))", "(1 (3 3 3 5))", "(1 (4 4 4 5))", "(1 (4 4 3 4))", # "(1 (5 4 4 5))", "(1 (2 1 1 2))", # "(1 (5 5 5 5))", "(1 (1 1 1 1))", # "(1 (4 3 4 4))", "(1 (2 1 2 2))",
from abjadext import rmakers rmaker = rmakers.talea([1, 3, 2, 4, 5], 8, extra_counts=[1, 0, 1, 1, 2, 3, 4]) def quarters(divisions): divisions = evans.BacaSequence(divisions) divisions = evans.BacaSequence( evans.BacaSequence(_).quarters() for _ in divisions) divisions = evans.BacaSequence(divisions).flatten(depth=-1) return divisions commands = [ rmakers.trivialize(lambda _: abjad.Selection(_).tuplets()), rmakers.rewrite_rest_filled(lambda _: abjad.Selection(_).tuplets()), rmakers.rewrite_sustained(lambda _: abjad.Selection(_).tuplets()), rmakers.extract_trivial(), rmakers.RewriteMeterCommand( boundary_depth=-1, reference_meters=[ abjad.Meter((6, 8)), abjad.Meter((9, 8)), ], ), ] stack = rmakers.stack( rmaker, *commands, preprocessor=quarters,