SustainMask

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=1]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjadext/rmakers/../../abjad/system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjadext/rmakers/../../abjad/system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph "cluster_abjadext.rmakers" { graph [label="abjadext.rmakers"]; node [color=2]; "abjadext.rmakers.SustainMask.SustainMask" [URL="../api/abjadext/rmakers/SustainMask.html#abjadext.rmakers.SustainMask.SustainMask", color=black, fontcolor=white, label="Sustain\nMask", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjadext.rmakers.SustainMask.SustainMask"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjadext.rmakers.SustainMask.SustainMask(pattern=None, *, template=None)

Sustain mask.

>>> mask = abjadext.rmakers.SustainMask(
...     pattern=abjad.index([0, 1, 7], 16),
...     )
>>> abjad.f(mask)
abjadext.rmakers.SustainMask(
    pattern=abjad.index([0, 1, 7], period=16),
    )

With composite pattern:

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

Works inverted composite pattern:

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

Attributes Summary

__invert__ Inverts pattern.
pattern Gets pattern.
sustain Makes sustain mask that matches indices.
template Gets template.

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.

__invert__()

Inverts pattern.

Return type:SustainMask
(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Class & static methods

static sustain(indices, period=None, inverted=None)

Makes sustain mask that matches indices.

Sustains divisions 1 and 2:

>>> mask = abjadext.rmakers.sustain([1, 2])
>>> mask
abjadext.rmakers.sustain([1, 2])
>>> rhythm_maker = abjadext.rmakers.NoteRhythmMaker(
...     division_masks=[
...         abjadext.rmakers.silence([0], 1),
...         mask,
...         ],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> abjad.show(lilypond_file) 

Sustains divisions -1 and -2:

>>> mask = abjadext.rmakers.sustain([-1, -2])
>>> mask
abjadext.rmakers.sustain([-1, -2])
>>> rhythm_maker = abjadext.rmakers.NoteRhythmMaker(
...     division_masks=[
...         abjadext.rmakers.silence([0], 1),
...         mask,
...         ],
...     )
>>> divisions = [(7, 16), (3, 8), (7, 16), (3, 8)]
>>> selections = rhythm_maker(divisions)
>>> lilypond_file = abjad.LilyPondFile.rhythm(
...     selections,
...     divisions,
...     )
>>> abjad.show(lilypond_file) 

Returns sustain mask.

Return type:SustainMask

Read-only properties

pattern

Gets pattern.

Return type:Pattern
template

Gets template.

Return type:Optional[str]