score

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.obgc" { graph [label="abjad.obgc"]; node [color=1]; "abjad.obgc.OnBeatGraceContainer" [URL="../api/abjad/obgc.html#abjad.obgc.OnBeatGraceContainer", label="On\nBeat\nGrace\nContainer", target=_top]; } subgraph "cluster_abjad.score" { graph [label="abjad.score"]; node [color=2]; "abjad.score.AfterGraceContainer" [URL="../api/abjad/score.html#abjad.score.AfterGraceContainer", color=black, fontcolor=white, label="After\nGrace\nContainer", target=_top]; "abjad.score.BeforeGraceContainer" [URL="../api/abjad/score.html#abjad.score.BeforeGraceContainer", color=black, fontcolor=white, label="Before\nGrace\nContainer", target=_top]; "abjad.score.Chord" [URL="../api/abjad/score.html#abjad.score.Chord", color=black, fontcolor=white, label=Chord, target=_top]; "abjad.score.Cluster" [URL="../api/abjad/score.html#abjad.score.Cluster", color=black, fontcolor=white, label=Cluster, target=_top]; "abjad.score.Component" [URL="../api/abjad/score.html#abjad.score.Component", color=black, fontcolor=white, label=Component, target=_top]; "abjad.score.Container" [URL="../api/abjad/score.html#abjad.score.Container", color=black, fontcolor=white, label=Container, target=_top]; "abjad.score.Component" -> "abjad.score.Container"; "abjad.score.Leaf" [URL="../api/abjad/score.html#abjad.score.Leaf", color=black, fontcolor=white, label=Leaf, target=_top]; "abjad.score.Component" -> "abjad.score.Leaf"; "abjad.score.Container" -> "abjad.score.AfterGraceContainer" [minlen=2]; "abjad.score.Container" -> "abjad.score.BeforeGraceContainer" [minlen=1]; "abjad.score.Container" -> "abjad.score.Cluster" [minlen=2]; "abjad.score.Context" [URL="../api/abjad/score.html#abjad.score.Context", color=black, fontcolor=white, label=Context, target=_top]; "abjad.score.Container" -> "abjad.score.Context"; "abjad.score.TremoloContainer" [URL="../api/abjad/score.html#abjad.score.TremoloContainer", color=black, fontcolor=white, label="Tremolo\nContainer", target=_top]; "abjad.score.Container" -> "abjad.score.TremoloContainer" [minlen=1]; "abjad.score.Tuplet" [URL="../api/abjad/score.html#abjad.score.Tuplet", color=black, fontcolor=white, label=Tuplet, target=_top]; "abjad.score.Container" -> "abjad.score.Tuplet" [minlen=2]; "abjad.score.Score" [URL="../api/abjad/score.html#abjad.score.Score", color=black, fontcolor=white, label=Score, target=_top]; "abjad.score.Context" -> "abjad.score.Score" [minlen=1]; "abjad.score.Staff" [URL="../api/abjad/score.html#abjad.score.Staff", color=black, fontcolor=white, label=Staff, target=_top]; "abjad.score.Context" -> "abjad.score.Staff" [minlen=2]; "abjad.score.StaffGroup" [URL="../api/abjad/score.html#abjad.score.StaffGroup", color=black, fontcolor=white, label="Staff\nGroup", target=_top]; "abjad.score.Context" -> "abjad.score.StaffGroup" [minlen=1]; "abjad.score.Voice" [URL="../api/abjad/score.html#abjad.score.Voice", color=black, fontcolor=white, label=Voice, target=_top]; "abjad.score.Context" -> "abjad.score.Voice" [minlen=2]; "abjad.score.DrumNoteHead" [URL="../api/abjad/score.html#abjad.score.DrumNoteHead", color=black, fontcolor=white, label="Drum\nNote\nHead", target=_top]; "abjad.score.Leaf" -> "abjad.score.Chord" [minlen=1]; "abjad.score.MultimeasureRest" [URL="../api/abjad/score.html#abjad.score.MultimeasureRest", color=black, fontcolor=white, label="Multimeasure\nRest", target=_top]; "abjad.score.Leaf" -> "abjad.score.MultimeasureRest" [minlen=2]; "abjad.score.Note" [URL="../api/abjad/score.html#abjad.score.Note", color=black, fontcolor=white, label=Note, target=_top]; "abjad.score.Leaf" -> "abjad.score.Note" [minlen=1]; "abjad.score.Rest" [URL="../api/abjad/score.html#abjad.score.Rest", color=black, fontcolor=white, label=Rest, target=_top]; "abjad.score.Leaf" -> "abjad.score.Rest" [minlen=2]; "abjad.score.Skip" [URL="../api/abjad/score.html#abjad.score.Skip", color=black, fontcolor=white, label=Skip, target=_top]; "abjad.score.Leaf" -> "abjad.score.Skip" [minlen=1]; "abjad.score.NoteHead" [URL="../api/abjad/score.html#abjad.score.NoteHead", color=black, fontcolor=white, label="Note\nHead", target=_top]; "abjad.score.NoteHead" -> "abjad.score.DrumNoteHead" [minlen=1]; "abjad.score.NoteHeadList" [URL="../api/abjad/score.html#abjad.score.NoteHeadList", color=black, fontcolor=white, label="Note\nHead\nList", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.list" [URL="https://docs.python.org/3.10/library/stdtypes.html#list", label=list, target=_top]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; "builtins.object" -> "builtins.list" [minlen=2]; } "abjad.score.Container" -> "abjad.obgc.OnBeatGraceContainer" [minlen=1]; "builtins.list" -> "abjad.score.NoteHeadList" [minlen=1]; "builtins.object" -> "abjad.score.Component"; "builtins.object" -> "abjad.score.NoteHead" [minlen=1]; }


Classes

Component

Component baseclass.

Leaf

Leaf baseclass.

class abjad.score.Component(*, tag=None)[source]

Component baseclass.


Attributes Summary

__copy__

Shallow copies component.

tag

Gets component tag.


Special methods

__copy__(*arguments)[source]

Shallow copies component.

Copies indicators.

Does not copy spanners.

Does not copy children.

Returns new component.


Read-only properties

tag

Gets component tag.

class abjad.score.Leaf(written_duration, *, multiplier=None, tag=None)[source]

Leaf baseclass.

Leaves include notes, rests, chords and skips.


Attributes Summary

__copy__

Shallow copies leaf.

__repr__

Gets repr.

multiplier

Gets multiplier.

written_duration

Gets written duration.


Special methods

overridden __copy__(*arguments)[source]

Shallow copies leaf.

overridden __repr__()[source]

Gets repr.

Return type:

str


Read/write properties

multiplier

Gets multiplier.

written_duration

Gets written duration.


Read-only properties

(Component).tag

Gets component tag.


Containers

AfterGraceContainer

After grace container.

BeforeGraceContainer

Grace container.

Cluster

Cluster.

Container

Container.

TremoloContainer

Tremolo container.

Tuplet

Tuplet.

class abjad.score.AfterGraceContainer(components=None, *, language='english', tag=None)[source]

After grace container.

After grace notes:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> string = "#(define afterGraceFraction (cons 15 16))"
>>> literal = abjad.LilyPondLiteral(string, site="before")
>>> abjad.attach(literal, voice[0])
>>> notes = [abjad.Note("c'16"), abjad.Note("d'16")]
>>> after_grace_container = abjad.AfterGraceContainer(notes)
>>> abjad.attach(after_grace_container, voice[1])
>>> abjad.show(voice)  

LilyPond positions after grace notes at a point 3/4 of the way after the note they follow. The resulting spacing is usually too loose.

Customize afterGraceFraction as shown above.

After grace notes are played in the last moments of duration of the note they follow.

Use after grace notes when you need to end a piece of music with grace notes.

Fill grace containers with notes, rests or chords.

Attach after grace containers to notes, rests or chords.

REGRESSION. After grace containers format correctly with main note articulations and markup:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> string = "#(define afterGraceFraction (cons 15 16))"
>>> literal = abjad.LilyPondLiteral(string, site="before")
>>> abjad.attach(literal, voice[0])
>>> after_grace_container = abjad.AfterGraceContainer("c'16 d'16")
>>> abjad.attach(after_grace_container, voice[1])
>>> leaves = abjad.select.leaves(voice, grace=None)
>>> markup = abjad.Markup(r"\markup Allegro")
>>> abjad.attach(markup, leaves[1], direction=abjad.UP)
>>> abjad.attach(abjad.Articulation("."), leaves[1])
>>> abjad.show(voice)  

REGRESSION #1074. After grace containers format correctly with chords and overrides. It is important here that the \afterGrace command appear lexically after the \override command:

>>> voice = abjad.Voice("c'4 <d' f'>4 e'4 f'4")
>>> string = "#(define afterGraceFraction (cons 15 16))"
>>> literal = abjad.LilyPondLiteral(string, site="before")
>>> abjad.attach(literal, voice[0])
>>> after_grace_container = abjad.AfterGraceContainer("c'16 d'16")
>>> abjad.attach(after_grace_container, voice[1])
>>> abjad.override(voice[1]).NoteHead.color = "#red"
>>> abjad.show(voice)  

Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:

bool

(Component).__copy__(*arguments)

Shallow copies component.

Copies indicators.

Does not copy spanners.

Does not copy children.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

(Container).__getitem__(argument)

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:

int

(Container).__repr__()

Gets repr.

Return type:

str

(Container).__setitem__(i, argument)

Sets container i equal to argument.

Return type:

None


Methods

(Container).append(component, *, language='english')

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).extend(argument, *, language='english')

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container)  
Return type:

None

(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

(Container).insert(i, component, *, language='english')

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None


Read/write properties

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
(Container).simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

(Container).components

Gets components in container.

(Component).tag

Gets component tag.

class abjad.score.BeforeGraceContainer(components=None, *, command='\\\\grace', language='english', tag=None)[source]

Grace container.

Grace container models LilyPond’s different types of “left-positioned” grace music:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16 ds'")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  

LilyPond engraves grace music at a reduced size.

LilyPond positions grace music immediately before a “main note” which follows.

Fill grace containers with notes, rests or chords:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("<cs' ds'>16 e'")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  

Detach grace containers like this:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("<cs' ds'>16 e'")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  
>>> abjad.detach(abjad.BeforeGraceContainer, voice[1])
(BeforeGraceContainer("<cs' ds'>16 e'16"),)
>>> abjad.detach(abjad.BeforeGraceContainer, voice[1])
()
>>> abjad.show(voice)  

Move grace containers like this:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("<cs' ds'>16 e'")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  
>>> result = abjad.detach(abjad.BeforeGraceContainer, voice[1])
>>> container = result[0]
>>> abjad.attach(container, voice[3])
>>> abjad.show(voice)  

LilyPond provides four types of left-positioned grace music: acciaccaturas, appoggiaturas, grace notes and slashed grace notes; see abjad.BeforeGraceContainer.command to choose between these. LilyPond’s left-positioned grace music contrasts with “right-positioned” after-grace music; see abjad.AfterGraceContainer.

Note that neither LilyPond nor Abjad attempts to model the ways that different categories of grace music have been performed historically. Typographic differences in slurring and slashing are provided. But distinctions between (for example) on-the-beat versus before-the-beat performance are left implicit.


Attributes Summary

command

Gets command.


Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:

bool

(Component).__copy__(*arguments)

Shallow copies component.

Copies indicators.

Does not copy spanners.

Does not copy children.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

(Container).__getitem__(argument)

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:

int

(Container).__repr__()

Gets repr.

Return type:

str

(Container).__setitem__(i, argument)

Sets container i equal to argument.

Return type:

None


Methods

(Container).append(component, *, language='english')

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).extend(argument, *, language='english')

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container)  
Return type:

None

(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

(Container).insert(i, component, *, language='english')

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None


Read/write properties

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
(Container).simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

command

Gets command. Chooses between LilyPond’s four types of left-positioned grace music.

(Vanilla) grace notes. LilyPond formats single grace notes with neither a slash nor a slur:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  

LilyPond likewise formats runs of grace notes with neither a slash nor a slur:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16 ds'")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  

Acciaccaturas. LilyPond formats single acciaccaturas with both a slash and a slur:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16", command=r"\acciaccatura")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  

But LilyPond fails to slash runs of acciaccaturas. This behavior is a longstanding LilyPond bug:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16 ds'", command=r"\acciaccatura")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  

Note

LilyPond fails to slash runs of acciaccaturas.

Appoggiaturas. LilyPond formats single appoggiaturas with only a slur; no slash is included:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16", command=r"\appoggiatura")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  

LilyPond likewise formats runs of appoggiaturas with only a slur:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16 ds'", command=r"\appoggiatura")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  

Slashed grace notes. LilyPond formats single slashed grace notes with only a slash; no slur is included:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16", command=r"\slashedGrace")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  

But LilyPond fails to slash runs of “slashed” grace notes. This is a longstanding LilyPond bug:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16 ds'", command=r"\slashedGrace")
>>> abjad.attach(container, voice[1])
>>> abjad.show(voice)  

Note

LilyPond fails to slash runs of “slashed” grace notes.

LilyPond \acciaccatura, \appoggiatura are syntactic sugar.

Grace notes with slur may be used instead of appoggiatura:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, voice[1])
>>> leaves = abjad.select.leaves(voice)[1:3]
>>> abjad.slur(leaves)
>>> abjad.show(voice)  

Slashed grace notes with slur may be used instead of acciaccatura:

>>> voice = abjad.Voice("c'4 d'4 e'4 f'4")
>>> container = abjad.BeforeGraceContainer("cs'16", command=r"\slashedGrace")
>>> abjad.attach(container, voice[1])
>>> leaves = abjad.select.leaves(voice)[1:3]
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
(Container).components

Gets components in container.

(Component).tag

Gets component tag.

class abjad.score.Cluster(components=None, *, identifier=None, language='english', name=None, simultaneous=False, tag=None)[source]

Cluster.

>>> cluster = abjad.Cluster("c'8 <d' g'>8 b'8")
>>> abjad.show(cluster)  
>>> cluster
Cluster("c'8 <d' g'>8 b'8")

Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:

bool

(Component).__copy__(*arguments)

Shallow copies component.

Copies indicators.

Does not copy spanners.

Does not copy children.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

(Container).__getitem__(argument)

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:

int

(Container).__repr__()

Gets repr.

Return type:

str

(Container).__setitem__(i, argument)

Sets container i equal to argument.

Return type:

None


Methods

(Container).append(component, *, language='english')

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).extend(argument, *, language='english')

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container)  
Return type:

None

(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

(Container).insert(i, component, *, language='english')

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None


Read/write properties

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
(Container).simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

(Container).components

Gets components in container.

(Component).tag

Gets component tag.

class abjad.score.Container(components=None, *, identifier=None, language='english', name=None, simultaneous=False, tag=None)[source]

Container.

Intializes from string:

>>> container = abjad.Container("c'4 e'4 d'4 e'8 f'8")
>>> abjad.show(container)  

Intializes from components:

>>> notes = [
...     abjad.Note("c'4"),
...     abjad.Note("e'4"),
...     abjad.Note("d'4"),
...     abjad.Note("e'8"),
...     abjad.Note("f'8"),
... ]
>>> container = abjad.Container(notes)
>>> abjad.show(container)  

Containers are iterables:

>>> import collections
>>> container = abjad.Container("c'4 e'4 d'4 e'8 f'8")
>>> isinstance(container, collections.abc.Iterable)
True

Containers are not sequences because containers do not implement reverse:

>>> container = abjad.Container("c'4 e'4 d'4 e'8 f'8")
>>> isinstance(container, collections.abc.Sequence)
False

Formatting positions contributions strictly one-per-line:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> abjad.attach(abjad.Articulation("^"), staff[0])
>>> markup = abjad.Markup(r"\markup Allegro")
>>> abjad.attach(markup, staff[0], direction=abjad.UP)
>>> abjad.attach(abjad.StemTremolo(), staff[0])
>>> abjad.show(staff)  
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
{
    c'4
    :16
    - \marcato
    ^ \markup Allegro
    d'4
    e'4
    f'4
}

Attributes Summary

__contains__

Is true when argument appears in container.

__delitem__

Deletes components(s) at index i in container.

__getitem__

Gets top-level item or slice identified by argument.

__iter__

Iterates container.

__len__

Gets number of components in container.

__repr__

Gets repr.

__setitem__

Sets container i equal to argument.

append

Appends component to container.

components

Gets components in container.

extend

Extends container with argument.

identifier

Gets and sets bracket comment.

index

Returns index of component in container.

insert

Inserts component at index i in container.

name

Gets and sets name of container.

pop

Pops component from container at index i.

remove

Removes component from container.

simultaneous

Is true when container is simultaneous.


Special methods

__contains__(argument)[source]

Is true when argument appears in container.

Return type:

bool

(Component).__copy__(*arguments)

Shallow copies component.

Copies indicators.

Does not copy spanners.

Does not copy children.

Returns new component.

__delitem__(i)[source]

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

__getitem__(argument)[source]

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

__iter__()[source]

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

__len__()[source]

Gets number of components in container.

Return type:

int

overridden __repr__()[source]

Gets repr.

Return type:

str

__setitem__(i, argument)[source]

Sets container i equal to argument.

Return type:

None


Methods

append(component, *, language='english')[source]

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

extend(argument, *, language='english')[source]

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container)  
Return type:

None

index(component)[source]

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

insert(i, component, *, language='english')[source]

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

pop(i=-1)[source]

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

remove(component)[source]

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None


Read/write properties

identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

components

Gets components in container.

(Component).tag

Gets component tag.

class abjad.score.TremoloContainer(count=2, components=None, *, language='english', tag=None)[source]

Tremolo container.

>>> staff = abjad.Staff()
>>> staff.append(abjad.TremoloContainer(2, "c'16 e'"))
>>> staff.append("cs'4")
>>> staff.append(abjad.TremoloContainer(2, "d'16 f'"))
>>> staff.append("ds'4")
>>> abjad.show(staff)  

Duration of container equal to contents duration multiplied by count:

>>> abjad.get.duration(staff[0])
Duration(1, 4)

Duration of each leaf equal to written duration multiplied by count:

>>> abjad.get.duration(staff[0][0])
Duration(1, 8)

Attributes Summary

count

Gets count.

implied_prolation

Gets implied prolation of tremolo container.


Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:

bool

(Component).__copy__(*arguments)

Shallow copies component.

Copies indicators.

Does not copy spanners.

Does not copy children.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

(Container).__getitem__(argument)

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:

int

(Container).__repr__()

Gets repr.

Return type:

str

(Container).__setitem__(i, argument)

Sets container i equal to argument.

Return type:

None


Methods

(Container).append(component, *, language='english')

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).extend(argument, *, language='english')

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container)  
Return type:

None

(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

(Container).insert(i, component, *, language='english')

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None


Read/write properties

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
(Container).simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

(Container).components

Gets components in container.

count

Gets count.

>>> tremolo_container = abjad.TremoloContainer(2, "<c' d'>16 e'16")
>>> tremolo_container.count
2
implied_prolation

Gets implied prolation of tremolo container.

Defined equal to count.

>>> tremolo_container = abjad.TremoloContainer(2, "<c' d'>16 e'16")
>>> abjad.show(tremolo_container)  
>>> tremolo_container.implied_prolation
Fraction(2, 1)
(Component).tag

Gets component tag.

class abjad.score.Tuplet(multiplier='3:2', components=None, *, denominator=None, force_fraction=False, hide=False, language='english', tag=None, tweaks=None)[source]

Tuplet.

A tuplet:

>>> tuplet = abjad.Tuplet("6:4", "c'8 d'8 e'8")
>>> abjad.show(tuplet)  

A nested tuplet:

>>> second_tuplet = abjad.Tuplet("7:4", "g'4. ( a'16 )")
>>> tuplet.insert(1, second_tuplet)
>>> abjad.show(tuplet)  

A doubly nested tuplet:

>>> third_tuplet = abjad.Tuplet("5:4", [])
>>> third_tuplet.extend("e''32 [ ef''32 d''32 cs''32 cqs''32 ]")
>>> second_tuplet.insert(1, third_tuplet)
>>> abjad.show(tuplet)  

Selects language:

>>> abjad.Tuplet("6:4", "do'2 dod' re'", language="français")
Tuplet('6:4', "c'2 cs'2 d'2")

Tuplets can be entered as LilyPond input:

>>> voice = abjad.Voice(r"\tuplet 6/4 { c'4 d' e' }")
>>> abjad.show(voice)  
>>> voice = abjad.Voice(r"\times 4/6 { c'4 d' e' }")
>>> abjad.show(voice)  

Tweak tuplets like this:

>>> tuplet_1 = abjad.Tuplet((2, 3), "c'4 ( d'4 e'4 )")
>>> abjad.tweak(tuplet_1, r"\tweak color #red")
>>> abjad.tweak(tuplet_1, r"\tweak staff-padding 2")
>>> tuplet_2 = abjad.Tuplet((2, 3), "c'4 ( d'4 e'4 )")
>>> abjad.tweak(tuplet_2, r"\tweak color #green")
>>> abjad.tweak(tuplet_2, r"\tweak staff-padding 2")
>>> tuplet_3 = abjad.Tuplet((5, 4), [tuplet_1, tuplet_2])
>>> abjad.tweak(tuplet_3, r"\tweak color #blue")
>>> abjad.tweak(tuplet_3, r"\tweak staff-padding 4")
>>> staff = abjad.Staff([tuplet_3])
>>> score = abjad.Score([staff], name="Score")
>>> leaves = abjad.select.leaves(staff)
>>> abjad.attach(abjad.TimeSignature((5, 4)), leaves[0])
>>> literal = abjad.LilyPondLiteral(r"\set tupletFullLength = ##t", site="opening")
>>> abjad.attach(literal, staff)
>>> abjad.show(staff)  

Todo

Report LilyPond bug that results from removing tupletFullLength in the example above: blue tuplet bracket shrinks to encompass only the second underlying tuplet.


Attributes Summary

__repr__

Gets repr.

append

Appends component to tuplet.

augmentation

Is true when tuplet multiplier is greater than 1.

colon_string

Gets colon string.

denominator

Gets and sets preferred denominator of tuplet.

diminution

Is true when tuplet multiplier is less than 1.

extend

Extends tuplet with argument.

force_fraction

Gets and sets force fraction flag.

from_duration

Makes tuplet from duration and components.

hide

Is true when tuplet bracket hides.

implied_prolation

Gets implied prolation of tuplet.

multiplied_duration

Gets multiplied duration of tuplet.

multiplier

Gets and sets multiplier of tuplet.

normalize_multiplier

Normalizes tuplet multiplier.

rest_filled

Is true when tuplet is rest-filled.

rewrite_dots

Rewrites dots.

set_minimum_denominator

Sets preferred denominator of tuplet to at least denominator.

tag

Gets tag.

toggle_prolation

Changes augmented tuplets to diminished; changes diminished tuplets to augmented.

trivial

Is true when tuplet multiplier is equal to 1 and no multipliers attach to any leaves in tuplet.

trivializable

Is true when tuplet is trivializable (can be rewritten with a ratio of 1:1).

trivialize

Trivializes tuplet.


Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:

bool

(Component).__copy__(*arguments)

Shallow copies component.

Copies indicators.

Does not copy spanners.

Does not copy children.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

(Container).__getitem__(argument)

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:

int

overridden __repr__()[source]

Gets repr.

Return type:

str

(Container).__setitem__(i, argument)

Sets container i equal to argument.

Return type:

None


Methods

overridden append(component, *, language='english', preserve_duration=False)[source]

Appends component to tuplet.

Appends note to tuplet:

>>> tuplet = abjad.Tuplet((2, 3), "c'4 ( d'4 f'4 )")
>>> abjad.show(tuplet)  
>>> tuplet.append(abjad.Note("e'4"))
>>> abjad.show(tuplet)  

Appends note to tuplet and preserves tuplet duration:

>>> tuplet = abjad.Tuplet((2, 3), "c'4 ( d'4 f'4 )")
>>> abjad.show(tuplet)  
>>> tuplet.append(abjad.Note("e'4"), preserve_duration=True)
>>> abjad.show(tuplet)  
Return type:

None

augmentation()[source]

Is true when tuplet multiplier is greater than 1.

Augmented tuplet:

>>> tuplet = abjad.Tuplet((4, 3), "c'8 d'8 e'8")
>>> abjad.show(tuplet)  
>>> tuplet.augmentation()
True

Diminished tuplet:

>>> tuplet = abjad.Tuplet((2, 3), "c'4 d'4 e'4")
>>> abjad.show(tuplet)  
>>> tuplet.augmentation()
False

Trivial tuplet:

>>> tuplet = abjad.Tuplet((1, 1), "c'8. d'8. e'8.")
>>> abjad.show(tuplet)  
>>> tuplet.augmentation()
False
Return type:

bool

diminution()[source]

Is true when tuplet multiplier is less than 1.

Augmented tuplet:

>>> tuplet = abjad.Tuplet((4, 3), "c'8 d'8 e'8")
>>> abjad.show(tuplet)  
>>> tuplet.diminution()
False

Diminished tuplet:

>>> tuplet = abjad.Tuplet((2, 3), "c'4 d'4 e'4")
>>> abjad.show(tuplet)  
>>> tuplet.diminution()
True

Trivial tuplet:

>>> tuplet = abjad.Tuplet((1, 1), "c'8. d'8. e'8.")
>>> abjad.show(tuplet)  
>>> tuplet.diminution()
False
Return type:

bool

overridden extend(argument, *, language='english', preserve_duration=False)[source]

Extends tuplet with argument.

Extends tuplet with three notes:

>>> tuplet = abjad.Tuplet((2, 3), "c'4 ( d'4 f'4 )")
>>> abjad.show(tuplet)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> tuplet.extend(notes)
>>> abjad.show(tuplet)  

Extends tuplet with three notes and preserves tuplet duration:

>>> tuplet = abjad.Tuplet((2, 3), "c'4 ( d'4 f'4 )")
>>> abjad.show(tuplet)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> tuplet.extend(notes, preserve_duration=True)
>>> abjad.show(tuplet)  
Return type:

None

(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

(Container).insert(i, component, *, language='english')

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

normalize_multiplier()[source]

Normalizes tuplet multiplier.

>>> tuplet = abjad.Tuplet((1, 3), "c'4 d' e'")
>>> abjad.show(tuplet)  
>>> abjad.Duration(tuplet.multiplier).normalized()
False
>>> tuplet.normalize_multiplier()
>>> abjad.show(tuplet)  
>>> abjad.Duration(tuplet.multiplier).normalized()
True
>>> tuplet = abjad.Tuplet((8, 3), "c'32 d'32 e'32")
>>> abjad.show(tuplet)  
>>> abjad.Duration(tuplet.multiplier).normalized()
False
>>> tuplet.normalize_multiplier()
>>> abjad.show(tuplet)  
>>> abjad.Duration(tuplet.multiplier).normalized()
True
>>> tuplet = abjad.Tuplet((5, 12), "c'4 d'4 e'4")
>>> abjad.show(tuplet)  
>>> abjad.Duration(tuplet.multiplier).normalized()
False
>>> tuplet.normalize_multiplier()
>>> abjad.show(tuplet)  
>>> abjad.Duration(tuplet.multiplier).normalized()
True
Return type:

None

(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None

rest_filled()[source]

Is true when tuplet is rest-filled.

>>> tuplet = abjad.Tuplet((3, 2), "r4 r r")
>>> abjad.show(tuplet)  
>>> string = abjad.lilypond(tuplet)
>>> print(string)
\tweak text #tuplet-number::calc-fraction-text
\times 3/2
{
    r4
    r4
    r4
}
>>> tuplet.rest_filled()
True
Return type:

bool

rewrite_dots()[source]

Rewrites dots.

Rewrites single dots as 3:2 prolation:

>>> tuplet = abjad.Tuplet((1, 1), "c'8. c'8.")
>>> abjad.show(tuplet)  
>>> tuplet.rewrite_dots()
>>> abjad.show(tuplet)  

Rewrites double dots as 7:4 prolation:

>>> tuplet = abjad.Tuplet((1, 1), "c'8.. c'8..")
>>> abjad.show(tuplet)  
>>> tuplet.rewrite_dots()
>>> abjad.show(tuplet)  

Does nothing when dot counts differ:

>>> tuplet = abjad.Tuplet((1, 1), "c'8. d'8. e'8")
>>> abjad.show(tuplet)  
>>> tuplet.rewrite_dots()
>>> abjad.show(tuplet)  

Does nothing when leaves carry no dots:

>>> tuplet = abjad.Tuplet((3, 2), "c'8 d' e'")
>>> abjad.show(tuplet)  
>>> tuplet.rewrite_dots()
>>> abjad.show(tuplet)  

Not yet implemented for multiply nested tuplets.

Return type:

None

set_minimum_denominator(denominator)[source]

Sets preferred denominator of tuplet to at least denominator.

Sets preferred denominator of tuplet to 8 at least:

>>> tuplet = abjad.Tuplet((3, 5), "c'4 d'8 e'8 f'4 g'2")
>>> abjad.show(tuplet)  
>>> tuplet.set_minimum_denominator(8)
>>> abjad.show(tuplet)  
Return type:

None

toggle_prolation()[source]

Changes augmented tuplets to diminished; changes diminished tuplets to augmented.

Changes augmented tuplet to diminished:

>>> tuplet = abjad.Tuplet((4, 3), "c'8 d'8 e'8")
>>> abjad.show(tuplet)  
>>> tuplet.toggle_prolation()
>>> abjad.show(tuplet)  

Multiplies the written duration of the leaves in tuplet by the least power of 2 necessary to diminshed tuplet.

Changes diminished tuplet to augmented:

>>> tuplet = abjad.Tuplet((2, 3), "c'4 d'4 e'4")
>>> abjad.show(tuplet)  
>>> tuplet.toggle_prolation()
>>> abjad.show(tuplet)  

Divides the written duration of the leaves in tuplet by the least power of 2 necessary to diminshed tuplet.

REGRESSION. Leaves trivial tuplets unchanged:

>>> tuplet = abjad.Tuplet((1, 1), "c'4 d'4 e'4")
>>> abjad.show(tuplet)  
>>> tuplet.toggle_prolation()
>>> abjad.show(tuplet)  

Does not yet work with nested tuplets.

Return type:

None

trivial()[source]

Is true when tuplet multiplier is equal to 1 and no multipliers attach to any leaves in tuplet.

>>> tuplet = abjad.Tuplet((1, 1), "c'8 d'8 e'8")
>>> abjad.show(tuplet)  
>>> tuplet.trivial()
True

Tuplet is not trivial when multipliers attach to tuplet leaves:

>>> tuplet = abjad.Tuplet((1, 1), "c'8 d'8 e'8")
>>> tuplet[0].multiplier = (3, 2)
>>> tuplet[-1].multiplier = (1, 2)
>>> abjad.show(tuplet)  
>>> tuplet.trivial()
False
Return type:

bool

trivializable()[source]

Is true when tuplet is trivializable (can be rewritten with a ratio of 1:1).

Redudant tuplet:

>>> tuplet = abjad.Tuplet((3, 4), "c'4 c'4")
>>> staff = abjad.Staff([tuplet])
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 8)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet.trivializable()
True

Can be rewritten without a tuplet bracket:

>>> staff = abjad.Staff("c'8. c'8.")
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 8)), staff[0])
>>> abjad.show(staff)  

Nontrivializable tuplet:

>>> tuplet = abjad.Tuplet((3, 5), "c'4 c'4 c'4 c'4 c'4")
>>> staff = abjad.Staff([tuplet])
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 4)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet.trivializable()
False

Can not be rewritten without a tuplet bracket.

REGRESSION. Nontrivializable tuplet:

>>> tuplet = abjad.Tuplet((3, 4), "c'2. c4")
>>> staff = abjad.Staff([tuplet])
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 4)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet.trivializable()
False
Return type:

bool

trivialize()[source]

Trivializes tuplet.

>>> tuplet = abjad.Tuplet((3, 4), "c'2")
>>> abjad.show(tuplet)  
>>> tuplet.trivializable()
True
>>> tuplet.trivialize()
>>> abjad.show(tuplet)  
Return type:

None


Class & static methods

static from_duration(duration, components, *, tag=None)[source]

Makes tuplet from duration and components.

Makes diminution:

>>> tuplet = abjad.Tuplet.from_duration((2, 8), "c'8 d' e'")
>>> abjad.show(tuplet)  
Return type:

Tuplet


Read/write properties

denominator

Gets and sets preferred denominator of tuplet.

Gets preferred denominator of tuplet:

>>> tuplet = abjad.Tuplet("3:2", "c'8 d'8 e'8")
>>> tuplet.denominator is None
True
>>> abjad.show(tuplet)  

Sets preferred denominator of tuplet:

>>> tuplet = abjad.Tuplet("3:2", "c'8 d'8 e'8")
>>> abjad.show(tuplet)  
>>> tuplet.denominator = 4
>>> abjad.show(tuplet)  
force_fraction

Gets and sets force fraction flag.

To illustrate the effect of Abjad’s force fraction property, we can temporarily restore LilyPond’s default tuplet number formatting like this:

>>> staff = abjad.Staff()
>>> staff.append(abjad.Tuplet((2, 3), "c'4 d' e'"))
>>> staff.append(abjad.Tuplet((2, 3), "c'4 d' e'"))
>>> staff.append(abjad.Tuplet((2, 3), "c'4 d' e'"))
>>> string = "#tuplet-number::calc-denominator-text"
>>> abjad.override(staff).TupletNumber.text = string
>>> abjad.show(staff)  

Which makes it possible to see the effect of setting force fraction to true on a single tuplet:

>>> tuplet = staff[1]
>>> tuplet.force_fraction = True
>>> abjad.show(staff)  

Ignored when tuplet number text is overridden explicitly:

>>> tuplet = abjad.Tuplet((2, 3), "c'8 d'8 e'8")
>>> duration = abjad.get.duration(tuplet)
>>> note = abjad.Note.from_pitch_and_duration(0, duration)
>>> string = abjad.illustrators.components_to_score_markup_string([note])
>>> string = rf"\markup {{ {string} }}"
>>> abjad.override(tuplet).TupletNumber.text = string
>>> staff = abjad.Staff([tuplet])
>>> abjad.show(staff)  
hide

Is true when tuplet bracket hides.

>>> tuplet = abjad.Tuplet((2, 3), "c'8 d'8 e'8")
>>> abjad.show(tuplet)  
>>> tuplet.hide
False
>>> tuplet_1 = abjad.Tuplet((2, 3), "c'4 d'4 e'4")
>>> tuplet_2 = abjad.Tuplet((2, 3), "d'4 e'4 f'4")
>>> staff = abjad.Staff([tuplet_1, tuplet_2])
>>> abjad.show(staff)  
>>> staff[0].hide = True
>>> abjad.show(staff)  

Hides tuplet bracket and tuplet number when true.

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
multiplier

Gets and sets multiplier of tuplet.

Gets tuplet multiplier:

>>> tuplet = abjad.Tuplet((2, 3), "c'8 d'8 e'8")
>>> abjad.show(tuplet)  
>>> tuplet.multiplier
(2, 3)

Sets tuplet multiplier:

>>> tuplet.multiplier = (4, 3)
>>> abjad.show(tuplet)  
(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
(Container).simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

colon_string

Gets colon string.

(Container).components

Gets components in container.

implied_prolation

Gets implied prolation of tuplet.

>>> tuplet = abjad.Tuplet((2, 3), "c'8 d'8 e'8")
>>> abjad.show(tuplet)  
>>> tuplet.implied_prolation
Fraction(2, 3)
multiplied_duration

Gets multiplied duration of tuplet.

>>> tuplet = abjad.Tuplet((2, 3), "c'8 d'8 e'8")
>>> abjad.show(tuplet)  
>>> tuplet.multiplied_duration
Duration(1, 4)
overridden tag

Gets tag.

>>> tuplet = abjad.Tuplet((2, 3), "c'4 d' e'", tag=abjad.Tag("RED"))
>>> abjad.show(tuplet)  
>>> string = abjad.lilypond(tuplet, tags=True)
>>> print(string)
  %! RED
\times 2/3
  %! RED
{
    c'4
    d'4
    e'4
  %! RED
}

Contexts

Context

LilyPond context.

Score

Score.

Staff

Staff.

StaffGroup

Staff group.

Voice

Voice.

class abjad.score.Context(components=None, *, language='english', lilypond_type='Context', name=None, simultaneous=False, tag=None)[source]

LilyPond context.

>>> context = abjad.Context(lilypond_type="GlobalContext", name="Meter_Voice")
>>> context
Context(lilypond_type='GlobalContext', name='Meter_Voice')

Attributes Summary

__copy__

Shallow copies context.

__repr__

Gets interpreter representation of context.

consists_commands

Unordered set of LilyPond engravers to include in context definition.

lilypond_context

Gets LilyPondContext associated with context.

lilypond_type

Gets lilypond type.

lilypond_types

remove_commands

Unordered set of LilyPond engravers to remove from context.

tag

Gets tag.


Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:

bool

overridden __copy__(*arguments)[source]

Shallow copies context.

Copies indicators.

Does not copy children.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

(Container).__getitem__(argument)

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:

int

overridden __repr__()[source]

Gets interpreter representation of context.

>>> context = abjad.Context(
...     lilypond_type="GlobalContext",
...     name="Meter_Voice",
... )
>>> repr(context)
"Context(lilypond_type='GlobalContext', name='Meter_Voice')"
Return type:

str

(Container).__setitem__(i, argument)

Sets container i equal to argument.

Return type:

None


Methods

(Container).append(component, *, language='english')

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).extend(argument, *, language='english')

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container)  
Return type:

None

(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

(Container).insert(i, component, *, language='english')

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None


Read/write properties

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
lilypond_type

Gets lilypond type.

>>> context = abjad.Context(
...     lilypond_type="ViolinStaff",
...     name="MyViolinStaff",
... )
>>> context.lilypond_type
'ViolinStaff'

Gets and sets lilypond type of context.

(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
(Container).simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

(Container).components

Gets components in container.

consists_commands

Unordered set of LilyPond engravers to include in context definition.

Manage with add, update, other standard set commands:

>>> staff = abjad.Staff([])
>>> staff.consists_commands.append("Horizontal_bracket_engraver")
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
\with
{
    \consists Horizontal_bracket_engraver
}
{
}
lilypond_context

Gets LilyPondContext associated with context.

Returns LilyPond context instance.

remove_commands

Unordered set of LilyPond engravers to remove from context.

Manage with add, update, other standard set commands:

>>> staff = abjad.Staff([])
>>> staff.remove_commands.append("Time_signature_engraver")
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
\with
{
    \remove Time_signature_engraver
}
{
}
overridden tag

Gets tag.

>>> context = abjad.Context(
...     "c'4 d' e' f'",
...     lilypond_type="CustomContext",
...     tag=abjad.Tag("RED"),
... )
>>> abjad.show(context)  
>>> string = abjad.lilypond(context, tags=True)
>>> print(string)
  %! RED
\new CustomContext
  %! RED
{
    c'4
    d'4
    e'4
    f'4
  %! RED
}
class abjad.score.Score(components=None, *, language='english', lilypond_type='Score', name=None, simultaneous=True, tag=None)[source]

Score.

>>> staff_1 = abjad.Staff("c'8 d'8 e'8 f'8")
>>> staff_2 = abjad.Staff("c'8 d'8 e'8 f'8")
>>> score = abjad.Score([staff_1, staff_2])
>>> abjad.show(score)  

Attributes Summary

tag

Gets tag.


Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:

bool

(Context).__copy__(*arguments)

Shallow copies context.

Copies indicators.

Does not copy children.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

(Container).__getitem__(argument)

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:

int

(Context).__repr__()

Gets interpreter representation of context.

>>> context = abjad.Context(
...     lilypond_type="GlobalContext",
...     name="Meter_Voice",
... )
>>> repr(context)
"Context(lilypond_type='GlobalContext', name='Meter_Voice')"
Return type:

str

(Container).__setitem__(i, argument)

Sets container i equal to argument.

Return type:

None


Methods

(Container).append(component, *, language='english')

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).extend(argument, *, language='english')

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container)  
Return type:

None

(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

(Container).insert(i, component, *, language='english')

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None


Read/write properties

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
(Context).lilypond_type

Gets lilypond type.

>>> context = abjad.Context(
...     lilypond_type="ViolinStaff",
...     name="MyViolinStaff",
... )
>>> context.lilypond_type
'ViolinStaff'

Gets and sets lilypond type of context.

(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
(Container).simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

(Container).components

Gets components in container.

(Context).consists_commands

Unordered set of LilyPond engravers to include in context definition.

Manage with add, update, other standard set commands:

>>> staff = abjad.Staff([])
>>> staff.consists_commands.append("Horizontal_bracket_engraver")
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
\with
{
    \consists Horizontal_bracket_engraver
}
{
}
(Context).lilypond_context

Gets LilyPondContext associated with context.

Returns LilyPond context instance.

(Context).remove_commands

Unordered set of LilyPond engravers to remove from context.

Manage with add, update, other standard set commands:

>>> staff = abjad.Staff([])
>>> staff.remove_commands.append("Time_signature_engraver")
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
\with
{
    \remove Time_signature_engraver
}
{
}
overridden tag

Gets tag.

>>> voice = abjad.Voice("c'4 d' e' f'", tag=abjad.Tag("RED"))
>>> staff = abjad.Staff([voice], tag=abjad.Tag("BLUE"))
>>> score = abjad.Score([staff], tag=abjad.Tag("GREEN"))
>>> abjad.show(score)  
>>> string = abjad.lilypond(score, tags=True)
>>> print(string)
  %! GREEN
\new Score
  %! GREEN
<<
      %! BLUE
    \new Staff
      %! BLUE
    {
          %! RED
        \new Voice
          %! RED
        {
            c'4
            d'4
            e'4
            f'4
          %! RED
        }
      %! BLUE
    }
  %! GREEN
>>
class abjad.score.Staff(components=None, *, language='english', lilypond_type='Staff', name=None, simultaneous=False, tag=None)[source]

Staff.

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8")
>>> abjad.show(staff)  

Can initialize from collection of strings:

>>> staff = abjad.Staff(
...     [
...         r"\times 9/10 { r8 c'16 c'16 bf'4~ bf'16 r16 }",
...         r"\times 9/10 { bf'16 e''16 e''4 ~ e''16 r16 fs''16 af''16 }",
...         r"\times 4/5 { a'16 r4 }",
...     ]
... )
>>> abjad.show(staff)  

Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:

bool

(Context).__copy__(*arguments)

Shallow copies context.

Copies indicators.

Does not copy children.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

(Container).__getitem__(argument)

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:

int

(Context).__repr__()

Gets interpreter representation of context.

>>> context = abjad.Context(
...     lilypond_type="GlobalContext",
...     name="Meter_Voice",
... )
>>> repr(context)
"Context(lilypond_type='GlobalContext', name='Meter_Voice')"
Return type:

str

(Container).__setitem__(i, argument)

Sets container i equal to argument.

Return type:

None


Methods

(Container).append(component, *, language='english')

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).extend(argument, *, language='english')

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container)  
Return type:

None

(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

(Container).insert(i, component, *, language='english')

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None


Read/write properties

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
(Context).lilypond_type

Gets lilypond type.

>>> context = abjad.Context(
...     lilypond_type="ViolinStaff",
...     name="MyViolinStaff",
... )
>>> context.lilypond_type
'ViolinStaff'

Gets and sets lilypond type of context.

(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
(Container).simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

(Container).components

Gets components in container.

(Context).consists_commands

Unordered set of LilyPond engravers to include in context definition.

Manage with add, update, other standard set commands:

>>> staff = abjad.Staff([])
>>> staff.consists_commands.append("Horizontal_bracket_engraver")
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
\with
{
    \consists Horizontal_bracket_engraver
}
{
}
(Context).lilypond_context

Gets LilyPondContext associated with context.

Returns LilyPond context instance.

(Context).remove_commands

Unordered set of LilyPond engravers to remove from context.

Manage with add, update, other standard set commands:

>>> staff = abjad.Staff([])
>>> staff.remove_commands.append("Time_signature_engraver")
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
\with
{
    \remove Time_signature_engraver
}
{
}
(Context).tag

Gets tag.

>>> context = abjad.Context(
...     "c'4 d' e' f'",
...     lilypond_type="CustomContext",
...     tag=abjad.Tag("RED"),
... )
>>> abjad.show(context)  
>>> string = abjad.lilypond(context, tags=True)
>>> print(string)
  %! RED
\new CustomContext
  %! RED
{
    c'4
    d'4
    e'4
    f'4
  %! RED
}
class abjad.score.StaffGroup(components=None, *, language='english', lilypond_type='StaffGroup', name=None, simultaneous=True, tag=None)[source]

Staff group.

>>> staff_1 = abjad.Staff("c'4 d'4 e'4 f'4 g'1")
>>> staff_2 = abjad.Staff("g2 f2 e1")
>>> staff_group = abjad.StaffGroup([staff_1, staff_2])
>>> abjad.show(staff_group)  

Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:

bool

(Context).__copy__(*arguments)

Shallow copies context.

Copies indicators.

Does not copy children.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

(Container).__getitem__(argument)

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:

int

(Context).__repr__()

Gets interpreter representation of context.

>>> context = abjad.Context(
...     lilypond_type="GlobalContext",
...     name="Meter_Voice",
... )
>>> repr(context)
"Context(lilypond_type='GlobalContext', name='Meter_Voice')"
Return type:

str

(Container).__setitem__(i, argument)

Sets container i equal to argument.

Return type:

None


Methods

(Container).append(component, *, language='english')

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).extend(argument, *, language='english')

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container)  
Return type:

None

(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

(Container).insert(i, component, *, language='english')

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None


Read/write properties

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
(Context).lilypond_type

Gets lilypond type.

>>> context = abjad.Context(
...     lilypond_type="ViolinStaff",
...     name="MyViolinStaff",
... )
>>> context.lilypond_type
'ViolinStaff'

Gets and sets lilypond type of context.

(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
(Container).simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

(Container).components

Gets components in container.

(Context).consists_commands

Unordered set of LilyPond engravers to include in context definition.

Manage with add, update, other standard set commands:

>>> staff = abjad.Staff([])
>>> staff.consists_commands.append("Horizontal_bracket_engraver")
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
\with
{
    \consists Horizontal_bracket_engraver
}
{
}
(Context).lilypond_context

Gets LilyPondContext associated with context.

Returns LilyPond context instance.

(Context).remove_commands

Unordered set of LilyPond engravers to remove from context.

Manage with add, update, other standard set commands:

>>> staff = abjad.Staff([])
>>> staff.remove_commands.append("Time_signature_engraver")
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
\with
{
    \remove Time_signature_engraver
}
{
}
(Context).tag

Gets tag.

>>> context = abjad.Context(
...     "c'4 d' e' f'",
...     lilypond_type="CustomContext",
...     tag=abjad.Tag("RED"),
... )
>>> abjad.show(context)  
>>> string = abjad.lilypond(context, tags=True)
>>> print(string)
  %! RED
\new CustomContext
  %! RED
{
    c'4
    d'4
    e'4
    f'4
  %! RED
}
class abjad.score.Voice(components=None, *, language='english', lilypond_type='Voice', name=None, simultaneous=False, tag=None)[source]

Voice.

>>> voice = abjad.Voice("c'8 d'8 e'8 f'8")
>>> abjad.show(voice)  

Voice-contexted indicators like dynamics work with nested voices.

Forte affects all red notes:

>>> outer_red_voice = abjad.Voice("e''8 d''", name="Red_Voice")
>>> inner_red_voice = abjad.Voice("c''4 b' c''8", name="Red_Voice")
>>> inner_blue_voice = abjad.Voice("e'4 f' e'8", name="Blue_Voice")
>>> container = abjad.Container(
...     [inner_red_voice, inner_blue_voice],
...     simultaneous=True,
... )
>>> outer_red_voice.append(container)
>>> outer_red_voice.extend("d''8")
>>> abjad.override(outer_red_voice).NoteHead.color = "#red"
>>> command = abjad.VoiceNumber(1)
>>> abjad.attach(command, outer_red_voice[0])
>>> abjad.override(inner_blue_voice).NoteHead.color = "#blue"
>>> command = abjad.VoiceNumber(2)
>>> abjad.attach(command, inner_blue_voice[0])
>>> dynamic = abjad.Dynamic("f")
>>> abjad.attach(dynamic, outer_red_voice[0])
>>> abjad.show(outer_red_voice)  
>>> for leaf in abjad.iterate.leaves(outer_red_voice):
...     dynamic = abjad.get.effective(leaf, abjad.Dynamic)
...     print(leaf, dynamic)
... 
Note("e''8") Dynamic(name='f', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=2)
Note("d''8") Dynamic(name='f', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=2)
Note("c''4") Dynamic(name='f', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=2)
Note("b'4") Dynamic(name='f', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=2)
Note("c''8") Dynamic(name='f', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=2)
Note("e'4") None
Note("f'4") None
Note("e'8") None
Note("d''8") Dynamic(name='f', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=2)

Piano affects all blue notes:

>>> outer_red_voice = abjad.Voice("e''8 d''", name="Red_Voice")
>>> inner_red_voice = abjad.Voice("c''4 b' c''8", name="Red_Voice")
>>> inner_blue_voice = abjad.Voice("e'4 f' e'8", name="Blue_Voice")
>>> container = abjad.Container(
...     [inner_red_voice, inner_blue_voice],
...     simultaneous=True,
... )
>>> outer_red_voice.append(container)
>>> outer_red_voice.extend("d''8")
>>> abjad.override(outer_red_voice).NoteHead.color = "#red"
>>> command = abjad.VoiceNumber(1)
>>> abjad.attach(command, outer_red_voice[0])
>>> abjad.override(inner_blue_voice).NoteHead.color = "#blue"
>>> command = abjad.VoiceNumber(2)
>>> abjad.attach(command, inner_blue_voice[0])
>>> dynamic = abjad.Dynamic("p")
>>> abjad.attach(dynamic, inner_blue_voice[0])
>>> abjad.show(outer_red_voice)  
>>> for leaf in abjad.iterate.leaves(outer_red_voice):
...     dynamic = abjad.get.effective(leaf, abjad.Dynamic)
...     print(leaf, dynamic)
... 
Note("e''8") None
Note("d''8") None
Note("c''4") None
Note("b'4") None
Note("c''8") None
Note("e'4") Dynamic(name='p', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=-2)
Note("f'4") Dynamic(name='p', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=-2)
Note("e'8") Dynamic(name='p', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=-2)
Note("d''8") None

Mezzoforte affects red notes from C4 forward:

>>> outer_red_voice = abjad.Voice("e''8 d''", name="Red_Voice")
>>> inner_red_voice = abjad.Voice("c''4 b' c''8", name="Red_Voice")
>>> inner_blue_voice = abjad.Voice("e'4 f' e'8", name="Blue_Voice")
>>> container = abjad.Container(
...     [inner_red_voice, inner_blue_voice],
...     simultaneous=True,
... )
>>> outer_red_voice.append(container)
>>> outer_red_voice.extend("d''8")
>>> abjad.override(outer_red_voice).NoteHead.color = "#red"
>>> command = abjad.VoiceNumber(1)
>>> abjad.attach(command, outer_red_voice[0])
>>> abjad.override(inner_blue_voice).NoteHead.color = "#blue"
>>> command = abjad.VoiceNumber(2)
>>> abjad.attach(command, inner_blue_voice[0])
>>> dynamic = abjad.Dynamic("mf")
>>> abjad.attach(dynamic, inner_red_voice[0])
>>> abjad.show(outer_red_voice)  
>>> for leaf in abjad.iterate.leaves(outer_red_voice):
...     dynamic = abjad.get.effective(leaf, abjad.Dynamic)
...     print(leaf, dynamic)
... 
Note("e''8") None
Note("d''8") None
Note("c''4") Dynamic(name='mf', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=1)
Note("b'4") Dynamic(name='mf', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=1)
Note("c''8") Dynamic(name='mf', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=1)
Note("e'4") None
Note("f'4") None
Note("e'8") None
Note("d''8") Dynamic(name='mf', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=1)

Mezzoforte and piano set at the same time:

>>> outer_red_voice = abjad.Voice("e''8 d''", name="Red_Voice")
>>> inner_red_voice = abjad.Voice("c''4 b' c''8", name="Red_Voice")
>>> inner_blue_voice = abjad.Voice("e'4 f' e'8", name="Blue_Voice")
>>> container = abjad.Container(
...     [inner_red_voice, inner_blue_voice],
...     simultaneous=True,
... )
>>> outer_red_voice.append(container)
>>> outer_red_voice.extend("d''8")
>>> abjad.override(outer_red_voice).NoteHead.color = "#red"
>>> command = abjad.VoiceNumber(1)
>>> abjad.attach(command, outer_red_voice[0])
>>> abjad.override(inner_blue_voice).NoteHead.color = "#blue"
>>> command = abjad.VoiceNumber(2)
>>> abjad.attach(command, inner_blue_voice[0])
>>> dynamic = abjad.Dynamic("mf")
>>> abjad.attach(dynamic, inner_red_voice[0])
>>> dynamic = abjad.Dynamic("p")
>>> abjad.attach(dynamic, inner_blue_voice[0])
>>> abjad.show(outer_red_voice)  
>>> for leaf in abjad.iterate.leaves(outer_red_voice):
...     dynamic = abjad.get.effective(leaf, abjad.Dynamic)
...     print(leaf, dynamic)
... 
Note("e''8") None
Note("d''8") None
Note("c''4") Dynamic(name='mf', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=1)
Note("b'4") Dynamic(name='mf', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=1)
Note("c''8") Dynamic(name='mf', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=1)
Note("e'4") Dynamic(name='p', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=-2)
Note("f'4") Dynamic(name='p', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=-2)
Note("e'8") Dynamic(name='p', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=-2)
Note("d''8") Dynamic(name='mf', command=None, format_hairpin_stop=False, hide=False, leak=False, name_is_textual=False, ordinal=1)

Selects language:

>>> abjad.Voice("do'8 re' mi' fa'", language="français")
Voice("c'8 d'8 e'8 f'8")

Attributes Summary

tag

Gets tag.


Special methods

(Container).__contains__(argument)

Is true when argument appears in container.

Return type:

bool

(Context).__copy__(*arguments)

Shallow copies context.

Copies indicators.

Does not copy children.

Returns new component.

(Container).__delitem__(i)

Deletes components(s) at index i in container.

Deletes first tuplet in voice:

>>> voice = abjad.Voice()
>>> voice.append(abjad.Tuplet((4, 6), "c'4 d'4 e'4"))
>>> voice.append(abjad.Tuplet((2, 3), "e'4 d'4 c'4"))
>>> leaves = abjad.select.leaves(voice)
>>> abjad.slur(leaves)
>>> abjad.show(voice)  
>>> tuplet_1 = voice[0]
>>> del voice[0]
>>> start_slur = abjad.StartSlur()
>>> leaf = abjad.select.leaf(voice, 0)
>>> abjad.attach(start_slur, leaf)

First tuplet no longer appears in voice:

>>> abjad.show(voice)  
>>> abjad.wf.wellformed(voice)
True

First tuplet must have start slur removed:

>>> abjad.detach(abjad.StartSlur, tuplet_1[0])
(StartSlur(),)
>>> abjad.show(tuplet_1)  
>>> abjad.wf.wellformed(tuplet_1)
True

Returns none.

(Container).__getitem__(argument)

Gets top-level item or slice identified by argument.

Return type:

Component | list[Component]

(Container).__iter__()

Iterates container.

Abjad containers are iterables:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Iterable)
True

Abjad containers are not sequences:

>>> import collections
>>> container = abjad.Container()
>>> isinstance(container, collections.abc.Sequence)
False

Yields container elements.

Returns generator.

(Container).__len__()

Gets number of components in container.

Return type:

int

(Context).__repr__()

Gets interpreter representation of context.

>>> context = abjad.Context(
...     lilypond_type="GlobalContext",
...     name="Meter_Voice",
... )
>>> repr(context)
"Context(lilypond_type='GlobalContext', name='Meter_Voice')"
Return type:

str

(Container).__setitem__(i, argument)

Sets container i equal to argument.

Return type:

None


Methods

(Container).append(component, *, language='english')

Appends component to container.

Appends note to container:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> container.append(abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).extend(argument, *, language='english')

Extends container with argument.

Extends container with three notes:

>>> container = abjad.Container("c'4 ( d'4 f'4 )")
>>> abjad.show(container)  
>>> notes = [abjad.Note("e'32"), abjad.Note("d'32"), abjad.Note("e'16")]
>>> container.extend(notes)
>>> abjad.show(container)  
Return type:

None

(Container).index(component)

Returns index of component in container.

Gets index of last element in container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[-1]
>>> note
Note("e'4")
>>> container.index(note)
3
Return type:

int

(Container).insert(i, component, *, language='english')

Inserts component at index i in container.

Inserts note.

>>> container = abjad.Container([])
>>> container.extend("fs16 cs' e' a'")
>>> container.extend("cs''16 e'' cs'' a'")
>>> container.extend("fs'16 e' cs' fs")
>>> abjad.show(container)  
>>> container.insert(-4, abjad.Note("e'4"))
>>> abjad.show(container)  
Return type:

None

(Container).pop(i=-1)

Pops component from container at index i.

Pops last element from container:

>>> container = abjad.Container("c'4 ( d'4 f'4 ) e'4")
>>> abjad.show(container)  
>>> container.pop()
Note("e'4")
>>> abjad.show(container)  
Return type:

Component

(Container).remove(component)

Removes component from container.

Removes note from container:

>>> container = abjad.Container("c'4 d'4 f'4 e'4")
>>> abjad.show(container)  
>>> note = container[2]
>>> note
Note("f'4")
>>> container.remove(note)
>>> abjad.show(container)  
Return type:

None


Read/write properties

(Container).identifier

Gets and sets bracket comment.

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     identifier="%*% AB",
... )
>>> abjad.show(container)  
>>> string = abjad.lilypond(container)
>>> print(string)
{   %*% AB
    c'4
    d'4
    e'4
    f'4
}   %*% AB
(Context).lilypond_type

Gets lilypond type.

>>> context = abjad.Context(
...     lilypond_type="ViolinStaff",
...     name="MyViolinStaff",
... )
>>> context.lilypond_type
'ViolinStaff'

Gets and sets lilypond type of context.

(Container).name

Gets and sets name of container.

Gets container name:

>>> container = abjad.Container("c'4 d'4 e'4 f'4")
>>> abjad.show(container)  
>>> container.name is None
True

Sets container name:

>>> container = abjad.Container(
...     "c'4 d'4 e'4 f'4",
...     name="Special",
... )
>>> abjad.show(container)  
>>> container.name
'Special'

Container name does not appear in LilyPond output:

>>> string = abjad.lilypond(container)
>>> print(string)
{
    c'4
    d'4
    e'4
    f'4
}
(Container).simultaneous

Is true when container is simultaneous.

Gets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous
False

Sets simultaneity status of container:

>>> container = abjad.Container()
>>> container.append(abjad.Voice("c'8 d'8 e'8"))
>>> container.append(abjad.Voice("g4."))
>>> abjad.show(container)  
>>> container.simultaneous = True
>>> abjad.show(container)  

Read-only properties

(Container).components

Gets components in container.

(Context).consists_commands

Unordered set of LilyPond engravers to include in context definition.

Manage with add, update, other standard set commands:

>>> staff = abjad.Staff([])
>>> staff.consists_commands.append("Horizontal_bracket_engraver")
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
\with
{
    \consists Horizontal_bracket_engraver
}
{
}
(Context).lilypond_context

Gets LilyPondContext associated with context.

Returns LilyPond context instance.

(Context).remove_commands

Unordered set of LilyPond engravers to remove from context.

Manage with add, update, other standard set commands:

>>> staff = abjad.Staff([])
>>> staff.remove_commands.append("Time_signature_engraver")
>>> string = abjad.lilypond(staff)
>>> print(string)
\new Staff
\with
{
    \remove Time_signature_engraver
}
{
}
overridden tag

Gets tag.

>>> voice = abjad.Voice("c'4 d' e' f'", tag=abjad.Tag("RED"))
>>> abjad.show(voice)  
>>> string = abjad.lilypond(voice, tags=True)
>>> print(string)
  %! RED
\new Voice
  %! RED
{
    c'4
    d'4
    e'4
    f'4
  %! RED
}

Leaves

Chord

Chord.

MultimeasureRest

Multimeasure rest.

Note

Note.

Rest

Rest.

Skip

LilyPond skip.

class abjad.score.Chord(*arguments, language='english', multiplier=None, tag=None)[source]

Chord.

>>> chord = abjad.Chord("<e' cs'' f''>4")
>>> abjad.show(chord)  

REGRESSION. Initializes from other chord:

>>> chord = abjad.Chord("<e' cs'' f''>4", multiplier=(1, 2))
>>> abjad.show(chord)  
>>> new_chord = abjad.Chord(chord)
>>> abjad.show(new_chord)  

Attributes Summary

__copy__

Copies chord.

note_heads

Gets note-heads in chord.

written_duration

Gets and sets written duration of chord.

written_pitches

Written pitches in chord.


Special methods

overridden __copy__(*arguments)[source]

Copies chord.

Return type:

Chord

(Leaf).__repr__()

Gets repr.

Return type:

str


Read/write properties

(Leaf).multiplier

Gets multiplier.

note_heads

Gets note-heads in chord.

Gets note-heads in chord:

>>> chord = abjad.Chord("<g' c'' e''>4")
>>> abjad.show(chord)  
>>> for _ in chord.note_heads:
...     _
... 
NoteHead("g'")
NoteHead("c''")
NoteHead("e''")

Sets note-heads with pitch names:

>>> chord = abjad.Chord("<g' c'' e''>4")
>>> abjad.show(chord)  
>>> chord.note_heads = "c' d' fs'"
>>> abjad.show(chord)  

Sets note-heads with pitch numbers:

>>> chord = abjad.Chord("<g' c'' e''>4")
>>> abjad.show(chord)  
>>> chord.note_heads = [16, 17, 19]
>>> abjad.show(chord)  

Set note-heads with any iterable.

overridden written_duration

Gets and sets written duration of chord.

Get written duration:

>>> chord = abjad.Chord("<e' cs'' f''>4")
>>> abjad.show(chord)  
>>> chord.written_duration
Duration(1, 4)

Set written duration:

>>> chord = abjad.Chord("<e' cs'' f''>4")
>>> abjad.show(chord)  
>>> chord.written_duration = abjad.Duration(1, 16)
>>> abjad.show(chord)  
written_pitches

Written pitches in chord.

Get written pitches:

>>> chord = abjad.Chord("<g' c'' e''>4")
>>> abjad.show(chord)  
>>> chord.written_pitches
(NamedPitch("g'"), NamedPitch("c''"), NamedPitch("e''"))

Set written pitches with pitch names:

>>> chord = abjad.Chord("<e' g' c''>4")
>>> abjad.show(chord)  
>>> chord.written_pitches = "f' b' d''"
>>> abjad.show(chord)  
>>> chord.written_pitches
(NamedPitch("f'"), NamedPitch("b'"), NamedPitch("d''"))

Set written pitches with any iterable.


Read-only properties

(Component).tag

Gets component tag.

class abjad.score.MultimeasureRest(*arguments, language='english', multiplier=None, tag=None)[source]

Multimeasure rest.

>>> rest = abjad.MultimeasureRest((1, 4))
>>> abjad.show(rest)  

Multimeasure rests may be tagged:

>>> rest = abjad.MultimeasureRest("R1", tag=abjad.Tag("GLOBAL_MULTIMEASURE_REST"))
>>> string = abjad.lilypond(rest, tags=True)
>>> print(string)
  %! GLOBAL_MULTIMEASURE_REST
R1

REGRESSION #1049. Parser reads multimeasure rest multipliers:

>>> staff = abjad.Staff(r"\time 3/8 R1 * 3/8")
>>> score = abjad.Score([staff], name="Score")
>>> abjad.show(staff)  

Attributes Summary

tag

Gets tag.


Special methods

(Leaf).__copy__(*arguments)

Shallow copies leaf.

(Leaf).__repr__()

Gets repr.

Return type:

str


Read/write properties

(Leaf).multiplier

Gets multiplier.

(Leaf).written_duration

Gets written duration.


Read-only properties

overridden tag

Gets tag.

>>> rest = abjad.MultimeasureRest(1, tag=abjad.Tag("MULTIMEASURE_REST"))
>>> rest.multiplier = (3, 8)
>>> string = abjad.lilypond(rest, tags=True)
>>> print(string)
  %! MULTIMEASURE_REST
R1 * 3/8
class abjad.score.Note(*arguments, language='english', multiplier=None, tag=None)[source]

Note.

>>> note = abjad.Note("cs''8.")
>>> abjad.show(note)  

REGRESSION. Initializes from other note:

>>> note = abjad.Note("cs''4", multiplier=(1, 1))
>>> abjad.show(note)  
>>> new_note = abjad.Note(note)
>>> abjad.show(new_note)  

Selects language:

>>> abjad.Note("dod''8.", language="français")
Note("cs''8.")

Attributes Summary

__copy__

Copies note.

from_pitch_and_duration

Makes note from pitch and duration.

note_head

Gets and sets note-head.

written_duration

Gets and sets written duration.

written_pitch

Gets and sets written pitch.


Special methods

overridden __copy__(*arguments)[source]

Copies note.

Return type:

Note

(Leaf).__repr__()

Gets repr.

Return type:

str


Class & static methods

static from_pitch_and_duration(pitch, duration)[source]

Makes note from pitch and duration.

>>> note = abjad.Note.from_pitch_and_duration("C#5", (3, 16))
>>> abjad.show(note)  
Return type:

Note


Read/write properties

(Leaf).multiplier

Gets multiplier.

note_head

Gets and sets note-head.

>>> note = abjad.Note("cs''8.")
>>> note.note_head
NoteHead("cs''")
>>> abjad.show(note)  
>>> note.note_head = "D5"
>>> note.note_head
NoteHead("d''")
>>> abjad.show(note)  
overridden written_duration

Gets and sets written duration.

>>> note = abjad.Note("cs''8.")
>>> note.written_duration
Duration(3, 16)
>>> abjad.show(note)  
>>> note.written_duration = (1, 16)
>>> note.written_duration
Duration(1, 16)
>>> abjad.show(note)  
written_pitch

Gets and sets written pitch.

>>> note = abjad.Note("cs''8.")
>>> note.written_pitch
NamedPitch("cs''")
>>> abjad.show(note)  
>>> note.written_pitch = "D5"
>>> note.written_pitch
NamedPitch("d''")
>>> abjad.show(note)  

Read-only properties

(Component).tag

Gets component tag.

class abjad.score.Rest(written_duration=None, *, language='english', multiplier=None, tag=None)[source]

Rest.

>>> rest = abjad.Rest("r8.")
>>> staff = abjad.Staff([rest])
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), rest)
>>> abjad.show(staff)  

Special methods

(Leaf).__copy__(*arguments)

Shallow copies leaf.

(Leaf).__repr__()

Gets repr.

Return type:

str


Read/write properties

(Leaf).multiplier

Gets multiplier.

(Leaf).written_duration

Gets written duration.


Read-only properties

(Component).tag

Gets component tag.

class abjad.score.Skip(*arguments, language='english', multiplier=None, tag=None)[source]

LilyPond skip.

>>> skip = abjad.Skip((1, 1))
>>> skip
Skip('s1')
>>> skip = abjad.Skip((1, 1), multiplier=(5, 4))
>>> skip
Skip('s1 * 5/4')
>>> note = abjad.Note("c'4", multiplier=(5, 4))
>>> skip = abjad.Skip(note)
>>> skip
Skip('s4 * 5/4')

Skips can be tagged:

>>> skip = abjad.Skip("s8.", tag=abjad.Tag("GLOBAL_SKIP"))
>>> string = abjad.lilypond(skip, tags=True)
>>> print(string)
  %! GLOBAL_SKIP
s8.

Special methods

(Leaf).__copy__(*arguments)

Shallow copies leaf.

(Leaf).__repr__()

Gets repr.

Return type:

str


Read/write properties

(Leaf).multiplier

Gets multiplier.

(Leaf).written_duration

Gets written duration.


Read-only properties

(Component).tag

Gets component tag.


Note-heads

DrumNoteHead

Drum note-head.

NoteHead

Note-head.

NoteHeadList

Note-head list.

class abjad.score.DrumNoteHead(written_pitch='snare', *, is_cautionary=False, is_forced=False, is_parenthesized=False, tweaks=None)[source]

Drum note-head.

>>> note_head = abjad.DrumNoteHead("snare")
>>> note_head
DrumNoteHead('snare')

Special methods

(NoteHead).__copy__(*arguments)

Copies note-head.

>>> import copy
>>> note_head = abjad.NoteHead(13)
>>> copy.copy(note_head)
NoteHead("cs''")
Return type:

NoteHead

(NoteHead).__eq__(argument)

Is true when `argument is a note-head with written pitch equal to that of this note-head.

Return type:

bool

(NoteHead).__ge__(other)

Return a >= b. Computed by @total_ordering from (not a < b).

(NoteHead).__gt__(other)

Return a > b. Computed by @total_ordering from (not a < b) and (a != b).

(NoteHead).__hash__()

Hashes note-head.

Return type:

int

(NoteHead).__le__(other)

Return a <= b. Computed by @total_ordering from (a < b) or (a == b).

(NoteHead).__lt__(argument)

Is true when argument is a note-head with written pitch greater than that of this note-head.

Return type:

bool

(NoteHead).__repr__()

Gets interpreter representation of note-head.

>>> note_head = abjad.NoteHead(13)
>>> note_head
NoteHead("cs''")
Return type:

str


Read/write properties

(NoteHead).alternative

Gets and sets note-head alternative.

>>> import copy
>>> note = abjad.Note("c''4")
>>> alternative = copy.copy(note.note_head)
>>> alternative.is_forced = True
>>> triple = (alternative, abjad.Tag("-PARTS"), abjad.Tag("+PARTS"))
>>> note.note_head.alternative = triple
>>> abjad.show(note)  
>>> string = abjad.lilypond(note, tags=True)
>>> print(string)
  %! +PARTS
c''4
  %! -PARTS
%@% c''!4

Survives pitch reassignment:

>>> note.written_pitch = "D5"
>>> abjad.show(note)  
>>> string = abjad.lilypond(note, tags=True)
>>> print(string)
  %! +PARTS
d''4
  %! -PARTS
%@% d''!4

Clear with none:

>>> note.note_head.alternative = None
>>> abjad.show(note)  
>>> string = abjad.lilypond(note, tags=True)
>>> print(string)
d''4
>>> chord = abjad.Chord("<c' d' bf''>4")
>>> alternative = copy.copy(chord.note_heads[0])
>>> alternative.is_forced = True
>>> triple = (alternative, abjad.Tag("-PARTS"), abjad.Tag("+PARTS"))
>>> chord.note_heads[0].alternative = triple
>>> abjad.show(chord)  
>>> string = abjad.lilypond(chord, tags=True)
>>> print(string)
<
      %! +PARTS
    c'
      %! -PARTS
    %@% c'!
    d'
    bf''
>4

Suvives pitch reassignment:

>>> chord.note_heads[0].written_pitch = "B3"
>>> abjad.show(chord)  
>>> string = abjad.lilypond(chord, tags=True)
>>> print(string)
<
      %! +PARTS
    b
      %! -PARTS
    %@% b!
    d'
    bf''
>4

Clear with none:

>>> chord.note_heads[0].alternative = None
>>> string = abjad.lilypond(chord, tags=True)
>>> print(string)
<b d' bf''>4
(NoteHead).is_cautionary

Gets and sets cautionary accidental flag.

>>> note = abjad.Note("c''")
>>> note.note_head.is_cautionary = True
>>> abjad.show(note)  
>>> note = abjad.Note("cs''")
>>> note.note_head.is_cautionary = True
>>> abjad.show(note)  
(NoteHead).is_forced

Gets and sets forced accidental flag.

>>> note = abjad.Note("c''")
>>> note.note_head.is_forced = True
>>> abjad.show(note)  
>>> note = abjad.Note("cs''")
>>> note.note_head.is_forced = True
>>> abjad.show(note)  
(NoteHead).is_parenthesized

Gets and sets forced accidental flag.

>>> note = abjad.Note("c''")
>>> note.note_head.is_parenthesized = True
>>> abjad.show(note)  
>>> note = abjad.Note("cs''")
>>> note.note_head.is_parenthesized = True
>>> abjad.show(note)  
(NoteHead).written_pitch

Gets and sets written pitch of note-head.

>>> note_head = abjad.NoteHead("cs''")
>>> note_head.written_pitch
NamedPitch("cs''")
>>> note_head = abjad.NoteHead("cs''")
>>> note_head.written_pitch = "d''"
>>> note_head.written_pitch
NamedPitch("d''")

Read-only properties

(NoteHead).named_pitch

Gets named pitch.

>>> note_head = abjad.NoteHead("cs''")
>>> note_head.named_pitch
NamedPitch("cs''")
class abjad.score.NoteHead(written_pitch=None, *, is_cautionary=None, is_forced=None, is_parenthesized=None, tweaks=None)[source]

Note-head.

>>> note = abjad.Note("cs''")
>>> abjad.show(note)  
>>> note.note_head
NoteHead("cs''")
>>> note_head = abjad.NoteHead("cs''")
>>> abjad.tweak(note_head, r"\tweak color #red")
>>> note_head.tweaks
(Tweak(string='\\tweak color #red', tag=None),)
>>> string = abjad.lilypond(note_head)
>>> print(string)
\tweak color #red
cs''
>>> chord = abjad.Chord([0, 2, 10], (1, 4))
>>> abjad.tweak(chord.note_heads[0], r"\tweak color #red")
>>> abjad.tweak(chord.note_heads[0], r"\tweak thickness 2")
>>> abjad.tweak(chord.note_heads[1], r"\tweak color #red")
>>> abjad.tweak(chord.note_heads[1], r"\tweak thickness 2")
>>> abjad.tweak(chord.note_heads[2], r"\tweak color #blue")
>>> abjad.show(chord)  

Attributes Summary

__copy__

Copies note-head.

__eq__

Is true when `argument is a note-head with written pitch equal to that of this note-head.

__ge__

Return a >= b.

__gt__

Return a > b.

__hash__

Hashes note-head.

__le__

Return a <= b.

__lt__

Is true when argument is a note-head with written pitch greater than that of this note-head.

__repr__

Gets interpreter representation of note-head.

alternative

Gets and sets note-head alternative.

is_cautionary

Gets and sets cautionary accidental flag.

is_forced

Gets and sets forced accidental flag.

is_parenthesized

Gets and sets forced accidental flag.

named_pitch

Gets named pitch.

written_pitch

Gets and sets written pitch of note-head.


Special methods

__copy__(*arguments)[source]

Copies note-head.

>>> import copy
>>> note_head = abjad.NoteHead(13)
>>> copy.copy(note_head)
NoteHead("cs''")
Return type:

NoteHead

overridden __eq__(argument)[source]

Is true when `argument is a note-head with written pitch equal to that of this note-head.

Return type:

bool

overridden __ge__(other)

Return a >= b. Computed by @total_ordering from (not a < b).

overridden __gt__(other)

Return a > b. Computed by @total_ordering from (not a < b) and (a != b).

overridden __hash__()[source]

Hashes note-head.

Return type:

int

overridden __le__(other)

Return a <= b. Computed by @total_ordering from (a < b) or (a == b).

overridden __lt__(argument)[source]

Is true when argument is a note-head with written pitch greater than that of this note-head.

Return type:

bool

overridden __repr__()[source]

Gets interpreter representation of note-head.

>>> note_head = abjad.NoteHead(13)
>>> note_head
NoteHead("cs''")
Return type:

str


Read/write properties

alternative

Gets and sets note-head alternative.

>>> import copy
>>> note = abjad.Note("c''4")
>>> alternative = copy.copy(note.note_head)
>>> alternative.is_forced = True
>>> triple = (alternative, abjad.Tag("-PARTS"), abjad.Tag("+PARTS"))
>>> note.note_head.alternative = triple
>>> abjad.show(note)  
>>> string = abjad.lilypond(note, tags=True)
>>> print(string)
  %! +PARTS
c''4
  %! -PARTS
%@% c''!4

Survives pitch reassignment:

>>> note.written_pitch = "D5"
>>> abjad.show(note)  
>>> string = abjad.lilypond(note, tags=True)
>>> print(string)
  %! +PARTS
d''4
  %! -PARTS
%@% d''!4

Clear with none:

>>> note.note_head.alternative = None
>>> abjad.show(note)  
>>> string = abjad.lilypond(note, tags=True)
>>> print(string)
d''4
>>> chord = abjad.Chord("<c' d' bf''>4")
>>> alternative = copy.copy(chord.note_heads[0])
>>> alternative.is_forced = True
>>> triple = (alternative, abjad.Tag("-PARTS"), abjad.Tag("+PARTS"))
>>> chord.note_heads[0].alternative = triple
>>> abjad.show(chord)  
>>> string = abjad.lilypond(chord, tags=True)
>>> print(string)
<
      %! +PARTS
    c'
      %! -PARTS
    %@% c'!
    d'
    bf''
>4

Suvives pitch reassignment:

>>> chord.note_heads[0].written_pitch = "B3"
>>> abjad.show(chord)  
>>> string = abjad.lilypond(chord, tags=True)
>>> print(string)
<
      %! +PARTS
    b
      %! -PARTS
    %@% b!
    d'
    bf''
>4

Clear with none:

>>> chord.note_heads[0].alternative = None
>>> string = abjad.lilypond(chord, tags=True)
>>> print(string)
<b d' bf''>4
is_cautionary

Gets and sets cautionary accidental flag.

>>> note = abjad.Note("c''")
>>> note.note_head.is_cautionary = True
>>> abjad.show(note)  
>>> note = abjad.Note("cs''")
>>> note.note_head.is_cautionary = True
>>> abjad.show(note)  
is_forced

Gets and sets forced accidental flag.

>>> note = abjad.Note("c''")
>>> note.note_head.is_forced = True
>>> abjad.show(note)  
>>> note = abjad.Note("cs''")
>>> note.note_head.is_forced = True
>>> abjad.show(note)  
is_parenthesized

Gets and sets forced accidental flag.

>>> note = abjad.Note("c''")
>>> note.note_head.is_parenthesized = True
>>> abjad.show(note)  
>>> note = abjad.Note("cs''")
>>> note.note_head.is_parenthesized = True
>>> abjad.show(note)  
written_pitch

Gets and sets written pitch of note-head.

>>> note_head = abjad.NoteHead("cs''")
>>> note_head.written_pitch
NamedPitch("cs''")
>>> note_head = abjad.NoteHead("cs''")
>>> note_head.written_pitch = "d''"
>>> note_head.written_pitch
NamedPitch("d''")

Read-only properties

named_pitch

Gets named pitch.

>>> note_head = abjad.NoteHead("cs''")
>>> note_head.named_pitch
NamedPitch("cs''")
class abjad.score.NoteHeadList(argument=())[source]

Note-head list.

>>> for _ in abjad.NoteHeadList([11, 10, 9]):
...     _
... 
NoteHead("a'")
NoteHead("bf'")
NoteHead("b'")

Attributes Summary

__setitem__

Coerces argument and sets at i.

append

Coerces item and appends note-head.

extend

Extends note-heads.

get

Gets note-head by pitch.

pop

Pops note-head i.

remove

Removes item.


Special methods

(list).__add__(value, /)

Return self+value.

(list).__class_getitem__()

See PEP 585

(list).__contains__(key, /)

Return key in self.

(list).__delitem__(key, /)

Delete self[key].

(list).__eq__(value, /)

Return self==value.

(list).__ge__(value, /)

Return self>=value.

(list).__getitem__()

x.__getitem__(y) <==> x[y]

(list).__gt__(value, /)

Return self>value.

(list).__iadd__(value, /)

Implement self+=value.

(list).__imul__(value, /)

Implement self*=value.

(list).__iter__()

Implement iter(self).

(list).__le__(value, /)

Return self<=value.

(list).__len__()

Return len(self).

(list).__lt__(value, /)

Return self<value.

(list).__mul__(value, /)

Return self*value.

(list).__ne__(value, /)

Return self!=value.

(list).__new__(**kwargs)
(list).__repr__()

Return repr(self).

(list).__reversed__()

Return a reverse iterator over the list.

(list).__rmul__(value, /)

Return value*self.

overridden __setitem__(i, argument)[source]

Coerces argument and sets at i.


Methods

overridden append(item)[source]

Coerces item and appends note-head.

(list).clear()

Remove all items from list.

(list).copy()

Return a shallow copy of the list.

(list).count(value, /)

Return number of occurrences of value.

overridden extend(items)[source]

Extends note-heads.

>>> chord = abjad.Chord("<ef'>")
>>> abjad.show(chord)  
>>> note_heads = []
>>> note_head = abjad.NoteHead("cs''")
>>> abjad.tweak(note_head, r"\tweak color #blue")
>>> note_heads.append(note_head)
>>> note_head = abjad.NoteHead("f''")
>>> abjad.tweak(note_head, r"\tweak color #green")
>>> note_heads.append(note_head)
>>> chord.note_heads.extend(note_heads)
>>> abjad.show(chord)  
Return type:

None

get(pitch)[source]

Gets note-head by pitch.

Gets note-head by pitch name:

>>> chord = abjad.Chord("<e' cs'' f''>4")
>>> abjad.show(chord)  
>>> note_head = chord.note_heads.get("e'")
>>> abjad.tweak(note_head, r"\tweak color #red")
>>> abjad.show(chord)  

Gets note-head by pitch number:

>>> chord = abjad.Chord("<e' cs'' f''>4")
>>> abjad.show(chord)  
>>> note_head = chord.note_heads.get(4)
>>> abjad.tweak(note_head, r"\tweak color #red")
>>> abjad.show(chord)  

Raises missing note-head error when chord contains no note-head with pitch.

Raises extra note-head error when chord contains more than one note-head with pitch.

Return type:

NoteHead

(list).index(value, start=0, stop=9223372036854775807, /)

Return first index of value.

Raises ValueError if the value is not present.

(list).insert(index, object, /)

Insert object before index.

overridden pop(i=-1)[source]

Pops note-head i.

>>> chord = abjad.Chord("<ef' c'' f''>4")
>>> abjad.show(chord)  
>>> chord.note_heads.pop(1)
NoteHead("c''")
>>> abjad.show(chord)  
Return type:

NoteHead

overridden remove(item)[source]

Removes item.

>>> chord = abjad.Chord("<ef' c'' f''>4")
>>> abjad.show(chord)  
>>> note_head = chord.note_heads[1]
>>> chord.note_heads.remove(note_head)
>>> abjad.show(chord)  
(list).reverse()

Reverse IN PLACE.

(list).sort(*, key=None, reverse=False)

Sort the list in ascending order and return None.

The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).

If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.

The reverse flag can be set to sort in descending order.