def color_tuplets(*, dmask=None, rotation=0): """ Makes color tuplets. """ tuplet_ratios = baca.sequence( [ (-2, 4, 1, 1, 12), (3, 2), (4, 3), (3, -2), (-3, 4, 1, 12), (3, 2), (7, 1, 3), (3, -2), ] ) tuplet_ratios = tuplet_ratios.rotate(n=rotation) return baca.rhythm( rhythm_maker=rmakers.TupletRhythmMaker( division_masks=dmask, tag="krummzeit.color_tuplets", tie_specifier=rmakers.TieSpecifier(tie_across_divisions=True), tuplet_ratios=tuplet_ratios, tuplet_specifier=rmakers.TupletSpecifier( extract_trivial=True, rewrite_dots=True ), ) )
def fused_expanse(divisions: typing.List[abjad.DurationTyping]): """ Makes fused expanse rhythm. """ return baca.rhythm( divisions=baca.divisions().fuse().split(divisions, cyclic=True), rhythm_maker=rmakers.NoteRhythmMaker(tag="krummzeit.fused_expanse"), )
def glissando_rhythm(rotate=0): return baca.rhythm( rmakers.talea(abjad.sequence.rotate([5, 1, 2, 1], n=rotate), 8), rmakers.beam(), rmakers.extract_trivial(), rmakers.rewrite_meter(), tag=abjad.Tag("animales.glissando_rhythm()"), )
def polyphony( durations=None, rotation=None, fuse=None, denominators=None, extra_counts=None, final_quarter_notes=None, initial_eighth_notes=None, ties=None, ): """ Makes polyphony rhythm. """ tuplet_specifier = rmakers.TupletSpecifier( extract_trivial=True, trivialize=True ) rhythm_maker = rmakers.EvenDivisionRhythmMaker( denominators=denominators, extra_counts_per_division=extra_counts, tag="krummzeit.polyphony", tie_specifier=rmakers.TieSpecifier(tie_across_divisions=ties), tuplet_specifier=tuplet_specifier, ) if final_quarter_notes: quarters = rmakers.NoteRhythmMaker( duration_specifier=rmakers.DurationSpecifier( forbidden_note_duration=(1, 2) ), tie_specifier=rmakers.TieSpecifier(strip_ties=True), ) indices = [-3, -2, -1] rhythm_maker = [ (rhythm_maker, ~abjad.index(indices)), (quarters, abjad.index(indices)), ] elif initial_eighth_notes: eighths = rmakers.EvenDivisionRhythmMaker( denominators=[8], tuplet_specifier=tuplet_specifier ) indices = [0, 1] rhythm_maker = [ (rhythm_maker, ~abjad.index(indices)), (eighths, abjad.index(indices)), ] split = baca.divisions().split( durations, cyclic=True, remainder_fuse_threshold=fuse, rotate_indexed=rotation, ) return baca.rhythm( divisions=baca.divisions().map(split), rhythm_maker=rhythm_maker )
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 prolated_quarters(extra_counts): """ Makes prolated quarters. """ return baca.rhythm( rhythm_maker=rmakers.EvenDivisionRhythmMaker( denominators=[4], extra_counts_per_division=extra_counts, tag="krummzeit.prolated_quarters", ) )
def right_remainder_quarters(*, dmask=None): """ Makes right-remainder quarter-note-filled measures. """ return baca.rhythm( divisions=baca.divisions().map(baca.divisions().quarters()), rhythm_maker=rmakers.NoteRhythmMaker( division_masks=dmask, tag="krummzeit.right_remainder_quarters" ), )
def detached_triplets(): """ Makes detached triplets. """ return baca.rhythm( divisions=baca.divisions().fuse().quarters(), rhythm_maker=rmakers.TupletRhythmMaker( tag="krummzeit.detached_triplets", tie_specifier=rmakers.TieSpecifier(tie_across_divisions=[1, 0]), tuplet_ratios=[(3, -1, 2), (1, -1, 3, -1)], ), )
def oboe_trills(): """ Makes oboe trill rhythm. """ return baca.rhythm( divisions=baca.divisions().ratios_each([(2, 1), (2, 1), (1, 1, 1)]), rhythm_maker=rmakers.TupletRhythmMaker( division_masks=[abjad.index([3, 4], 6)], tag="krummzeit.oboe_trills", tuplet_ratios=[(1, 1, 1, 1, 3, 3), (3, 4, 1, 1)], ), )
def opening_triplets(*, dmask=None, remainder=abjad.Left): """ Makes opening triplets. """ return baca.rhythm( divisions=baca.divisions().fuse().quarters(remainder=remainder), rhythm_maker=rmakers.TupletRhythmMaker( division_masks=dmask, tag="krummzeit.opening_triplets", tuplet_ratios=[(1, 1, 1)], ), )
def single_division_tuplets(ratios): """ Makes single-division tuplet rhythm. """ return baca.rhythm( rhythm_maker=rmakers.TupletRhythmMaker( tag="krummzeit.single_division_tuplets", tie_specifier=rmakers.TieSpecifier(tie_across_divisions=True), tuplet_ratios=ratios, tuplet_specifier=rmakers.TupletSpecifier( diminution=False, rewrite_dots=True ), ) )
def piano_harmonics(division_ratios, *, dmask=None, tie_across_divisions=None): """ Makes piano harmonics rhythm. """ assert isinstance(division_ratios, list), repr(division_ratios) return baca.rhythm( divisions=baca.divisions().ratios_each(division_ratios), rhythm_maker=rmakers.NoteRhythmMaker( division_masks=dmask, tag="krummzeit.piano_harmonics", tie_specifier=rmakers.TieSpecifier( tie_across_divisions=tie_across_divisions ), ), )
def sponge_rhythm(): """ Makes sponge rhythm. """ return baca.rhythm( rhythm_maker=rmakers.TaleaRhythmMaker( extra_counts_per_division=[2, 1, 0], tag="krummzeit.sponge_rhythm", talea=rmakers.Talea(counts=[1, 2], denominator=2), tie_specifier=rmakers.TieSpecifier(repeat_ties=True), tuplet_specifier=rmakers.TupletSpecifier( extract_trivial=True, trivialize=True ), ) )
def closing_pizzicati( counts, extra_counts_per_division, split_divisions_by_counts ): """ Makes closing pizzicati rhythm. """ return baca.rhythm( rhythm_maker=rmakers.TaleaRhythmMaker( extra_counts_per_division=extra_counts_per_division, rest_tied_notes=True, split_divisions_by_counts=split_divisions_by_counts, tag="krummzeit.closing_pizzicati", talea=rmakers.Talea(counts=counts, denominator=4), tuplet_specifier=rmakers.TupletSpecifier(extract_trivial=True), ) )
def incise_attacks(): """ Makes incise attacks. """ return baca.rhythm( rhythm_maker=rmakers.IncisedRhythmMaker( incise_specifier=rmakers.InciseSpecifier( fill_with_rests=True, prefix_talea=[-1, 1, -2, 0, 0, -1, 1, -2], prefix_counts=[3, 1, 1, 3], suffix_talea=[0, 0, 1, -3, 0], suffix_counts=[1, 1, 2, 1], talea_denominator=16, ), tag="krummzeit.incise_attacks", ) )
def rest_delimited_repeated_duration_notes( duration: abjad.DurationTyping, denominator: int ): """ Makes rest-delimited repeated duration notes. """ return baca.rhythm( divisions=baca.divisions().fuse().split([duration], cyclic=True), rhythm_maker=rmakers.IncisedRhythmMaker( incise_specifier=rmakers.InciseSpecifier( suffix_talea=[-1], suffix_counts=[1], talea_denominator=denominator, ), tag="krummzeit.rest_delimited_repeated_duration_notes", ), )
def silver_points( ratios, *, dmask=None, tuplet_ratios=[(-1, 1, 1, 2), (-1, 1, 1, -2, 2)] ): """ Makes silver point rhythm. """ return baca.rhythm( divisions=baca.divisions().ratios_each(ratios), rhythm_maker=rmakers.TupletRhythmMaker( division_masks=dmask, tag="krummzeit.silver_points", tuplet_ratios=tuplet_ratios, tuplet_specifier=rmakers.TupletSpecifier( extract_trivial=True, rewrite_dots=True ), ), )
def single_cluster_piano_rhythm(): """ Makes single-cluster piano rhythm. """ return baca.rhythm( rhythm_maker=rmakers.IncisedRhythmMaker( incise_specifier=rmakers.InciseSpecifier( fill_with_rests=True, prefix_talea=[-1, 1, -2, 0, 0, -1, 1, -2], prefix_counts=[3, 1, 1, 3], suffix_talea=[0, 0, 1, -3, 0], suffix_counts=[1, 1, 2, 1], talea_denominator=16, ), tag="krummzeit.single_cluster_piano_rhythm", ) )
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()"), )
def harp_exchange_rhythm(this_part, *commands, silence_first=False): part_to_pattern = dict([ (0, abjad.index([0, 30], period=36)), (1, abjad.index([0, 12, 16, 28, 32], period=48)), (2, abjad.index([0, 30], period=36)), (3, abjad.index([0, 12, 16, 28, 32], period=48)), ]) part_to_indices = {} for part in part_to_pattern: part_to_indices[part] = [] harp_indices = [] part = 0 pattern = part_to_pattern[part] index = 0 while True: if index % pattern.period in pattern.indices: part_to_indices[part].append(index) harp_indices.append((index, part)) degrees = [] for indices in part_to_indices.values(): talea = abjad.math.difference_series(indices) degree = baca.sequence.degree_of_rotational_symmetry(talea) degrees.append(degree) if all(1 < _ for _ in degrees): break part = (part + 1) % len(part_to_pattern) pattern = part_to_pattern[part] index += 1 if 999 < index: break part_to_preamble = {} part_to_counts = {} for part, indices in part_to_indices.items(): offset = indices[0] preamble = [] if offset != 0: preamble.append(offset) part_to_preamble[part] = preamble counts = abjad.math.difference_series(indices) period = baca.sequence.period_of_rotation(counts) counts = counts[:period] part_to_counts[part] = counts preamble = part_to_preamble[this_part] counts = [] for count in part_to_counts[this_part]: counts.append(2) rest = -(count - 2) counts.append(rest) silence_first_specifier = [] if silence_first is True: specifier = rmakers.force_rest(baca.selectors.lt(0)) silence_first_specifier.append(specifier) def preprocessor(divisions): result = baca.sequence.fuse(divisions) result = baca.sequence.quarters(result) return result return baca.rhythm( rmakers.talea(counts, 16, extra_counts=[2], preamble=preamble), *commands, rmakers.cache_state(), *silence_first_specifier, rmakers.beam(), rmakers.trivialize(), rmakers.extract_trivial(), rmakers.rewrite_meter(), rmakers.force_repeat_tie(), preprocessor=preprocessor, persist="harp_exchange_rhythm", tag=abjad.Tag("animales.harp_exchange_rhythm()"), )
def sforzando_exchange_rhythm(this_part): part_to_pattern = dict([ (0, abjad.index([0, 15], period=18)), (1, abjad.index([0, 6, 8, 14, 16], period=24)), (2, abjad.index([0, 15], period=18)), (3, abjad.index([0, 6, 8, 14, 16], period=24)), (4, abjad.index([0, 15], period=18)), (5, abjad.index([0, 6, 8, 14, 16], period=24)), (6, abjad.index([0, 15], period=18)), ]) part_to_indices = {} for part in part_to_pattern: part_to_indices[part] = [] sforzando_indices = [] part = 0 pattern = part_to_pattern[part] index = 0 while True: if index % pattern.period in pattern.indices: part_to_indices[part].append(index) sforzando_indices.append((index, part)) degrees = [] for indices in part_to_indices.values(): talea = abjad.math.difference_series(indices) degree = baca.sequence.degree_of_rotational_symmetry(talea) degrees.append(degree) if all(1 < _ for _ in degrees): break part = (part + 1) % len(part_to_pattern) pattern = part_to_pattern[part] index += 1 part_to_preamble = {} part_to_counts = {} for part, indices in part_to_indices.items(): offset = indices[0] preamble = [] if offset != 0: preamble.append(offset) part_to_preamble[part] = preamble counts = abjad.math.difference_series(indices) period = baca.sequence.period_of_rotation(counts) counts = counts[:period] part_to_counts[part] = counts preamble = part_to_preamble[this_part] counts = part_to_counts[this_part] def preprocessor(divisions): result = baca.sequence.fuse(divisions) result = baca.sequence.quarters(divisions) return result return baca.rhythm( rmakers.talea(counts, 16, extra_counts=[2], preamble=preamble), rmakers.beam(), rmakers.trivialize(), rmakers.extract_trivial(), rmakers.rewrite_meter(), rmakers.force_repeat_tie(), preprocessor=preprocessor, persist="sforzando_exchange_rhythm", tag=abjad.Tag("animales.sforzando_exchange_rhythm()"), )