silence

rhythmmakertools.silence(indices=None, inverted=None)

Makes silence mask that matches indices.

Silences divisions 1 and 2:

>>> mask = rhythmmakertools.silence([1, 2])
>>> f(mask)
rhythmmakertools.SilenceMask(
    pattern=patterntools.Pattern(
        indices=[1, 2],
        ),
    )
>>> 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) 

Silences divisions -1 and -2:

>>> mask = rhythmmakertools.silence([-1, -2])
>>> f(mask)
rhythmmakertools.SilenceMask(
    pattern=patterntools.Pattern(
        indices=[-1, -2],
        ),
    )
>>> 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) 

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(pattern)
>>> f(mask)
rhythmmakertools.SilenceMask(
    pattern=patterntools.CompoundPattern(
        (
            patterntools.Pattern(
                indices=[0],
                period=1,
                ),
            patterntools.Pattern(
                indices=[0],
                ),
            patterntools.Pattern(
                indices=[-1],
                ),
            ),
        operator='xor',
        ),
    )
>>> 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) 

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.silence(pattern, inverted=True)
>>> f(mask)
rhythmmakertools.SilenceMask(
    pattern=patterntools.CompoundPattern(
        (
            patterntools.Pattern(
                indices=[0],
                period=1,
                ),
            patterntools.Pattern(
                indices=[0],
                ),
            patterntools.Pattern(
                indices=[-1],
                ),
            ),
        inverted=True,
        operator='xor',
        ),
    )
>>> 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) 

Returns silence mask.