silence_except

rhythmmakertools.silence_except(indices=None)

Makes silence mask that matches all indices except indices.

Silences divisions except 1 and 2:

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

Silences divisions except -1 and -2:

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

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)
>>> 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) 

Equivalent to silence(..., inverted=True).

Returns silence mask.