import abjad import abjadext.rmakers as rmakers import muda durations_general = [(4, 4)] * 32 rmaker_afluteA = rmakers.stack( rmakers.talea([4, -2, 1], 8), rmakers.extract_trivial(), # counts # denominator tag=abjad.Tag("Mat_A"), ) rmaker_afluteB = rmakers.stack( rmakers.talea([1], 8, extra_counts=[1]), rmakers.beam(), rmakers.extract_trivial(), # counts # denominator # rmakers.rewrite_meter(), tag=abjad.Tag("Mat_B"), ) rest_maker = rmakers.stack(rmakers.note(), rmakers.force_rest(abjad.select()), tag=abjad.Tag("Rests")) rmaker_bclarinetA = rmakers.stack( rmakers.talea([-4, 2], 8), # counts # denominator rmakers.beam(), rmakers.extract_trivial(), tag=abjad.Tag("Mat_A"), ) rmaker_bclarinetB = rmakers.stack(
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()"), )
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))",
# 2 _ 2 _ 2 _ 2 _ 2 # 4 _ _ _ 4 _ \ _ _ 1 3 _ _ \ 1 3 _ _ 1 2 _ 1 2 _ 1 1 # 1 2 _ 1 2 _ \ 1 3 _ _ 1 3 \ _ _ 1 2 _ 1 2 _ 1 1 # 2 _ 3 _ _ 4 \ _ _ _ 1 3 _ \ _ 1 2 _ 1 2 _ 1 1 # TALEA RHYTHM MAKER selector = abjad.select().tuplets()[:-1] selector = selector.map(abjad.select().note(-1)) rhythm_maker_voice_two = rmakers.stack( rmakers.talea( [4, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1, 1], # counts 8, # denominator ), # rmakers.beam(), rmakers.extract_trivial(), rmakers.tie(selector), ) rhythm_maker_voice_three = rmakers.stack( rmakers.talea( [1, 2, 1, 2, 1, 3, 1, 3, 1, 2, 1, 2, 1, 1], # counts 8, # denominator ), # rmakers.beam(), rmakers.extract_trivial(), rmakers.tie(selector), ) rhythm_maker_voice_four = rmakers.stack( rmakers.talea(
time_signatures = [] for item in durations: if isinstance(item, list): for i in item: time_signatures.append(abjad.TimeSignature(i)) else: time_signatures.append(abjad.TimeSignature(item)) # time_signatures = timespans.time_signatures() # It is a list of durations where each one is annotated with # the material name. # Rhythms of each material makers = { "matL": rmakers.stack(rmakers.talea([2, 1, -1], 16), rmakers.extract_trivial()), "matK": rmakers.stack( rmakers.talea([1, 1, 1, 1, 1], 32, extra_counts=[1]), rmakers.extract_trivial(), ), "matJ": rmakers.stack( rmakers.talea([-1, 1, -1], 8, extra_counts=[1]), rmakers.extract_trivial() ), "matI": rmakers.stack( rmakers.talea([1, 1, 1], 4, extra_counts=[1]), rmakers.extract_trivial() ), "matH": rmakers.stack( rmakers.talea([-3, -2, 1, -3, -3], 16, extra_counts=[4]), rmakers.extract_trivial(), ), "matG": rmakers.stack(