abjad.verticalmoment
Iterates leaf pairs. |
|
Iterates pitch pairs. |
|
Iterates vertical moments. |
|
Vertical moment. |
- abjad.verticalmoment.iterate_leaf_pairs(components) Iterator [source]
Iterates leaf pairs.
Iterates leaf pairs left-to-right and top-to-bottom.
>>> 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')]
- abjad.verticalmoment.iterate_pitch_pairs(components) Iterator[tuple[NamedPitch, NamedPitch]] [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''"))
- abjad.verticalmoment.iterate_vertical_moments(components, *, reverse=False)[source]
Iterates vertical moments.
Returns tuple.
Iterates vertical moments forward:
>>> score = abjad.Score( ... [ ... abjad.Staff(r"\tuplet 3/2 { d''4 c''4 b'4 }"), ... abjad.StaffGroup( ... [ ... abjad.Staff("a'4 g'4"), ... abjad.Staff(r"""\clef "bass" f'8 e'8 d'8 c'8"""), ... ] ... ), ... ] ... ) >>> abjad.show(score)
>>> for vertical_moment in abjad.iterate_vertical_moments(score): ... vertical_moment.leaves ... [Note("d''4"), Note("a'4"), Note("f'8")] [Note("d''4"), Note("a'4"), Note("e'8")] [Note("c''4"), Note("a'4"), Note("e'8")] [Note("c''4"), Note("g'4"), Note("d'8")] [Note("b'4"), Note("g'4"), Note("d'8")] [Note("b'4"), Note("g'4"), Note("c'8")]
>>> staff_group = score[1] >>> 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:
>>> for vmoment in abjad.iterate_vertical_moments(score, reverse=True): ... vmoment.leaves ... [Note("b'4"), Note("g'4"), Note("c'8")] [Note("b'4"), Note("g'4"), Note("d'8")] [Note("c''4"), Note("g'4"), Note("d'8")] [Note("c''4"), Note("a'4"), Note("e'8")] [Note("d''4"), Note("a'4"), Note("e'8")] [Note("d''4"), Note("a'4"), Note("f'8")]
>>> for vmoment in abjad.iterate_vertical_moments(staff_group, reverse=True): ... vmoment.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")]
- 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>>)
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.
- attack_count
Positive integer number of pitch carriers starting at vertical moment.
>>> score = abjad.Score( ... [ ... abjad.Staff(r"\tuplet 3/2 { d''4 c''4 b'4 }"), ... abjad.StaffGroup( ... [ ... abjad.Staff("a'4 g'4"), ... abjad.Staff(r"""\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( ... [ ... abjad.Staff(r"\tuplet 3/2 { d''4 c''4 b'4 }"), ... abjad.StaffGroup( ... [ ... abjad.Staff("a'4 g'4"), ... abjad.Staff(r"""\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''4"), Note("a'4"), Note("f'8")] 1/8 [Note("d''4"), Note("a'4"), Note("e'8")] 1/6 [Note("c''4"), Note("a'4"), Note("e'8")] 1/4 [Note("c''4"), Note("g'4"), Note("d'8")] 1/3 [Note("b'4"), Note("g'4"), Note("d'8")] 3/8 [Note("b'4"), 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.