score¶
Classes
Component baseclass. |
|
Leaf baseclass. |
- class abjad.score.Component(*, tag=None)[source]¶
Component baseclass.
Attributes Summary
Shallow copies component.
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
Shallow copies leaf.
Gets repr.
Gets multiplier.
Gets written duration.
Special methods
Read/write properties
- multiplier¶
Gets multiplier.
- written_duration¶
Gets written duration.
Read-only properties
Containers
After grace container. |
|
Grace container. |
|
Cluster. |
|
Container. |
|
Tremolo container. |
|
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
).__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
).__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.
Methods
-
(
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:
-
(
Container
).insert(i, component, *, language='english')¶ Inserts
component
at indexi
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:
Read/write properties
-
(
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
-
(
- 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; seeabjad.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
Gets command.
Special methods
-
(
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
).__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.
Methods
-
(
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:
-
(
Container
).insert(i, component, *, language='english')¶ Inserts
component
at indexi
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:
Read/write properties
-
(
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)
-
(
- 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
).__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
).__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.
Methods
-
(
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:
-
(
Container
).insert(i, component, *, language='english')¶ Inserts
component
at indexi
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:
Read/write properties
-
(
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
-
(
- 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
Is true when
argument
appears in container.Deletes components(s) at index
i
in container.Gets top-level item or slice identified by
argument
.Iterates container.
Gets number of components in container.
Gets repr.
Sets container
i
equal toargument
.Appends
component
to container.Gets components in container.
Extends container with
argument
.Gets and sets bracket comment.
Returns index of
component
in container.Inserts
component
at indexi
in container.Gets and sets name of container.
Pops component from container at index
i
.Removes
component
from container.Is true when container is simultaneous.
Special methods
- __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.
- __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.
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:
- 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:
- 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:
- insert(i, component, *, language='english')[source]¶
Inserts
component
at indexi
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:
- 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:
- 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:
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.
- 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
Gets count.
Gets implied prolation of tremolo container.
Special methods
-
(
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
).__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.
Methods
-
(
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:
-
(
Container
).insert(i, component, *, language='english')¶ Inserts
component
at indexi
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:
Read/write properties
-
(
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
- 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)
-
(
- 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
Gets repr.
Appends
component
to tuplet.Is true when tuplet multiplier is greater than
1
.Gets colon string.
Gets and sets preferred denominator of tuplet.
Is true when tuplet multiplier is less than
1
.Extends tuplet with
argument
.Gets and sets force fraction flag.
Makes tuplet from
duration
andcomponents
.Is true when tuplet bracket hides.
Gets implied prolation of tuplet.
Gets multiplied duration of tuplet.
Gets and sets multiplier of tuplet.
Normalizes tuplet multiplier.
Is true when tuplet is rest-filled.
Rewrites dots.
Sets preferred denominator of tuplet to at least
denominator
.Gets tag.
Changes augmented tuplets to diminished; changes diminished tuplets to augmented.
Is true when tuplet multiplier is equal to
1
and no multipliers attach to any leaves in tuplet.Is true when tuplet is trivializable (can be rewritten with a ratio of 1:1).
Trivializes tuplet.
Special methods
-
(
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
).__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.
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:
- 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:
- 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:
- 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:
-
(
Container
).insert(i, component, *, language='english')¶ Inserts
component
at indexi
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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- trivialize()[source]¶
Trivializes tuplet.
>>> tuplet = abjad.Tuplet((3, 4), "c'2") >>> abjad.show(tuplet)
>>> tuplet.trivializable() True
>>> tuplet.trivialize() >>> abjad.show(tuplet)
- Return type:
Class & static methods
- static from_duration(duration, components, *, tag=None)[source]¶
Makes tuplet from
duration
andcomponents
.Makes diminution:
>>> tuplet = abjad.Tuplet.from_duration((2, 8), "c'8 d' e'") >>> abjad.show(tuplet)
- Return type:
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.
- 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.
- 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
LilyPond context. |
|
Score. |
|
Staff. |
|
Staff group. |
|
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
Shallow copies context.
Gets interpreter representation of context.
Unordered set of LilyPond engravers to include in context definition.
Gets
LilyPondContext
associated with context.Gets lilypond type.
lilypond_types
Unordered set of LilyPond engravers to remove from context.
Gets tag.
Special methods
- 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
).__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.
- 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:
Methods
-
(
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:
-
(
Container
).insert(i, component, *, language='english')¶ Inserts
component
at indexi
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:
Read/write properties
- 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
- 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
Gets tag.
Special methods
-
(
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
).__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.
Methods
-
(
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:
-
(
Container
).insert(i, component, *, language='english')¶ Inserts
component
at indexi
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:
Read/write properties
-
(
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
-
(
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
).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
).__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
).__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.
Methods
-
(
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:
-
(
Container
).insert(i, component, *, language='english')¶ Inserts
component
at indexi
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:
Read/write properties
-
(
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
-
(
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
).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 } { }
-
(
- 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
).__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
).__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.
Methods
-
(
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:
-
(
Container
).insert(i, component, *, language='english')¶ Inserts
component
at indexi
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:
Read/write properties
-
(
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
-
(
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
).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 } { }
-
(
- 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
Gets tag.
Special methods
-
(
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
).__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.
Methods
-
(
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:
-
(
Container
).insert(i, component, *, language='english')¶ Inserts
component
at indexi
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:
Read/write properties
-
(
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
-
(
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
).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. |
|
Multimeasure rest. |
|
Note. |
|
Rest. |
|
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
Copies chord.
Gets note-heads in chord.
Gets and sets written duration of chord.
Written pitches in chord.
Special methods
Read/write properties
- 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
- 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
Gets tag.
Special methods
Read/write properties
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
Copies note.
Makes note from
pitch
andduration
.Gets and sets note-head.
Gets and sets written duration.
Gets and sets written pitch.
Special methods
Class & static methods
- static from_pitch_and_duration(pitch, duration)[source]¶
Makes note from
pitch
andduration
.>>> note = abjad.Note.from_pitch_and_duration("C#5", (3, 16)) >>> abjad.show(note)
- Return type:
Read/write properties
- 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
- 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
Read/write properties
Read-only properties
- 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
Read/write properties
Read-only properties
Note-heads
Drum note-head. |
|
Note-head. |
|
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
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
Read-only properties
-
(
- 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
Copies note-head.
Is true when
`argument
is a note-head with written pitch equal to that of this note-head.Return a >= b.
Return a > b.
Hashes note-head.
Return a <= b.
Is true when
argument
is a note-head with written pitch greater than that of this note-head.Gets interpreter representation of note-head.
Gets and sets note-head alternative.
Gets and sets cautionary accidental flag.
Gets and sets forced accidental flag.
Gets and sets forced accidental flag.
Gets named 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:
- overridden __eq__(argument)[source]¶
Is true when
`argument
is a note-head with written pitch equal to that of this note-head.- Return type:
- 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 __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:
- overridden __repr__()[source]¶
Gets interpreter representation of note-head.
>>> note_head = abjad.NoteHead(13) >>> note_head NoteHead("cs''")
- Return type:
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
Coerces
argument
and sets ati
.Coerces
item
and appends note-head.Extends note-heads.
Gets note-head by
pitch
.Pops note-head
i
.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.
Methods
-
(
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:
- 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:
-
(
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:
- 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.
-
(