def silence_none(): r'''Makes silence mask equal to all ones. .. container:: example **Example 1.** Makes mask: :: >>> mask = rhythmmakertools.silence_none() :: >>> print(format(mask)) rhythmmakertools.SilenceMask( indices=(), period=1, ) .. container:: example **Example 2.** Makes note rhythm-maker. Effectively applies no mask: :: >>> mask = rhythmmakertools.silence_none() >>> maker = rhythmmakertools.NoteRhythmMaker( ... output_masks=[mask], ... ) :: >>> print(format(maker)) rhythmmakertools.NoteRhythmMaker( output_masks=rhythmmakertools.BooleanPatternInventory( ( rhythmmakertools.SilenceMask( indices=(), period=1, ), ) ), ) Returns boolean pattern. ''' from abjad.tools import rhythmmakertools return rhythmmakertools.SilenceMask( indices=[], period=1, )
def silence_all(use_multimeasure_rests=None): r'''Makes silence mask equal to all zeros. .. container:: example **Example 1.** Silences all divisions: :: >>> mask = rhythmmakertools.silence_all() :: >>> print(format(mask)) rhythmmakertools.SilenceMask( indices=(0,), period=1, ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... output_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 r4. } } .. container:: example **Example 2.** Silences all divisions with multimeasure rests: :: >>> mask = rhythmmakertools.silence_all( ... use_multimeasure_rests=True, ... ) >>> maker = rhythmmakertools.NoteRhythmMaker( ... output_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 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 return rhythmmakertools.SilenceMask( indices=[0], period=1, use_multimeasure_rests=use_multimeasure_rests, )
-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 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
def silence_except(indices=None): r'''Makes silence mask that matches all indices except `indices`. .. container:: example **Example 1.** Silences divisions except 1 and 2: :: >>> mask = rhythmmakertools.silence_except([1, 2]) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( pattern=patterntools.Pattern( indices=(1, 2), 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) >>> 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.** Silences divisions except -1 and -2: :: >>> mask = rhythmmakertools.silence_except([-1, -2]) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( pattern=patterntools.Pattern( indices=(-1, -2), 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) >>> 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.silence_except(pattern) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( 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=[ ... 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. } } Equivalent to ``silence(..., inverted=True)``. Returns silence 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, ) pattern = new(pattern, inverted=True) return rhythmmakertools.SilenceMask(pattern=pattern)
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
def silence_first(n=1, use_multimeasure_rests=None): r'''Makes silence mask with first `n` indices equal to zero. .. container:: example **Example 1.** Silences first division: :: >>> mask = rhythmmakertools.silence_first() :: >>> print(format(mask)) rhythmmakertools.SilenceMask( indices=(0,), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... output_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 c'4. } { \time 7/16 c'4.. } { \time 3/8 c'4. } } .. container:: example **Example 2.** Silences first two divisions: :: >>> mask = rhythmmakertools.silence_first(n=2) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( indices=(0, 1), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... output_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 c'4.. } { \time 3/8 c'4. } } .. container:: example **Example 3.** Silences no first divisions: :: >>> mask = rhythmmakertools.silence_first(n=0) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( indices=(), ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... output_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 c'4. } { \time 7/16 c'4.. } { \time 3/8 c'4. } } Returns silence mask. ''' from abjad.tools import rhythmmakertools assert 0 <= n, repr(n) indices = list(range(n)) return rhythmmakertools.SilenceMask( indices=indices, use_multimeasure_rests=use_multimeasure_rests, )
def silence_every(indices, period, use_multimeasure_rests=None): r'''Makes silence mask with `indices` set equal to zero at `period`. .. container:: example **Example 1.** Silences every second division: :: >>> mask = rhythmmakertools.silence_every(indices=[1], period=2) :: >>> print(format(mask)) rhythmmakertools.SilenceMask( indices=(1,), period=2, ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... output_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( indices=(1, 2), period=3, ) :: >>> maker = rhythmmakertools.NoteRhythmMaker( ... output_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. } } Returns silence mask. ''' from abjad.tools import rhythmmakertools indices = list(indices) assert isinstance(period, int) assert 0 < period return rhythmmakertools.SilenceMask( indices=indices, period=period, use_multimeasure_rests=use_multimeasure_rests, )
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