select_first

patterntools.select_first(n=1, inverted=None)

Makes pattern that matches the first n indices.

Example 1. Selects first division for tie creation:

>>> pattern = patterntools.select_first()
>>> print(format(pattern))
patterntools.Pattern(
    indices=(0,),
    )
>>> 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) 

Example 2. Selects first two divisions for tie creation:

>>> pattern = patterntools.select_first(n=2)
>>> print(format(pattern))
patterntools.Pattern(
    indices=(0, 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) 

Example 3. Selects no divisions for tie creation:

>>> pattern = patterntools.select_first(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) 

Returns pattern.