select_every

patterntools.select_every(indices, period=None, inverted=None)

Makes pattern that matches indices at period.

Example 1. Selects every second division:

>>> mask = patterntools.select_every(indices=[1], period=2)
>>> print(format(mask))
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) 

Example 2. Selects every second and third division:

>>> mask = patterntools.select_every(indices=[1, 2], period=3)
>>> print(format(mask))
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) 

Returns pattern.