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 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 VC(voice): voice = score["Cello.Music"] music = baca.make_repeat_tied_notes( accumulator.get(1, 4), do_not_rewrite_meter=True ) voice.extend(music) rhythm_maker = rmakers.bind( rmakers.assign( make_vc_waves, abjad.index([1, 2, 3]), ), rmakers.assign( make_repeat_tied_notes, ), ) music = rhythm_maker(accumulator.get(5, 10)) voice.extend(music) music = baca.make_repeat_tied_notes( accumulator.get(11, 14), do_not_rewrite_meter=True ) voice.extend(music) rhythm_maker = rmakers.bind( rmakers.assign( make_vc_waves, abjad.index([1, 2, 3]), ), rmakers.assign( make_eighth_notes, abjad.index([4, 5]), ), rmakers.assign( make_repeat_tied_notes, ), ) music = rhythm_maker(accumulator.get(15, 20)) voice.extend(music) music = library.make_eighth_notes(accumulator.get(21, 25)) voice.extend(music) music = baca.make_mmrests(accumulator.get(26), head=voice.name) voice.extend(music)
def incise_chain(): """ Makes incise chain. """ return baca.rhythm( rhythm_maker=rmakers.IncisedRhythmMaker( division_masks=[abjad.index([2], 5)], incise_specifier=rmakers.InciseSpecifier( fill_with_rests=True, prefix_talea=[-2, 2, -2, 2, -2, 2, 0], prefix_counts=[2, 2, 2, 1], suffix_talea=[0, 2, -2, 0, 2, -2], suffix_counts=[1, 2, 1, 2], talea_denominator=16, ), tag="krummzeit.incise_chain", ) )
maker( ('pf', [(4, 9), 13, 16]), krummzeit.silver_points([(1, 2), (2, 1)]), ) maker( ('vn', (7, 19)), krummzeit.hypermeter_tuplets([(3, 4)], [2, 2, 2, 2, 2, 3]), ) maker( ('va', (7, 19)), krummzeit.hypermeter_tuplets( [(1, 6)], counts=[2, 2, 2, 2, 2, 3], dmask=abjad.index([0, 1]), ), ) maker( ('vc', (7, 19)), krummzeit.hypermeter_tuplets( [(6, 1)], counts=[2, 2, 2, 2, 2, 3], dmask=abjad.index([0, 1]), ), ) maker( ('ob', (4, 10)), krummzeit.polyphony(
def silence( indices, period=None, inverted=None, use_multimeasure_rests=None, ): r'''Makes silence mask that matches `indices`. .. container:: example Silences divisions 1 and 2: >>> mask = abjad.silence([1, 2]) >>> mask abjad.silence([1, 2]) >>> rhythm_maker = abjad.rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> selections = rhythm_maker(divisions) >>> lilypond_file = abjad.LilyPondFile.rhythm( ... selections, ... divisions, ... ) >>> abjad.show(lilypond_file) # doctest: +SKIP .. docs:: >>> abjad.f(lilypond_file[abjad.Staff]) \new RhythmicStaff { { % measure \time 7/16 c'4.. } % measure { % measure \time 3/8 r4. } % measure { % measure \time 7/16 r4.. } % measure { % measure \time 3/8 c'4. } % measure } .. container:: example Silences divisions -1 and -2: >>> mask = abjad.silence([-1, -2]) >>> mask abjad.silence([-1, -2]) >>> rhythm_maker = abjad.rhythmmakertools.NoteRhythmMaker( ... division_masks=[ ... mask, ... ], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> selections = rhythm_maker(divisions) >>> lilypond_file = abjad.LilyPondFile.rhythm( ... selections, ... divisions, ... ) >>> abjad.show(lilypond_file) # doctest: +SKIP .. docs:: >>> abjad.f(lilypond_file[abjad.Staff]) \new RhythmicStaff { { % measure \time 7/16 c'4.. } % measure { % measure \time 3/8 c'4. } % measure { % measure \time 7/16 r4.. } % measure { % measure \time 3/8 r4. } % measure } Returns silence mask. ''' import abjad pattern = abjad.index(indices, period=period, inverted=inverted) template = SilenceMask._get_template(inspect.currentframe()) return SilenceMask( pattern=pattern, template=template, use_multimeasure_rests=use_multimeasure_rests, )
) cellomusicmaker_two = MusicMaker( rmaker=rmaker_two, pitches=cello_notes_two, continuous=True, attachment_handler=attachment_handler_two, ) cellomusicmaker_three = MusicMaker( rmaker=rmaker_three, pitches=cello_notes_three, continuous=True, attachment_handler=attachment_handler_three, ) silence_maker = abjadext.rmakers.NoteRhythmMaker( division_masks=[abjadext.rmakers.SilenceMask(pattern=abjad.index([0], 1))]) # Define a small class so that we can annotate timespans with additional # information: class MusicSpecifier: def __init__(self, music_maker, voice_name): self.music_maker = music_maker self.voice_name = voice_name # Define an initial timespan structure, annotated with music specifiers. This # structure has not been split along meter boundaries. This structure does not # contain timespans explicitly representing silence. Here I make four, one # for each voice, using Python's list comprehension syntax to save some
baca.clef('bass'), baca.instrument(krummzeit.instruments['Piano']), krummzeit.incise_attacks(), krummzeit.margin_markup('Pf.'), ) maker( ('perc', (45, 60)), baca.markup('tam-tam', boxed=True), krummzeit.incise_attacks(), ) maker( ('va', (48, 56)), krummzeit.pizzicato_rhythm( dmask=abjad.index([1, 2, 3], 6), ), ) maker( ('vc', (52, 56)), krummzeit.pizzicato_rhythm( dmask=abjad.index([2, 3, 4], 6), ), ) maker( ('vn', (54, 56)), krummzeit.pizzicato_rhythm( dmask=abjad.index([3, 4, 5], 6), ),
krummzeit.opening_triplets(), ) maker( ('perc', (5, 6)), baca.chunk( baca.bar_extent_persistent( (-2, 2), tag=baca.const.NOT_PARTS, ), baca.staff_lines(5), ), baca.clef('treble'), baca.markup('crotale', boxed=True), baca.pitch('D5'), krummzeit.left_remainder_quarters(dmask=abjad.index([0])), ) maker( [ ('ob', (4, 7)), ('cl', (4, 5)), ], baca.make_repeat_tied_notes(), ) maker( ('cl', 4), baca.instrument(krummzeit.instruments['ClarinetInEFlat']), )
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()"), )
############################################################################### ##################################### [A] ##################################### ############################################################################### ### MUSIC-MAKERS ### music: typing.List[abjad.Tuplet] = [] music_makers = [] ### stage [1] (middle) ### music_maker = huitzil.DreamsMusicMaker() music_maker.pitch_class_trees = huitzil.pitch_classes[:6] music_maker.extra_counts_per_division = [1, 2, 0, -1, 5] music_maker.pc_displacement = [abjad.index(list(range(15)), 30)] music_maker.voice_map = [ [2, range(0, 99)], ] music_makers.append(music_maker) ### stage [2] (middle & lower) ### music_maker = huitzil.DreamsMusicMaker() music_maker.pitch_class_trees = huitzil.pitch_classes[2:8] music_maker.pc_operators = [abjad.Transposition(n=1)] music_maker.extra_counts_per_division = [1, 2, 0, -1, 5] music_maker.pc_displacement = [abjad.index(list(range(15)), 30)] music_maker.voice_map = [ [2, range(0, 99)], [3, (4, 14, 15, 28, 29, 35, 36)],
krummzeit.margin_markup('Va.'), baca.start_markup('Viola', hcenter_in=16), ), ) maker( 'vc', baca.suite( krummzeit.margin_markup('Vc.'), baca.start_markup('Cello', hcenter_in=16), ), ) maker( (['vn', 'va', 'vc'], (1, 2)), krummzeit.opening_triplets(dmask=abjad.index([0])), ) maker( ('vn', (4, 8)), krummzeit.glissando_rhythm( [(2, 1), (2, 1), (1, 1, 1)], dmask=abjad.index([5, 6], 7), ) ) maker( ('va', (4, 8)), krummzeit.glissando_rhythm( [(2, 1), (1, 1, 1), (2, 1)], dmask=abjad.index([0, 1], 7),
pcs_, selector=baca.plts(exclude=abjad.const.HIDDEN), ), ) maker( ('vn', (22, 28)), baca.dynamic('ff'), baca.new( baca.trill_spanner(), map=baca.plts().filter_preprolated('>=', (1, 4)), ), baca.suite( baca.new( baca.deviation([0, -0.5, 0, 0.5]), map=baca.ltqruns().filter_length('>', 1)[abjad.index([0], 2)], ), baca.new( baca.deviation([0, 0.5, 0, -0.5]), map=baca.ltqruns().filter_length('>', 1), ), krummzeit.displacement(), krummzeit.register_wide(5), ), ) maker( ('pf', [(14, 20), (28, 35)]), baca.pitch( 'C#6', selector=baca.plts(exclude=abjad.const.HIDDEN),
rmaker=rmaker_one, pitches=contrabass_notes, continuous=True, attachment_handler=attachment_handler_one, ) contrabass_musicmaker_two = MusicMaker( rmaker=rmaker_two, pitches=contrabass_notes, continuous=True, attachment_handler=attachment_handler_two, ) silence_maker = abjadext.rmakers.NoteRhythmMaker( division_masks=[ abjadext.rmakers.SilenceMask( pattern=abjad.index([0], 1), ), ], ) # Define a small class so that we can annotate timespans with additional # information: class MusicSpecifier: def __init__(self, music_maker, voice_name): self.music_maker = music_maker self.voice_name = voice_name # Define an initial timespan structure, annotated with music specifiers. This
('perc', 28), baca.chunk( baca.bar_extent_persistent( (0, 2), after=True, tag=baca.const.NOT_PARTS, ), baca.staff_lines(1), ), ) maker( ('vn', (12, 20)), krummzeit.glissando_rhythm( [(2, 1), (2, 1), (1, 1, 1)], dmask=abjad.index([5, 6], 7), ), ) maker( ('va', (12, 20)), krummzeit.glissando_rhythm( [(2, 1), (1, 1, 1), (2, 1)], dmask=abjad.index([0, 1], 7), ), ) maker( ('vc', (12, 20)), krummzeit.glissando_rhythm( [(1, 1, 1), (2, 1), (2, 1)],
class MusicSpecifier: def __init__(self, rhythm_maker, voice_name): self.rhythm_maker = rhythm_maker self.voice_name = voice_name # Define an initial timespan structure, annotated with music specifiers. This # structure has not been split along meter boundaries. This structure does not # contain timespans explicitly representing silence. Here I make four, one # for each voice, using Python's list comprehension syntax to save some # space. silence_maker = abjadext.rmakers.NoteRhythmMaker(division_masks=[ abjadext.rmakers.SilenceMask(pattern=abjad.index([0], 1), ), ], ) print('Collecting timespans and rmakers ...') voice_1_timespan_list = abjad.TimespanList([ abjad.AnnotatedTimespan( start_offset=start_offset, stop_offset=stop_offset, annotation=MusicSpecifier( rhythm_maker=rhythm_maker, voice_name='Voice 1', ), ) for start_offset, stop_offset, rhythm_maker in [ [(0, 4), (1, 4), rmaker_one], [(1, 4), (2, 4), rmaker_one],
('vc', (1, 13)), ], krummzeit.right_remainder_quarters(), ) maker( ('perc', (6, 16)), baca.markup('sponges', boxed=True), krummzeit.sponge_rhythm(), ) maker( ('va', (8, 10)), krummzeit.glissando_rhythm( [(2, 1), (2, 1), (1, 1, 1)], dmask=abjad.index([5, 6], 7), ), ) maker( ('va', (11, 24)), krummzeit.glissando_rhythm( [(2, 1), (2, 1), (1, 1, 1)], dmask=abjad.index([0]), ), ) maker( ('vn', (14, 16)), krummzeit.glissando_rhythm( [(2, 1), (2, 1), (1, 1, 1)],
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()"), )
rotation=-1, fuse=(1, 8), denominators=[8, 8, 4, 4, 8, 8], extra_counts=[3, 1, 0, 4], ties=[0, 1, 0, 1, 1, 0], ), ) maker( ('pf', (14, 20)), baca.instrument(krummzeit.instruments['Piano']), baca.clef('bass'), krummzeit.margin_markup('Pf.'), krummzeit.piano_harmonics( [(2, 1), (2, 1), (1, 1, 1)], dmask=abjad.index([5, 6], 7), tie_across_divisions=[0, 1], ), ) maker( ('perc', (1, 7)), baca.make_repeated_duration_notes( [(1, 2)], dmask=abjad.index([-1]), do_not_rewrite_meter=True, ), baca.markup('tam-tam', boxed=True), baca.staff_position(0), )