SustainMask

class rhythmmakertools.SustainMask(pattern=None)

Sustain mask.

>>> import abjad
>>> from abjad.tools import rhythmmakertools
>>> mask = rhythmmakertools.SustainMask(
...     pattern=abjad.index_every([0, 1, 7], period=16),
...     )
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        indices=[0, 1, 7],
        period=16,
        ),
    )

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" [color=1, group=0, label=AbjadValueObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.AbjadValueObject.AbjadValueObject"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_rhythmmakertools { graph [label=rhythmmakertools]; "abjad.tools.rhythmmakertools.SustainMask.SustainMask" [color=black, fontcolor=white, group=2, label=<<B>SustainMask</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.rhythmmakertools.SustainMask.SustainMask"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

pattern Gets pattern.
sustain([indices, inverted]) Makes sustain mask that matches indices.
sustain_all([inverted]) Makes sustain mask that matches all indices.
sustain_every(indices, period[, inverted]) Makes sustain mask that matches indices at period.
sustain_first([n, inverted]) Makes sustain mask that matches the first n indices.
sustain_last([n, inverted]) Makes sustain mask that matches the last n indices.
__copy__(*arguments) Copies Abjad value object.
__eq__(argument) Is true when all initialization values of Abjad value object equal the initialization values of argument.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes Abjad value object.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

SustainMask.pattern

Gets pattern.

Returns pattern.

Class & static methods

static SustainMask.sustain(indices=None, inverted=None)

Makes sustain mask that matches indices.

Sustains divisions 1 and 2:

>>> mask = abjad.sustain([1, 2])
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        indices=[1, 2],
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[
...         abjad.silence_all(),
...         mask,
...         ],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Sustains divisions -1 and -2:

>>> mask = abjad.sustain([-1, -2])
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        indices=[-1, -2],
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[
...         abjad.silence_all(),
...         mask,
...         ],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Works with pattern input:

>>> pattern_1 = abjad.index_all()
>>> pattern_2 = abjad.index_first()
>>> pattern_3 = abjad.index_last()
>>> pattern = pattern_1 ^ pattern_2 ^ pattern_3
>>> mask = abjad.sustain(pattern)
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        operator='xor',
        patterns=(
            abjad.Pattern(
                indices=[0],
                period=1,
                ),
            abjad.Pattern(
                indices=[0],
                ),
            abjad.Pattern(
                indices=[-1],
                ),
            ),
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[
...         abjad.silence_all(),
...         mask,
...         ],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Works with pattern input and inverted flag:

>>> pattern_1 = abjad.index_all()
>>> pattern_2 = abjad.index_first()
>>> pattern_3 = abjad.index_last()
>>> pattern = pattern_1 ^ pattern_2 ^ pattern_3
>>> mask = abjad.sustain(pattern, inverted=True)
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        inverted=True,
        operator='xor',
        patterns=(
            abjad.Pattern(
                indices=[0],
                period=1,
                ),
            abjad.Pattern(
                indices=[0],
                ),
            abjad.Pattern(
                indices=[-1],
                ),
            ),
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[
...         abjad.silence_all(),
...         mask,
...         ],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Returns sustain mask.

static SustainMask.sustain_all(inverted=None)

Makes sustain mask that matches all indices.

Without mask:

>>> rhythm_maker = rhythmmakertools.TupletRhythmMaker(
...     tuplet_ratios=[(3, 1)],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

With mask:

>>> mask = abjad.sustain_all()
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        indices=[0],
        period=1,
        ),
    )
>>> rhythm_maker = rhythmmakertools.TupletRhythmMaker(
...     division_masks=[mask],
...     tuplet_ratios=[(3, 1)],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Returns sustain mask.

static SustainMask.sustain_every(indices, period, inverted=None)

Makes sustain mask that matches indices at period.

Sustains every second division:

>>> mask = abjad.sustain_every(indices=[1], period=2)
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        indices=[1],
        period=2,
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[mask],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Sustains every second and third division:

>>> mask = abjad.sustain_every(indices=[1, 2], period=3)
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        indices=[1, 2],
        period=3,
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[mask],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Returns sustain mask.

static SustainMask.sustain_first(n=1, inverted=None)

Makes sustain mask that matches the first n indices.

Sustains first division:

>>> mask = abjad.sustain_first()
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        indices=[0],
        ),
    )
>>> rhythm_maker = rhythmmakertools.EvenDivisionRhythmMaker(
...     denominators=[16],
...     division_masks=[mask],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Sustains first two divisions:

>>> mask = abjad.sustain_first(n=2)
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        indices=[0, 1],
        ),
    )
>>> rhythm_maker = rhythmmakertools.EvenDivisionRhythmMaker(
...     denominators=[16],
...     division_masks=[mask],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Returns sustain mask.

static SustainMask.sustain_last(n=1, inverted=None)

Makes sustain mask that matches the last n indices.

Sustains last division:

>>> mask = abjad.sustain_last()
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        indices=[-1],
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[
...         abjad.silence_all(),
...         mask,
...         ],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Sustains last two divisions:

>>> mask = abjad.sustain_last(n=2)
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(
        indices=[-2, -1],
        ),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[
...         abjad.silence_all(),
...         mask
...         ],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Sustains no last divisions:

>>> mask = abjad.sustain_last(n=0)
>>> f(mask)
rhythmmakertools.SustainMask(
    pattern=abjad.Pattern(),
    )
>>> rhythm_maker = rhythmmakertools.NoteRhythmMaker(
...     division_masks=[
...         abjad.silence_all(),
...         mask,
...         ],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> show(lilypond_file) 

Returns sustain mask.

Special methods

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

(AbjadValueObject).__eq__(argument)

Is true when all initialization values of Abjad value object equal the initialization values of argument.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(AbjadValueObject).__hash__()

Hashes Abjad value object.

Returns integer.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.