verticalmoment¶
Classes
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
Is true when
argument
is a vertical moment with the same components as this vertical moment.Hases vertical moment.
Length of vertical moment.
Gets interpreter representation of vertical moment.
Positive integer number of pitch carriers starting at vertical moment.
Tuple of zero or more components happening at vertical moment.
Tuple of one or more containers in which vertical moment is evaluated.
Tuple of zero or more leaves at vertical moment.
Tuple of zero or more notes at vertical moment.
Tuple of zero or more notes and chords at vertical moment.
Rational-valued score offset at which vertical moment is evaluated.
Tuple of components in vertical moment starting before vertical moment, ordered by score index.
Tuple of leaves in vertical moment starting before vertical moment, ordered by score index.
Tuple of notes in vertical moment starting before vertical moment, ordered by score index.
Tuple of components in vertical moment starting with at vertical moment, ordered by score index.
Tuple of leaves in vertical moment starting with vertical moment, ordered by score index.
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:
- 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.
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
Iterates leaf pairs. |
|
Iterates pitch pairs. |
|
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.