sustain_last

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

Makes sustain mask that matches the last n indices.

Example 1. Sustains last division:

>>> mask = rhythmmakertools.sustain_last()
>>> print(format(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) 

Example 2. Sustains last two divisions:

>>> mask = rhythmmakertools.sustain_last(n=2)
>>> print(format(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) 

Example 3. Sustains no last divisions:

>>> mask = rhythmmakertools.sustain_last(n=0)
>>> print(format(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.