sustain_last

rhythmmakertools.sustain_last(n=1, inverted=None)

Makes sustain mask that matches the last n indices.

Sustains last division:

>>> mask = rhythmmakertools.sustain_last()
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=patterntools.Pattern(
        indices=[-1],
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[
...         rhythmmakertools.silence_all(),
...         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) 

Sustains last two divisions:

>>> mask = rhythmmakertools.sustain_last(n=2)
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=patterntools.Pattern(
        indices=[-2, -1],
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[
...         rhythmmakertools.silence_all(),
...         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) 

Sustains no last divisions:

>>> mask = rhythmmakertools.sustain_last(n=0)
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=patterntools.Pattern(
        indices=[],
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[
...         rhythmmakertools.silence_all(),
...         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 sustain mask.