verticalmoment

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.verticalmoment" { graph [label="abjad.verticalmoment"]; node [color=1]; "abjad.verticalmoment.VerticalMoment" [URL="../api/abjad/verticalmoment.html#abjad.verticalmoment.VerticalMoment", color=black, fontcolor=white, label="Vertical\nMoment", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; } "builtins.object" -> "abjad.verticalmoment.VerticalMoment"; }


Classes

VerticalMoment

Vertical moment.

class abjad.verticalmoment.VerticalMoment(components=None, offset=None)[source]

Vertical moment.

>>> score = abjad.Score()
>>> staff_group = abjad.StaffGroup()
>>> staff_group.lilypond_type = "PianoStaff"
>>> staff_group.append(abjad.Staff("c'4 e'4 d'4 f'4"))
>>> staff_group.append(abjad.Staff(r"""\clef "bass" g2 f2"""))
>>> score.append(staff_group)
>>> abjad.show(score)  
>>> for moment in abjad.iterate_vertical_moments(score):
...     moment
... 
VerticalMoment(0, <<2>>)
VerticalMoment(1/4, <<2>>)
VerticalMoment(1/2, <<2>>)
VerticalMoment(3/4, <<2>>)

Attributes Summary

__eq__

Is true when argument is a vertical moment with the same components as this vertical moment.

__hash__

Hases vertical moment.

__len__

Length of vertical moment.

__repr__

Gets interpreter representation of vertical moment.

attack_count

Positive integer number of pitch carriers starting at vertical moment.

components

Tuple of zero or more components happening at vertical moment.

governors

Tuple of one or more containers in which vertical moment is evaluated.

leaves

Tuple of zero or more leaves at vertical moment.

notes

Tuple of zero or more notes at vertical moment.

notes_and_chords

Tuple of zero or more notes and chords at vertical moment.

offset

Rational-valued score offset at which vertical moment is evaluated.

overlap_components

Tuple of components in vertical moment starting before vertical moment, ordered by score index.

overlap_leaves

Tuple of leaves in vertical moment starting before vertical moment, ordered by score index.

overlap_notes

Tuple of notes in vertical moment starting before vertical moment, ordered by score index.

start_components

Tuple of components in vertical moment starting with at vertical moment, ordered by score index.

start_leaves

Tuple of leaves in vertical moment starting with vertical moment, ordered by score index.

start_notes

Tuple of notes in vertical moment starting with vertical moment, ordered by score index.


Special methods

overridden __eq__(argument)[source]

Is true when argument is a vertical moment with the same components as this vertical moment.

Return type:

bool

overridden __hash__()[source]

Hases vertical moment.

Vertical moments can be hashed:

>>> staff = abjad.Staff("c'8 d'8 e'8 f'8")
>>> vms = []
>>> vms.extend(abjad.iterate_vertical_moments(staff))
>>> vms.extend(abjad.iterate_vertical_moments(staff))
>>> assert len(vms) == 8
>>> assert len(set(vms)) == 4

Redefined in tandem with __eq__.

__len__()[source]

Length of vertical moment.

>>> score = abjad.Score(
...     r"""
...    \new Staff {
...        \times 4/3 {
...            d''8
...            c''8
...            b'8
...        }
...    }
...    \new PianoStaff <<
...        \new Staff {
...            a'4
...            g'4
...        }
...        \new Staff {
...            \clef "bass"
...            f'8
...            e'8
...            d'8
...            c'8
...        }
...    >>
...    """
... )
>>> abjad.show(score)  
>>> for moment in abjad.iterate_vertical_moments(score):
...     print(moment, len(moment))
... 
VerticalMoment(0, <<3>>) 9
VerticalMoment(1/8, <<3>>) 9
VerticalMoment(1/6, <<3>>) 9
VerticalMoment(1/4, <<3>>) 9
VerticalMoment(1/3, <<3>>) 9
VerticalMoment(3/8, <<3>>) 9

Defined equal to the number of components in vertical moment.

Returns nonnegative integer.

overridden __repr__()[source]

Gets interpreter representation of vertical moment.

Returns string.


Read-only properties

attack_count

Positive integer number of pitch carriers starting at vertical moment.

>>> score = abjad.Score(
...     r"""
...    \new Staff {
...        \times 4/3 {
...            d''8
...            c''8
...            b'8
...        }
...    }
...    \new PianoStaff <<
...        \new Staff {
...            a'4
...            g'4
...        }
...        \new Staff {
...            \clef "bass"
...            f'8
...            e'8
...            d'8
...            c'8
...        }
...    >>
...    """
... )
>>> abjad.show(score)  
>>> for moment in abjad.iterate_vertical_moments(score):
...     print(moment, moment.attack_count)
... 
VerticalMoment(0, <<3>>) 3
VerticalMoment(1/8, <<3>>) 1
VerticalMoment(1/6, <<3>>) 1
VerticalMoment(1/4, <<3>>) 2
VerticalMoment(1/3, <<3>>) 1
VerticalMoment(3/8, <<3>>) 1
components

Tuple of zero or more components happening at vertical moment.

It is always the case that self.components = self.overlap_components + self.start_components.

governors

Tuple of one or more containers in which vertical moment is evaluated.

leaves

Tuple of zero or more leaves at vertical moment.

>>> score = abjad.Score(
...     r"""
...    \new Staff {
...        \times 4/3 {
...            d''8
...            c''8
...            b'8
...        }
...    }
...    \new PianoStaff <<
...        \new Staff {
...            a'4
...            g'4
...        }
...        \new Staff {
...            \clef "bass"
...            f'8
...            e'8
...            d'8
...            c'8
...        }
...    >>
...    """
... )
>>> abjad.show(score)  
>>> for moment in abjad.iterate_vertical_moments(score):
...     print(moment.offset, moment.leaves)
... 
0 [Note("d''8"), Note("a'4"), Note("f'8")]
1/8 [Note("d''8"), Note("a'4"), Note("e'8")]
1/6 [Note("c''8"), Note("a'4"), Note("e'8")]
1/4 [Note("c''8"), Note("g'4"), Note("d'8")]
1/3 [Note("b'8"), Note("g'4"), Note("d'8")]
3/8 [Note("b'8"), Note("g'4"), Note("c'8")]
notes

Tuple of zero or more notes at vertical moment.

notes_and_chords

Tuple of zero or more notes and chords at vertical moment.

offset

Rational-valued score offset at which vertical moment is evaluated.

overlap_components

Tuple of components in vertical moment starting before vertical moment, ordered by score index.

overlap_leaves

Tuple of leaves in vertical moment starting before vertical moment, ordered by score index.

overlap_notes

Tuple of notes in vertical moment starting before vertical moment, ordered by score index.

start_components

Tuple of components in vertical moment starting with at vertical moment, ordered by score index.

start_leaves

Tuple of leaves in vertical moment starting with vertical moment, ordered by score index.

start_notes

Tuple of notes in vertical moment starting with vertical moment, ordered by score index.


Functions

iterate_leaf_pairs

Iterates leaf pairs.

iterate_pitch_pairs

Iterates pitch pairs.

iterate_vertical_moments

Iterates vertical moments.

abjad.verticalmoment.iterate_leaf_pairs(components)[source]

Iterates leaf pairs.

>>> score = abjad.Score()
>>> score.append(abjad.Staff("c'8 d'8 e'8 f'8 g'4"))
>>> score.append(abjad.Staff("c4 a,4 g,4"))
>>> abjad.attach(abjad.Clef("bass"), score[1][0])
>>> abjad.show(score)  
>>> for leaf_pair in abjad.iterate_leaf_pairs(score):
...     leaf_pair
... 
[Note("c'8"), Note('c4')]
[Note("c'8"), Note("d'8")]
[Note('c4'), Note("d'8")]
[Note("d'8"), Note("e'8")]
[Note("d'8"), Note('a,4')]
[Note('c4'), Note("e'8")]
[Note('c4'), Note('a,4')]
[Note("e'8"), Note('a,4')]
[Note("e'8"), Note("f'8")]
[Note('a,4'), Note("f'8")]
[Note("f'8"), Note("g'4")]
[Note("f'8"), Note('g,4')]
[Note('a,4'), Note("g'4")]
[Note('a,4'), Note('g,4')]
[Note("g'4"), Note('g,4')]

Iterates leaf pairs left-to-right and top-to-bottom.

Returns generator.

abjad.verticalmoment.iterate_pitch_pairs(components)[source]

Iterates pitch pairs.

Iterates note pitch pairs:

>>> score = abjad.Score()
>>> score.append(abjad.Staff("c'8 d' e' f' g'4"))
>>> score.append(abjad.Staff("c4 a, g,"))
>>> abjad.attach(abjad.Clef("bass"), score[1][0])
>>> abjad.show(score)  
>>> for pair in abjad.iterate_pitch_pairs(score):
...     pair
... 
(NamedPitch("c'"), NamedPitch('c'))
(NamedPitch("c'"), NamedPitch("d'"))
(NamedPitch('c'), NamedPitch("d'"))
(NamedPitch("d'"), NamedPitch("e'"))
(NamedPitch("d'"), NamedPitch('a,'))
(NamedPitch('c'), NamedPitch("e'"))
(NamedPitch('c'), NamedPitch('a,'))
(NamedPitch("e'"), NamedPitch('a,'))
(NamedPitch("e'"), NamedPitch("f'"))
(NamedPitch('a,'), NamedPitch("f'"))
(NamedPitch("f'"), NamedPitch("g'"))
(NamedPitch("f'"), NamedPitch('g,'))
(NamedPitch('a,'), NamedPitch("g'"))
(NamedPitch('a,'), NamedPitch('g,'))
(NamedPitch("g'"), NamedPitch('g,'))

Iterates chord pitch pairs:

>>> staff = abjad.Staff("<c' d' e'>4 <f'' g''>4")
>>> for pair in abjad.iterate_pitch_pairs(staff):
...     pair
... 
(NamedPitch("c'"), NamedPitch("d'"))
(NamedPitch("c'"), NamedPitch("e'"))
(NamedPitch("d'"), NamedPitch("e'"))
(NamedPitch("c'"), NamedPitch("f''"))
(NamedPitch("c'"), NamedPitch("g''"))
(NamedPitch("d'"), NamedPitch("f''"))
(NamedPitch("d'"), NamedPitch("g''"))
(NamedPitch("e'"), NamedPitch("f''"))
(NamedPitch("e'"), NamedPitch("g''"))
(NamedPitch("f''"), NamedPitch("g''"))

Returns generator.

abjad.verticalmoment.iterate_vertical_moments(components, reverse=None)[source]

Iterates vertical moments.

Iterates vertical moments:

>>> score = abjad.Score([])
>>> staff = abjad.Staff(r"\times 4/3 { d''8 c''8 b'8 }")
>>> score.append(staff)
>>> staff_group = abjad.StaffGroup([])
>>> staff_group.lilypond_type = "PianoStaff"
>>> staff_group.append(abjad.Staff("a'4 g'4"))
>>> staff_group.append(abjad.Staff(r"""\clef "bass" f'8 e'8 d'8 c'8"""))
>>> score.append(staff_group)
>>> abjad.show(score)  
>>> for vertical_moment in abjad.iterate_vertical_moments(score):
...     vertical_moment.leaves
... 
[Note("d''8"), Note("a'4"), Note("f'8")]
[Note("d''8"), Note("a'4"), Note("e'8")]
[Note("c''8"), Note("a'4"), Note("e'8")]
[Note("c''8"), Note("g'4"), Note("d'8")]
[Note("b'8"), Note("g'4"), Note("d'8")]
[Note("b'8"), Note("g'4"), Note("c'8")]
>>> for vertical_moment in abjad.iterate_vertical_moments(staff_group):
...     vertical_moment.leaves
... 
[Note("a'4"), Note("f'8")]
[Note("a'4"), Note("e'8")]
[Note("g'4"), Note("d'8")]
[Note("g'4"), Note("c'8")]

Iterates vertical moments in reverse:

>>> score = abjad.Score([])
>>> staff = abjad.Staff(r"\times 4/3 { d''8 c''8 b'8 }")
>>> score.append(staff)
>>> staff_group = abjad.StaffGroup([])
>>> staff_group.lilypond_type = "PianoStaff"
>>> staff_group.append(abjad.Staff("a'4 g'4"))
>>> staff_group.append(abjad.Staff(r"""\clef "bass" f'8 e'8 d'8 c'8"""))
>>> score.append(staff_group)
>>> abjad.show(score)  
>>> for vertical_moment in abjad.iterate_vertical_moments(score, reverse=True):
...     vertical_moment.leaves
... 
[Note("b'8"), Note("g'4"), Note("c'8")]
[Note("b'8"), Note("g'4"), Note("d'8")]
[Note("c''8"), Note("g'4"), Note("d'8")]
[Note("c''8"), Note("a'4"), Note("e'8")]
[Note("d''8"), Note("a'4"), Note("e'8")]
[Note("d''8"), Note("a'4"), Note("f'8")]
>>> for vertical_moment in abjad.iterate_vertical_moments(
...     staff_group,
...     reverse=True,
... ):
...     vertical_moment.leaves
... 
[Note("g'4"), Note("c'8")]
[Note("g'4"), Note("d'8")]
[Note("a'4"), Note("e'8")]
[Note("a'4"), Note("f'8")]

Returns tuple.