iterate_named_pitch_pairs_in_expr

pitchtools.iterate_named_pitch_pairs_in_expr(expr)

Iterates left-to-right, top-to-bottom named pitch pairs in expr.

>>> score = Score([])
>>> notes = [Note("c'8"), Note("d'8"), Note("e'8"), Note("f'8"), Note("g'4")]
>>> score.append(Staff(notes))
>>> notes = [Note(x, (1, 4)) for x in [-12, -15, -17]]
>>> score.append(Staff(notes))
>>> clef = Clef('bass')
>>> attach(clef, score[1])
>>> show(score) 
>>> for pair in pitchtools.iterate_named_pitch_pairs_in_expr(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,'))

Chords are handled correctly.

>>> chord_1 = Chord([0, 2, 4], (1, 4))
>>> chord_2 = Chord([17, 19], (1, 4))
>>> staff = Staff([chord_1, chord_2])
>>> for pair in pitchtools.iterate_named_pitch_pairs_in_expr(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.