def select(indices=None, inverted=None): r'''Makes pattern that matches `indices`. .. container:: example **Example 1.** Selects index 2: :: >>> pattern = patterntools.select([2]) :: >>> print(format(pattern)) patterntools.Pattern( indices=(2,), ) .. container:: example **Example 2.** Selects indices 2, 3 and 5: :: >>> pattern = patterntools.select([2, 3, 5]) :: >>> print(format(pattern)) patterntools.Pattern( indices=(2, 3, 5), ) Returns pattern. ''' from abjad.tools import patterntools indices = indices or [] return patterntools.Pattern( indices=indices, inverted=inverted, )
def sustain(indices=None, inverted=None): r'''Makes sustain mask that matches `indices`. .. container:: example **Example 1.** Sustains divisions 1 and 2: :: >>> mask = rhythmmakertools.sustain([1, 2]) :: >>> print(format(mask)) rhythmmakertools.SustainMask( pattern=patterntools.Pattern( indices=(1, 2), ), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[ ... rhythmmakertools.silence_all(), ... mask, ... ], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> print(format(staff)) \new RhythmicStaff { { \time 7/16 r4.. } { \time 3/8 c'4. } { \time 7/16 c'4.. } { \time 3/8 r4. } } .. container:: example **Example 2.** Sustains divisions -1 and -2: :: >>> mask = rhythmmakertools.sustain([-1, -2]) :: >>> print(format(mask)) rhythmmakertools.SustainMask( pattern=patterntools.Pattern( indices=(-1, -2), ), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[ ... rhythmmakertools.silence_all(), ... mask, ... ], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> print(format(staff)) \new RhythmicStaff { { \time 7/16 r4.. } { \time 3/8 r4. } { \time 7/16 c'4.. } { \time 3/8 c'4. } } .. container:: example **Example 3.** Works with pattern input: :: >>> pattern_1 = patterntools.select_all() >>> pattern_2 = patterntools.select_first() >>> pattern_3 = patterntools.select_last() >>> pattern = pattern_1 ^ pattern_2 ^ pattern_3 >>> mask = rhythmmakertools.sustain(pattern) :: >>> print(format(mask)) rhythmmakertools.SustainMask( pattern=patterntools.CompoundPattern( ( patterntools.Pattern( indices=(0,), period=1, ), patterntools.Pattern( indices=(0,), ), patterntools.Pattern( indices=(-1,), ), ), operator='xor', ), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[ ... rhythmmakertools.silence_all(), ... mask, ... ], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> print(format(staff)) \new RhythmicStaff { { \time 7/16 r4.. } { \time 3/8 c'4. } { \time 7/16 c'4.. } { \time 3/8 r4. } } .. container:: example **Example 4.** Works with pattern input and inverted flag: :: >>> pattern_1 = patterntools.select_all() >>> pattern_2 = patterntools.select_first() >>> pattern_3 = patterntools.select_last() >>> pattern = pattern_1 ^ pattern_2 ^ pattern_3 >>> mask = rhythmmakertools.sustain(pattern, inverted=True) :: >>> print(format(mask)) rhythmmakertools.SustainMask( pattern=patterntools.CompoundPattern( ( patterntools.Pattern( indices=(0,), period=1, ), patterntools.Pattern( indices=(0,), ), patterntools.Pattern( indices=(-1,), ), ), inverted=True, operator='xor', ), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[ ... rhythmmakertools.silence_all(), ... mask, ... ], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> print(format(staff)) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 r4. } { \time 7/16 r4.. } { \time 3/8 c'4. } } Returns sustain mask. ''' from abjad.tools import rhythmmakertools indices = indices or [] prototype = (patterntools.Pattern, patterntools.CompoundPattern) if isinstance(indices, prototype): pattern = indices else: pattern = patterntools.Pattern( indices=indices, inverted=inverted, ) pattern = new(pattern, inverted=inverted) return rhythmmakertools.SustainMask(pattern=pattern)
def select_all(inverted=None): r'''Makes pattern that matches all indices. .. container:: example **Example 1.** Selects all divisions for tie creation: :: >>> pattern = patterntools.select_all() :: >>> print(format(pattern)) patterntools.Pattern( indices=(0,), period=1, ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... tie_specifier=rhythmmakertools.TieSpecifier( ... tie_across_divisions=pattern, ... use_messiaen_style_ties=True, ... ), ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 c'4. \repeatTie } { \time 7/16 c'4.. \repeatTie } { \time 3/8 c'4. \repeatTie } } Returns pattern. ''' from abjad.tools import patterntools return patterntools.Pattern( indices=[0], inverted=inverted, period=1, )
def sustain_first(n=1, inverted=None): r'''Makes sustain mask that matches the first `n` indices. .. container:: example **Example 1.** Sustains first division: :: >>> mask = rhythmmakertools.sustain_first() :: >>> print(format(mask)) rhythmmakertools.SustainMask( pattern=patterntools.Pattern( indices=(0,), ), ) :: >>> rhythm_maker = rhythmmakertools.EvenDivisionRhythmMaker( ... denominators=[16], ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> selections = rhythm_maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... selections, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = rhythm_maker._get_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 { c'16 [ c'16 c'16 c'16 c'16 c'16 ] } } { \time 7/16 { c'16 [ c'16 c'16 c'16 c'16 c'16 c'16 ] } } { \time 3/8 { c'16 [ c'16 c'16 c'16 c'16 c'16 ] } } } .. container:: example **Example 2.** Sustains first two divisions: :: >>> mask = rhythmmakertools.sustain_first(n=2) :: >>> print(format(mask)) rhythmmakertools.SustainMask( pattern=patterntools.Pattern( indices=(0, 1), ), ) :: >>> rhythm_maker = rhythmmakertools.EvenDivisionRhythmMaker( ... denominators=[16], ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> selections = rhythm_maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... selections, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = rhythm_maker._get_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 c'4. } { \time 7/16 { c'16 [ c'16 c'16 c'16 c'16 c'16 c'16 ] } } { \time 3/8 { c'16 [ c'16 c'16 c'16 c'16 c'16 ] } } } Returns sustain mask. ''' from abjad.tools import rhythmmakertools indices = list(range(n)) pattern = patterntools.Pattern( indices=indices, inverted=inverted, ) mask = rhythmmakertools.SustainMask(pattern=pattern) return mask
1, 1, 1, 1, 1, 1, 1, -2, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -2, ], denominator=16, ), division_masks=[ rhythmmakertools.SustainMask(pattern=patterntools.Pattern( indices=[1], period=2, ), ), ], ))
def __call__(self, expr): r'''Calls rotation on `expr`. .. container:: example **Example 1.** Duplicates once without period. :: >>> operator_ = sequencetools.Duplication(counts=1) >>> numbers = [1, 2, 3, 4] >>> operator_(numbers) [1, 2, 3, 4, 1, 2, 3, 4] .. container:: example **Example 2.** Duplicates twice without period. :: >>> operator_ = sequencetools.Duplication(counts=2) >>> pitch_classes = pitchtools.PitchClassSegment([0, 1, 4, 7]) >>> operator_(pitch_classes) PitchClassSegment([0, 1, 4, 7, 0, 1, 4, 7, 0, 1, 4, 7]) .. container:: example **Example 3.** Duplicates periodically. :: >>> operator_ = sequencetools.Duplication(counts=1, period=3) >>> pitches = pitchtools.PitchSegment("c' d' e' f' g' a' b' c''") >>> for pitch in operator_(pitches): ... pitch ... NamedPitch("c'") NamedPitch("d'") NamedPitch("e'") NamedPitch("c'") NamedPitch("d'") NamedPitch("e'") NamedPitch("f'") NamedPitch("g'") NamedPitch("a'") NamedPitch("f'") NamedPitch("g'") NamedPitch("a'") NamedPitch("b'") NamedPitch("c''") NamedPitch("b'") NamedPitch("c''") .. container:: example **Example 4.** Duplicate indices. :: >>> operator_ = sequencetools.Duplication( ... counts=1, ... indices=(0, -1), ... ) >>> pitch_classes = pitchtools.PitchClassSegment([0, 1, 4, 7]) >>> operator_(pitch_classes) PitchClassSegment([0, 0, 1, 4, 7, 7]) .. container:: example **Example 5.** Duplicate indices periodically. :: >>> operator_ = sequencetools.Duplication( ... counts=1, ... indices=(0,), ... period=2, ... ) >>> pitch_classes = pitchtools.PitchClassSegment([0, 1, 4, 7, 9]) >>> operator_(pitch_classes) PitchClassSegment([0, 0, 1, 4, 4, 7, 9, 9]) .. container:: example **Example 6.** Duplicate indices periodically with different counts. :: >>> operator_ = sequencetools.Duplication( ... counts=(1, 2), ... indices=(0,), ... period=2, ... ) >>> pitch_classes = pitchtools.PitchClassSegment([0, 1, 4, 7, 9]) >>> operator_(pitch_classes) PitchClassSegment([0, 0, 1, 4, 4, 4, 7, 9, 9]) .. container:: example **Example 7.** Cyclic counts. :: >>> operator_ = sequencetools.Duplication(counts=(0, 1, 2, 3)) >>> pitch_classes = pitchtools.PitchClassSegment([0, 1, 4, 7, 9]) >>> operator_(pitch_classes) PitchClassSegment([0, 1, 1, 4, 4, 4, 7, 7, 7, 7, 9]) Returns new object with type equal to that of `expr`. ''' from abjad.tools import datastructuretools from abjad.tools import patterntools from abjad.tools import sequencetools if not isinstance(expr, collections.Sequence): expr = (expr, ) counts = self.counts if isinstance(counts, int): counts = counts + 1 else: counts = [_ + 1 for _ in counts] if not self.period and not self.indices: if isinstance(counts, int): return type(expr)(expr * counts) else: counts = datastructuretools.CyclicTuple(counts) result = [] for i, x in enumerate(expr): count = counts[i] result.extend([x] * count) if isinstance(expr, datastructuretools.TypedCollection): result = new(expr, items=result) else: result = type(expr)(result) return result if isinstance(counts, int): counts = [counts] counts = datastructuretools.CyclicTuple(counts) if not self.indices: if isinstance(expr, datastructuretools.TypedCollection): result = new(expr, items=()) else: result = type(expr)() iterator = sequencetools.partition_sequence_by_counts( expr, [self.period], cyclic=True, overhang=True) for i, shard in enumerate(iterator): shard = type(expr)(shard) * counts[i] result = result + shard return result pattern = patterntools.Pattern( indices=self.indices, period=self.period, ) result = [] length = len(expr) j = 0 for i, x in enumerate(expr): if pattern.matches_index(i, length): count = counts[j] result.extend([x] * count) j += 1 else: result.append(x) if isinstance(expr, datastructuretools.TypedCollection): result = new(expr, items=result) else: result = type(expr)(result) return result
), pitches_are_nonsemantic=True, ), rhythm_maker=rhythmmakertools.TaleaRhythmMaker( extra_counts_per_division=[0, 1, 2], talea=rhythmmakertools.Talea( counts=[ 1, 1, -1, 1, 1, -1, 1, 1, -2, 1, 1, 1, 1, 1, 1, -1, 1, 1, -2, 1, 1, 1, -2, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -2, ], denominator=16, ), division_masks=[ rhythmmakertools.SustainMask( pattern=patterntools.Pattern( indices=[1], period=2, ), ), ], ) )
), trill_spanner=consort.AttachmentExpression( attachments=spannertools.ComplexTrillSpanner('M2'), selector=selectortools.select_pitched_runs(), ), ), color='red', labels=[], pitch_handler=consort.PitchClassPitchHandler( deviations=[0, 1], pitch_application_rate='phrase', pitch_specifier=abbreviations.agitato_pitch_specifier, pitch_operation_specifier=abbreviations.pitch_operation_specifier, register_specifier=consort.RegisterSpecifier(base_pitch='C4', ), ), rhythm_maker=rhythmmakertools.EvenDivisionRhythmMaker( denominators=[8], extra_counts_per_division=[0, 1, 2], division_masks=[ rhythmmakertools.SustainMask(pattern=patterntools.Pattern( indices=[2], period=3, ), ), rhythmmakertools.SustainMask(pattern=patterntools.Pattern( indices=[0, -1], ), ), ], tie_specifier=rhythmmakertools.TieSpecifier( tie_across_divisions=True, ), ), )
dynamic_tokens='mf mp fff', start_dynamic_tokens='f', stop_dynamic_tokens='p mp mf', ), flutter_tongue=consort.AttachmentExpression( attachments=abbreviations.make_text_spanner('Flz.'), selector=selectortools.Selector().by_logical_tie( pitched=True).by_duration( '>', (1, 16), preprolated=True).by_contiguity().by_leaf()), slur=consort.AttachmentExpression( attachments=spannertools.Slur(), selector=selectortools.Selector().by_logical_tie( pitched=True).by_duration( '==', (1, 16), preprolated=True).by_contiguity().by_length( '>', 1).by_pattern(pattern=patterntools.Pattern( indices=[0], period=2, ), ).by_leaf()), staccati=consort.AttachmentExpression( attachments=indicatortools.Articulation('staccato'), selector=selectortools.Selector().by_logical_tie( pitched=True).by_duration( '==', (1, 16), preprolated=True).by_contiguity().by_length( '>', 1).by_pattern(pattern=patterntools.Pattern( indices=[0, 2], period=3, ), ).by_leaf()), stem_tremolo_spanner=consort.AttachmentExpression( attachments=spannertools.StemTremoloSpanner(), selector=selectortools.Selector().by_logical_tie( pitched=True).by_duration( '>', (1, 16), preprolated=True).by_contiguity().by_leaf()),
def silence_all(inverted=None, use_multimeasure_rests=None): r'''Makes silence that matches all indices. .. container:: example **Example 1.** Silences all divisions: :: >>> mask = rhythmmakertools.silence_all() :: >>> print(format(mask)) rhythmmakertools.SilenceMask( pattern=patterntools.Pattern( indices=(0,), period=1, ), ) :: >>> rhythm_maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> selections = rhythm_maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... selections, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = rhythm_maker._get_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 r4.. } { \time 3/8 r4. } { \time 7/16 r4.. } { \time 3/8 r4. } } .. container:: example **Example 2.** Silences all divisions with multimeasure rests: :: >>> mask = rhythmmakertools.silence_all( ... use_multimeasure_rests=True, ... ) >>> rhythm_maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) :: >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> selections = rhythm_maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... selections, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = rhythm_maker._get_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 R1 * 7/16 } { \time 3/8 R1 * 3/8 } { \time 7/16 R1 * 7/16 } { \time 3/8 R1 * 3/8 } } Returns silence mask. ''' from abjad.tools import rhythmmakertools pattern = patterntools.Pattern( indices=[0], inverted=inverted, period=1, ) mask = rhythmmakertools.SilenceMask( pattern=pattern, use_multimeasure_rests=use_multimeasure_rests, ) return mask
viola=ersilia.string_legato_music_specifier .transpose('C3'), cello=ersilia.string_legato_music_specifier .transpose('C2'), bass=ersilia.string_legato_music_specifier .transpose('E1'), ) ### AUXILIARY ### music_specifier = new( ersilia.pitch_pipe_music_specifier, rhythm_maker__division_masks=[ rhythmmakertools.SustainMask( pattern=patterntools.Pattern( indices=[0, -1], ), ), ], attachment_handler__dynamic_expressions=consort.DynamicExpression( start_dynamic_tokens='fp', stop_dynamic_tokens='niente', ), ) segment_maker.add_setting( timespan_identifier=timespantools.Timespan(0, (3, 2)), timespan_maker=new( ersilia.tutti_timespan_maker, fuse_groups=True, timespan_specifier=consort.TimespanSpecifier( minimum_duration=0,
from abjad.tools import selectortools from abjad.tools import spannertools string_legato_music_specifier = consort.MusicSpecifier( attachment_handler=consort.AttachmentHandler( dynamic_expressions=consort.DynamicExpression( dynamic_tokens='p mf', start_dynamic_tokens='niente fp', stop_dynamic_tokens='niente ff'), glissando=consort.Glissando(), tenuti=consort.AttachmentExpression( attachments=indicatortools.Articulation('tenuto'), selector=selectortools.Selector().by_leaf().by_logical_tie( pitched=True).by_pattern( patterntools.Pattern( indices=[3], period=4, ), )[0]), tremolo_trill=consort.AttachmentExpression( attachments=( spannertools.ComplexTrillSpanner(interval='+m3'), spannertools.StemTremoloSpanner(), spannertools.ComplexTrillSpanner(interval='+m3'), spannertools.ComplexTrillSpanner(interval='+M2'), spannertools.StemTremoloSpanner(), ), selector=selectortools.Selector().by_leaf().by_logical_tie( pitched=True).by_pattern( patterntools.Pattern( indices=[0, 1, 2], period=4, ), ),
def coerce_(expr): if isinstance(expr, prototype): pass elif not isinstance(expr, patterntools.Pattern): expr = patterntools.Pattern(*expr) return expr
def silence_every( indices, period=None, inverted=None, use_multimeasure_rests=None, ): r'''Makes silence mask that matches `indices` at `period`. .. container:: example **Example 1.** Silences every second division: :: >>> mask = rhythmmakertools.silence_every(indices=[1], period=2) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( pattern=patterntools.Pattern( indices=(1,), period=2, ), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 r4. } { \time 7/16 c'4.. } { \time 3/8 r4. } } .. container:: example **Example 2.** Silences every second and third division: :: >>> mask = rhythmmakertools.silence_every(indices=[1, 2], period=3) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( pattern=patterntools.Pattern( indices=(1, 2), period=3, ), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 r4. } { \time 7/16 r4.. } { \time 3/8 c'4. } } .. container:: example **Example 3.** Silences every division except the last: :: >>> mask = rhythmmakertools.silence_every(indices=[-1], inverted=True) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( pattern=patterntools.Pattern( indices=(-1,), inverted=True, ), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 r4.. } { \time 3/8 r4. } { \time 7/16 r4.. } { \time 3/8 c'4. } } Returns silence mask. ''' from abjad.tools import rhythmmakertools pattern = patterntools.Pattern( indices=indices, inverted=inverted, period=period, ) mask = rhythmmakertools.SilenceMask( pattern=pattern, use_multimeasure_rests=use_multimeasure_rests, ) return mask
def sustain_every(indices, period, inverted=None): r'''Makes sustain mask that matches `indices` at `period`. .. container:: example **Example 1.** Sustains every second division: :: >>> mask = rhythmmakertools.sustain_every(indices=[1], period=2) :: >>> print(format(mask)) rhythmmakertools.SustainMask( pattern=patterntools.Pattern( indices=(1,), period=2, ), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> print(format(staff)) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 c'4. } { \time 7/16 c'4.. } { \time 3/8 c'4. } } .. container:: example **Example 2.** Sustains every second and third division: :: >>> mask = rhythmmakertools.sustain_every(indices=[1, 2], period=3) :: >>> print(format(mask)) rhythmmakertools.SustainMask( pattern=patterntools.Pattern( indices=(1, 2), period=3, ), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> print(format(staff)) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 c'4. } { \time 7/16 c'4.. } { \time 3/8 c'4. } } Returns sustain mask. ''' from abjad.tools import rhythmmakertools indices = list(indices) pattern = patterntools.Pattern( indices=indices, inverted=inverted, period=period, ) mask = rhythmmakertools.SustainMask(pattern=pattern) return mask
def silence_last(n=1, inverted=None, use_multimeasure_rests=None): r'''Makes silence mask that matches the last `n` indices. .. container:: example **Example 1.** Silences last division: :: >>> mask = rhythmmakertools.silence_last() :: >>> print(format(mask)) rhythmmakertools.SilenceMask( pattern=patterntools.Pattern( indices=(-1,), ), ) :: >>> rhythm_maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> selections = rhythm_maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... selections, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = rhythm_maker._get_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 c'4. } { \time 7/16 c'4.. } { \time 3/8 r4. } } .. container:: example **Example 2.** Silences last two divisions: :: >>> mask = rhythmmakertools.silence_last(n=2) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( pattern=patterntools.Pattern( indices=(-2, -1), ), ) :: >>> rhythm_maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> selections = rhythm_maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... selections, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = rhythm_maker._get_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 c'4. } { \time 7/16 r4.. } { \time 3/8 r4. } } .. container:: example **Example 3.** Silences no last divisions: :: >>> mask = rhythmmakertools.silence_last(n=0) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( pattern=patterntools.Pattern( indices=(), ), ) :: >>> rhythm_maker = rhythmmakertools.NoteRhythmMaker( ... division_masks=[mask], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> selections = rhythm_maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... selections, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = rhythm_maker._get_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 c'4. } { \time 7/16 c'4.. } { \time 3/8 c'4. } } Returns silence mask. ''' from abjad.tools import rhythmmakertools indices = list(reversed(range(-1, -n - 1, -1))) pattern = patterntools.Pattern( indices=indices, inverted=inverted, ) mask = rhythmmakertools.SilenceMask( pattern=pattern, use_multimeasure_rests=use_multimeasure_rests, ) return mask
string_agitato_music_specifier = consort.MusicSpecifier( attachment_handler=consort.AttachmentHandler( dynamic_expressions=consort.DynamicExpression( division_period=2, dynamic_tokens='mp fff', start_dynamic_tokens='f p', stop_dynamic_tokens='p f', ), harmonics=consort.AttachmentExpression( attachments=consort.HarmonicExpression('P4'), is_destructive=True, selector=selectortools.Selector().by_logical_tie( pitched=True).by_duration('==', (1, 16), preprolated=True).by_pattern( pattern=patterntools.Pattern( indices=[2, 4], period=5, ), )), slur=consort.AttachmentExpression( attachments=spannertools.Slur(), selector=selectortools.Selector().by_logical_tie( pitched=True).by_duration( '==', (1, 16), preprolated=True).by_contiguity().by_length('>', 1).by_leaf()), staccati=consort.AttachmentExpression( attachments=indicatortools.Articulation('staccato'), selector=selectortools.Selector().by_logical_tie( pitched=True).by_duration( '==', (1, 16), preprolated=True).by_contiguity().by_leaf()), accents=consort.AttachmentExpression(
-1, 2, -1, 1, ], timespan_maker=ersilia.tutti_timespan_maker, piano_lh=ersilia.piano_arm_cluster_music_specifier.transpose(-12), percussion=ersilia.percussion_snare_interruption_music_specifier, ) segment_maker.add_setting( timespan_maker=consort.BoundaryTimespanMaker( labels='piano arm cluster', division_masks=[ rhythmmakertools.SilenceMask(pattern=patterntools.Pattern( indices=[0, 1, 3], period=5, ), ), ], start_talea=(3, 8), ), guitar=new( ersilia.guitar_strummed_music_specifier, attachment_handler__dynamic_expressions=consort.DynamicExpression( dynamic_tokens='f', only_first=True, ), rhythm_maker__incise_specifier__prefix_counts=[3, 2], rhythm_maker__incise_specifier__prefix_talea=[1], ), )
def sustain_all(inverted=None): r'''Makes sustain mask that matches all indices. .. container:: example **Example 1.** Without mask: >>> maker = rhythmmakertools.TupletRhythmMaker( ... tuplet_ratios=[(3, 1)], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] :: >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 \tweak #'text #tuplet-number::calc-fraction-text \times 7/8 { c'4. c'8 } } { \time 3/8 \tweak #'text #tuplet-number::calc-fraction-text \times 3/4 { c'4. c'8 } } { \time 7/16 \tweak #'text #tuplet-number::calc-fraction-text \times 7/8 { c'4. c'8 } } { \time 3/8 \tweak #'text #tuplet-number::calc-fraction-text \times 3/4 { c'4. c'8 } } } .. container:: example **Example 2.** With mask: :: >>> mask = rhythmmakertools.sustain_all() :: >>> print(format(mask)) rhythmmakertools.SustainMask( pattern=patterntools.Pattern( indices=(0,), period=1, ), ) :: >>> maker = rhythmmakertools.TupletRhythmMaker( ... division_masks=[mask], ... tuplet_ratios=[(3, 1)], ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] :: >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 c'4. } { \time 7/16 c'4.. } { \time 3/8 c'4. } } Returns sustain mask. ''' from abjad.tools import rhythmmakertools pattern = patterntools.Pattern( indices=[0], inverted=inverted, period=1, ) mask = rhythmmakertools.SustainMask(pattern=pattern) return mask
base_pitch='G3', phrase_inflections=consort.RegisterInflection.zigzag(6) .reverse().align(), segment_inflections=consort.RegisterInflection.descending( width=12).align() ), register_spread=6, ), rhythm_maker=rhythmmakertools.TaleaRhythmMaker( burnish_specifier=rhythmmakertools.BurnishSpecifier( left_classes=[scoretools.Rest], left_counts=[1, 1, 0], right_classes=[scoretools.Rest], right_counts=[1], ), extra_counts_per_division=[0, 0, 1], division_masks=[ rhythmmakertools.SustainMask( pattern=patterntools.Pattern( indices=[0], period=3, ), ), ], talea=rhythmmakertools.Talea( counts=[1, 1, 1, 1, 2], denominator=16, ), ), )
def select_last(n=1, inverted=None): r'''Makes pattern that matches the last `n` indices. .. container:: example **Example 1.** Selects last two divisions for tie creation: :: >>> pattern = patterntools.select_last(n=2) :: >>> print(format(pattern)) patterntools.Pattern( indices=(-2, -1), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... tie_specifier=rhythmmakertools.TieSpecifier( ... tie_across_divisions=pattern, ... use_messiaen_style_ties=True, ... ), ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 c'4. } { \time 7/16 c'4.. } { \time 3/8 c'4. \repeatTie } } (Tie creation happens between adjacent divisions. Selecting only the last division creates no ties.) .. container:: example **Example 2.** Selects no divisions for tie creation: :: >>> pattern = patterntools.select_last(n=0) :: >>> print(format(pattern)) patterntools.Pattern( indices=(), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... tie_specifier=rhythmmakertools.TieSpecifier( ... tie_across_divisions=pattern, ... use_messiaen_style_ties=True, ... ), ... ) >>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)] >>> music = maker(divisions) >>> lilypond_file = rhythmmakertools.make_lilypond_file( ... music, ... divisions, ... ) >>> show(lilypond_file) # doctest: +SKIP .. doctest:: >>> staff = maker._get_rhythmic_staff(lilypond_file) >>> f(staff) \new RhythmicStaff { { \time 7/16 c'4.. } { \time 3/8 c'4. } { \time 7/16 c'4.. } { \time 3/8 c'4. } } Returns pattern. ''' from abjad.tools import patterntools indices = list(reversed(range(-1, -n - 1, -1))) return patterntools.Pattern( indices=indices, inverted=inverted, )