abjad.score
After grace container. |
|
Grace container. |
|
|
Chord. |
|
Cluster. |
|
Component. |
|
Container. |
|
LilyPond context. |
|
Drum note-head. |
Independent after grace container. |
|
|
Leaf. |
|
Multimeasure rest. |
|
Note. |
|
Note-head. |
|
Note-head list. |
|
Rest. |
|
Score. |
|
LilyPond skip. |
|
Staff. |
|
Staff group. |
|
Tremolo container. |
|
Tuplet. |
|
Voice. |
- class abjad.score.AfterGraceContainer(components=None, *, fraction: tuple[int, int] | None = None, language: str = 'english', tag: Tag | None = None)[source]
After grace container.
After grace notes are played in the last moments of duration of the note they follow.
Fill after grace containers with notes, rests or chords.
Attach after grace containers to notes, rests or chords.
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
fraction
as shown here:>>> voice = abjad.Voice("c'4 d'4 e'4 f'4") >>> notes = [abjad.Note("c'16"), abjad.Note("d'16")] >>> after_grace_container = abjad.AfterGraceContainer(notes, fraction=(15, 16)) >>> abjad.attach(after_grace_container, voice[1]) >>> abjad.show(voice)
REGRESSION. After grace containers format correctly with main note articulations and markup:
>>> voice = abjad.Voice("c'4 d'4 e'4 f'4") >>> container = abjad.AfterGraceContainer("c'16 d'16", fraction=(15, 16)) >>> abjad.attach(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") >>> container = abjad.AfterGraceContainer("c'16 d'16", fraction=(15, 16)) >>> abjad.attach(container, voice[1]) >>> abjad.override(voice[1]).NoteHead.color = "#red" >>> abjad.show(voice)
Gets LilyPond afterGraceFraction.
- fraction
Gets LilyPond afterGraceFraction.
- class abjad.score.BeforeGraceContainer(components=None, *, command: str = '\\grace', language: str = 'english', tag: Tag | None = None)[source]
Grace container.
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.
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)
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)
Gets command.
- 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.Chord(*arguments, language: str = 'english', multiplier: tuple[int, int] | None = None, tag: Tag | None = None)[source]
Chord.
>>> chord = abjad.Chord("<e' cs'' f''>4") >>> abjad.show(chord)
Gets note-heads in chord.
Gets and sets written duration of chord.
Written pitches in chord.
- 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)
- 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''"))
- class abjad.score.Cluster(components=None, *, identifier: str | None = None, language: str = 'english', name: str | None = None, simultaneous: bool = False, tag: Tag | None = 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")
- class abjad.score.Component(*, tag: Tag | None = None)[source]
Component.
Gets component tag.
- tag
Gets component tag.
- class abjad.score.Container(components=None, *, identifier: str | None = None, language: str = 'english', name: str | None = None, simultaneous: bool = False, tag: Tag | None = 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 }
append
(component, *[, language])Appends
component
to container.Gets components in container.
extend
(argument, *[, language])Extends container with
argument
.Gets and sets bracket comment.
index
(component)Returns index of
component
in container.insert
(i, component, *[, language])Inserts
component
at indexi
in container.Gets and sets name of container.
pop
([i])Pops component from container at index
i
.remove
(component)Removes
component
from container.Is true when container is simultaneous.
- append(component: Component, *, language: str = 'english') None [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)
- components
Gets components in container.
- extend(argument, *, language: str = 'english') None [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)
- 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
- index(component) int [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
- insert(i: int, component: str | Component, *, language: str = 'english') None [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)
- 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 }
- pop(i: int = -1) Component [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)
- remove(component: Component) None [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)
- 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)
- class abjad.score.Context(components=None, *, language: str = 'english', lilypond_type: str = 'Context', name: str | None = None, simultaneous: bool = False, tag: Tag | None = None)[source]
LilyPond context.
>>> context = abjad.Context(lilypond_type="GlobalContext", name="Meter_Voice") >>> context Context(lilypond_type='GlobalContext', name='Meter_Voice')
Unordered set of LilyPond engravers to include in context definition.
Gets
LilyPondContext
associated with context.Gets and sets lilypond type of context.
Unordered set of LilyPond engravers to remove from context.
Gets tag.
- 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.
- lilypond_type
Gets and sets lilypond type of context.
>>> context = abjad.Context( ... lilypond_type="ViolinStaff", ... name="MyViolinStaff", ... ) >>> context.lilypond_type 'ViolinStaff'
- 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.DrumNoteHead(written_pitch: str = 'snare', *, is_cautionary: bool = False, is_forced: bool = False, is_parenthesized: bool = False, tweaks: Tweak | None = None)[source]
Drum note-head.
>>> note_head = abjad.DrumNoteHead("snare") >>> note_head DrumNoteHead('snare')
- class abjad.score.IndependentAfterGraceContainer(components=None, *, fraction: tuple[int, int] | None = None, language: str = 'english', tag: Tag | None = None)[source]
Independent after grace container.
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
fraction
as shown:>>> voice = abjad.Voice("c'4 d'4 e'4 f'4") >>> notes = [abjad.Note("c'16"), abjad.Note("d'16")] >>> container = abjad.IndependentAfterGraceContainer(notes, fraction=(15, 16)) >>> voice.insert(2, container) >>> abjad.show(voice)
Gets LilyPond afterGraceFraction.
- fraction
Gets LilyPond afterGraceFraction.
- class abjad.score.Leaf(written_duration: Duration, *, multiplier=None, tag: Tag | None = None)[source]
Leaf.
Gets leaf duration multiplier.
Gets leaf written duration.
- multiplier
Gets leaf duration multiplier.
- written_duration
Gets leaf written duration.
- class abjad.score.MultimeasureRest(*arguments, language: str = 'english', multiplier: tuple[int, int] | None = None, tag: Tag | None = None)[source]
Multimeasure rest.
>>> rest = abjad.MultimeasureRest("R1") >>> abjad.show(rest)
Gets and sets tag.
- overridden tag
Gets and sets tag.
>>> tag = abjad.Tag("MULTIMEASURE_REST") >>> rest = abjad.MultimeasureRest(1, tag=tag) >>> rest.multiplier = (3, 8)
>>> string = abjad.lilypond(rest, tags=True) >>> print(string) %! MULTIMEASURE_REST R1 * 3/8
- class abjad.score.Note(*arguments, language: str = 'english', multiplier: tuple[int, int] | None = None, tag: Tag | None = None)[source]
Note.
>>> note = abjad.Note("cs''8.") >>> abjad.show(note)
Gets and sets note-head.
Gets and sets written duration.
Gets and sets written pitch.
- 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)
- 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', i=None, 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)
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.
- 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)
- named_pitch
Gets named pitch.
>>> note_head = abjad.NoteHead("cs''") >>> note_head.named_pitch NamedPitch("cs''")
- 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''")
- class abjad.score.NoteHeadList(argument=())[source]
Note-head list.
>>> for _ in abjad.NoteHeadList([11, 10, 9]): ... _ ... NoteHead("a'") NoteHead("bf'") NoteHead("b'")
append
(item)Coerces
item
and appends note-head.extend
(items)Extends note-heads.
get
(pitch)Gets note-head by
pitch
.pop
([i])Pops note-head
i
.remove
(item)Removes
item
.- overridden extend(items) None [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)
- get(pitch) NoteHead [source]
Gets note-head by
pitch
.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
.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)
- class abjad.score.Rest(written_duration=None, *, language: str = 'english', multiplier: tuple[int, int] | None = None, tag: Tag | None = 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)
- class abjad.score.Score(components=None, *, language: str = 'english', lilypond_type: str = 'Score', name: str | None = None, simultaneous: bool = True, tag: Tag | None = 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)
Gets and sets tag.
- overridden tag
Gets and sets 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.Skip(*arguments, language: str = 'english', multiplier: tuple[int, int] | None = None, tag: Tag | None = None)[source]
LilyPond skip.
>>> skip = abjad.Skip("s1") >>> skip Skip('s1')
>>> skip = abjad.Skip("s1", 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')
- class abjad.score.Staff(components=None, *, language: str = 'english', lilypond_type: str = 'Staff', name: str | None = None, simultaneous: bool = False, tag: Tag | None = None)[source]
Staff.
>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> abjad.show(staff)
- class abjad.score.StaffGroup(components=None, *, language: str = 'english', lilypond_type: str = 'StaffGroup', name: str | None = None, simultaneous: bool = True, tag: Tag | None = 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)
- class abjad.score.TremoloContainer(count: int = 2, components=None, *, language: str = 'english', tag: Tag | None = 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)
Gets count.
- count
Gets count.
>>> tremolo_container = abjad.TremoloContainer(2, "<c' d'>16 e'16") >>> tremolo_container.count 2
- class abjad.score.Tuplet(ratio: tuple[int, int] | str | Ratio = '3:2', components=None, *, language: str = 'english', tag: Tag | None = None, tweaks: Tweak | None = None)[source]
Tuplet.
A tuplet:
>>> tuplet = abjad.Tuplet("6:4", "c'8 d'8 e'8") >>> abjad.show(tuplet)
Tweak tuplets like this:
>>> tuplet_1 = abjad.Tuplet("3:2", "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("3:2", "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("4:5", [tuplet_1, tuplet_2]) >>> abjad.tweak(tuplet_3, r"\tweak text #tuplet-number::calc-fraction-text") >>> abjad.tweak(tuplet_3, r"\tweak color #blue") >>> abjad.tweak(tuplet_3, r"\tweak staff-padding 4")
>>> staff = abjad.Staff(r"\time 6/4 r4") >>> staff.append(tuplet_3) >>> score = abjad.Score([staff], name="Score") >>> abjad.show(staff)
append
(component, *[, language, ...])Appends
component
to tuplet.extend
(argument, *[, language, ...])Extends tuplet with
argument
.Is true when tuplet is rest-filled.
Is true when tuplet ratio reduces to 1:1.
Is true when tuplet can be rewritten with a ratio of 1:1.
Gets tuplet multiplier.
Normalizes tuplet ratio.
Gets and sets tuplet ratio.
Rewrites dots of leaves in tuplet.
Toggles tuplet prolation.
Rewrites tuplet with ratio of 1:1.
- overridden append(component: Component, *, language: str = 'english', preserve_duration: bool = False) None [source]
Appends
component
to tuplet.Appends note to tuplet:
>>> tuplet = abjad.Tuplet("3:2", "c'4 ( d'4 f'4 )") >>> abjad.show(tuplet)
>>> tuplet.append(abjad.Note("e'4")) >>> abjad.makers.tweak_tuplet_bracket_edge_height(tuplet) >>> abjad.show(tuplet)
Appends note to tuplet and changes tuplet ratio to preserve tuplet duration:
>>> tuplet = abjad.Tuplet("3:2", "c'4 ( d'4 f'4 )") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> voice = abjad.Voice([tuplet]) >>> abjad.show(voice)
>>> tuplet.append(abjad.Note("e'4"), preserve_duration=True) >>> abjad.show(voice)
- overridden extend(argument, *, language: str = 'english', preserve_duration: bool = False) None [source]
Extends tuplet with
argument
.Extends tuplet with three notes:
>>> tuplet = abjad.Tuplet("3:2", "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.makers.tweak_tuplet_bracket_edge_height(tuplet) >>> abjad.show(tuplet)
Extends tuplet with three notes and preserves tuplet duration:
>>> tuplet = abjad.Tuplet("3:2", "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)
- is_rest_filled() bool [source]
Is true when tuplet is rest-filled.
>>> tuplet = abjad.Tuplet("3:2", "r2 r2 r2") >>> abjad.show(tuplet)
>>> tuplet.is_rest_filled() True
- is_trivial() bool [source]
Is true when tuplet ratio reduces to 1:1.
>>> tuplet = abjad.Tuplet("1:1", "c'8 d'8 e'8") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> abjad.show(tuplet)
>>> tuplet.is_trivial() True
Is false when duration multiplier attaches to leaf in tuplet:
>>> tuplet = abjad.Tuplet("1:1", "c'8 d'8 e'8") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> tuplet[0].multiplier = (2, 1) >>> abjad.show(tuplet)
>>> tuplet.is_trivial() False
- is_trivializable() bool [source]
Is true when tuplet can be rewritten with a ratio of 1:1.
>>> tuplet = abjad.Tuplet("4:3", "c'4 c'4 c'4 c'4") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> staff = abjad.Staff([tuplet]) >>> score = abjad.Score([staff], name="Score") >>> abjad.attach(abjad.TimeSignature((3, 4)), tuplet[0]) >>> abjad.show(staff)
>>> tuplet.is_trivializable() True
>>> tuplet.trivialize() >>> abjad.show(staff)
>>> tuplet = abjad.Tuplet("5:3", "c'4 c'4 c'4 c'4 c'4") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> staff = abjad.Staff([tuplet]) >>> score = abjad.Score([staff], name="Score") >>> abjad.attach(abjad.TimeSignature((3, 4)), tuplet[0]) >>> abjad.show(staff)
>>> tuplet.is_trivializable() False
- multiplier() Fraction [source]
Gets tuplet multiplier.
>>> abjad.Tuplet("6:4", "c'4 d'4 e'4").multiplier() Fraction(2, 3)
- normalize_ratio() None [source]
Normalizes tuplet ratio.
>>> tuplet = abjad.Tuplet("3:1", "c'4 d' e'") >>> abjad.show(tuplet)
>>> tuplet.ratio.is_normalized() False
>>> tuplet.normalize_ratio() >>> abjad.show(tuplet)
>>> tuplet.ratio.is_normalized() True
>>> tuplet = abjad.Tuplet("3:8", "c'32 d'32 e'32") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> abjad.show(tuplet)
>>> tuplet.ratio.is_normalized() False
>>> tuplet.normalize_ratio() >>> abjad.show(tuplet)
>>> tuplet.ratio.is_normalized() True
>>> tuplet = abjad.Tuplet("12:5", "c'4 d'4 e'4") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> abjad.show(tuplet)
>>> tuplet.ratio.is_normalized() False
>>> tuplet.normalize_ratio() >>> abjad.show(tuplet)
>>> tuplet.ratio.is_normalized() True
- ratio
Gets and sets tuplet ratio.
>>> tuplet = abjad.Tuplet("3:2", "c'8 d'8 e'8") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> abjad.show(tuplet)
>>> tuplet.ratio Ratio(numerator=3, denominator=2)
>>> tuplet.ratio = abjad.Ratio(6, 4) >>> abjad.show(tuplet)
- rewrite_dots() None [source]
Rewrites dots of leaves in tuplet.
Not implemented for multiply nested tuplets.
Rewrites single dots as 3:2 prolation:
>>> tuplet = abjad.Tuplet("1:1", "c'8. c'8.") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> 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.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> 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.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> abjad.show(tuplet)
>>> tuplet.rewrite_dots() >>> abjad.show(tuplet)
Does nothing when leaves carry no dots:
>>> tuplet = abjad.Tuplet("2:3", "c'8 d' e'") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> abjad.show(tuplet)
>>> tuplet.rewrite_dots() >>> abjad.show(tuplet)
- toggle_prolation() None [source]
Toggles tuplet prolation.
Not implemented for nested tuplets.
Changes augmented tuplet to diminished; that is, multiplies the written duration of the leaves in tuplet by the least power of
2
necessary to diminshed tuplet:>>> tuplet = abjad.Tuplet("3:4", "c'8 d'8 e'8") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> abjad.show(tuplet)
>>> tuplet.toggle_prolation() >>> abjad.show(tuplet)
Changes diminished tuplet to augmented; that is, divides the written duration of the leaves in tuplet by the least power of
2
necessary to diminshed tuplet.>>> tuplet = abjad.Tuplet("3:2", "c'4 d'4 e'4") >>> abjad.show(tuplet)
>>> tuplet.toggle_prolation() >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> abjad.show(tuplet)
Leaves trivial tuplets unchanged:
>>> tuplet = abjad.Tuplet("1:1", "c'4 d'4 e'4") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> abjad.show(tuplet)
>>> tuplet.toggle_prolation() >>> abjad.show(tuplet)
- trivialize() None [source]
Rewrites tuplet with ratio of 1:1.
>>> tuplet = abjad.Tuplet("4:3", "c'4 c'4 c'4 c'4") >>> abjad.tweak(tuplet, r"\tweak text #tuplet-number::calc-fraction-text") >>> staff = abjad.Staff([tuplet]) >>> score = abjad.Score([staff], name="Score") >>> abjad.attach(abjad.TimeSignature((3, 4)), tuplet[0]) >>> abjad.show(staff)
>>> tuplet.is_trivializable() True
>>> tuplet.trivialize() >>> abjad.show(staff)
- class abjad.score.Voice(components=None, *, language: str = 'english', lilypond_type: str = 'Voice', name: str | None = None, simultaneous: bool = False, tag: Tag | None = None)[source]
Voice.
Voice-contexted indicators like dynamics work with nested voices.
>>> voice = abjad.Voice("c'8 d'8 e'8 f'8") >>> abjad.show(voice)
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, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("d''8") Dynamic(name='f', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("c''4") Dynamic(name='f', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("b'4") Dynamic(name='f', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("c''8") Dynamic(name='f', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("e'4") None Note("f'4") None Note("e'8") None Note("d''8") Dynamic(name='f', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None)
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, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("f'4") Dynamic(name='p', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("e'8") Dynamic(name='p', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) 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, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("b'4") Dynamic(name='mf', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("c''8") Dynamic(name='mf', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("e'4") None Note("f'4") None Note("e'8") None Note("d''8") Dynamic(name='mf', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None)
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, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("b'4") Dynamic(name='mf', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("c''8") Dynamic(name='mf', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("e'4") Dynamic(name='p', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("f'4") Dynamic(name='p', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("e'8") Dynamic(name='p', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None) Note("d''8") Dynamic(name='mf', command=None, hide=False, leak=False, name_is_textual=False, ordinal=None)
Gets and sets voice tag.
- overridden tag
Gets and sets voice 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 }