select_last

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

Makes pattern that matches the last n indices.

Selects last two divisions for tie creation:

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

(Tie creation happens between adjacent divisions. Selecting only the last division creates no ties.)

Selects no divisions for tie creation:

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