LogicalTie¶
-
class
abjad.core.LogicalTie.
LogicalTie
(items=None)¶ Logical tie of a component.
>>> staff = abjad.Staff("c' d' e' ~ e'") >>> abjad.show(staff)
>>> abjad.inspect(staff[2]).logical_tie() LogicalTie([Note("e'4"), Note("e'4")])
Attributes Summary
__getitem__
Gets argument
.head
Reference to element 0
in logical tie.is_pitched
Is true when logical tie head is a note or chord. is_trivial
Is true when length of logical tie is less than or equal to 1
.leaves
Gets leaves in logical tie. tail
Gets last leaf in logical tie. tie
Gets tie spanner governing logical tie. to_tuplet
Changes logical tie to tuplet. written_duration
Sum of written duration of all components in logical tie. Special methods
-
(
AbjadValueObject
).__copy__
(*arguments)¶ Copies Abjad value object.
Returns new Abjad value object.
-
__getitem__
(argument)¶ Gets
argument
.Returns component or vanilla selection (not logical tie).
-
(
Selection
).__illustrate__
()¶ Attempts to illustrate selection.
Evaluates the storage format of the selection (to sever any references to the source score from which the selection was taken). Then tries to wrap the result in a staff; in the case that notes of only C4 are found then sets the staff context name to
'RhythmicStaff'
. If this works then the staff is wrapped in a LilyPond file and the file is returned. If this doesn’t work then the method raises an exception.The idea is that the illustration should work for simple selections of that represent an essentially contiguous snippet of a single voice of music.
Returns LilyPond file.
Methods
-
(
Selection
).are_contiguous_logical_voice
(prototype=None, allow_orphans=True)¶ Is true when items in selection are contiguous components in the same logical voice.
>>> staff = abjad.Staff("c'4 d'4 e'4 f'4") >>> staff[:].are_contiguous_logical_voice() True
>>> selection = staff[:1] + staff[-1:] >>> selection.are_contiguous_logical_voice() False
Returns true or false.
-
(
Selection
).are_contiguous_same_parent
(prototype=None, allow_orphans=True)¶ Is true when items in selection are all contiguous components in the same parent.
>>> staff = abjad.Staff("c'4 d'4 e'4 f'4") >>> staff[:].are_contiguous_same_parent() True
>>> selection = staff[:1] + staff[-1:] >>> selection.are_contiguous_same_parent() False
Returns true or false.
-
(
Selection
).are_logical_voice
(prototype=None, allow_orphans=True)¶ Is true when items in selection are all components in the same logical voice.
>>> staff = abjad.Staff("c'4 d'4 e'4 f'4") >>> staff[:].are_logical_voice() True
>>> selection = staff[:1] + staff[-1:] >>> selection.are_logical_voice() True
Returns true or false.
-
(
Selection
).chord
(n)¶ Selects chord
n
.Selects chord -1:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).chord(-1)
>>> result Chord("<fs' gs'>16")
-
(
Selection
).chords
()¶ Selects chords.
Selects chords:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).chords()
>>> for item in result: ... item ... Chord("<a'' b''>16") Chord("<d' e'>4") Chord("<d' e'>16") Chord("<a'' b''>16") Chord("<e' fs'>4") Chord("<e' fs'>16") Chord("<a'' b''>16") Chord("<fs' gs'>4") Chord("<fs' gs'>16")
>>> selector = abjad.select().chords() >>> result = selector(staff)
>>> selector.print(result) Chord("<a'' b''>16") Chord("<d' e'>4") Chord("<d' e'>16") Chord("<a'' b''>16") Chord("<e' fs'>4") Chord("<e' fs'>16") Chord("<a'' b''>16") Chord("<fs' gs'>4") Chord("<fs' gs'>16")
>>> selector.color(result) >>> abjad.show(lilypond_file)
-
(
Selection
).filter
(predicate=None)¶ Filters selection by
predicate
.Selects runs with duration equal to 2/8:
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> inequality = abjad.DurationInequality('==', (2, 8)) >>> result = abjad.select(staff).runs().filter(inequality)
>>> for item in result: ... item ... Selection([Note("d'8"), Note("e'8")])
Returns new selection (or expression).
-
(
Selection
).filter_duration
(operator, duration)¶ Filters selection by
operator
andduration
.Selects runs with duration equal to 2/8:
Selects runs with duration less than 3/8:
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).runs() >>> result = result.filter_duration('<', (3, 8))
>>> for item in result: ... item ... Selection([Note("c'8")]) Selection([Note("d'8"), Note("e'8")])
Returns new selection (or expression).
-
(
Selection
).filter_length
(operator, length)¶ Filters selection by
operator
andlength
.Selects notes runs with length greater than 1:
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).runs().filter_length('>', 1)
>>> for item in result: ... item ... Selection([Note("d'8"), Note("e'8")]) Selection([Note("f'8"), Note("g'8"), Note("a'8")])
Selects runs with length less than 3:
-
(
Selection
).filter_pitches
(operator, pitches)¶ Filters selection by
operator
andpitches
.Selects leaves with pitches intersecting C4:
>>> staff = abjad.Staff("c'8 d'8 ~ d'8 e'8") >>> abjad.setting(staff).auto_beaming = False >>> staff.extend("r8 <c' e' g'>8 ~ <c' e' g'>4") >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.filter_pitches('&', 'C4')
>>> for item in result: ... item ... Note("c'8") Chord("<c' e' g'>8") Chord("<c' e' g'>4")
Selects leaves with pitches intersecting C4 or E4:
>>> staff = abjad.Staff("c'8 d'8 ~ d'8 e'8") >>> abjad.setting(staff).auto_beaming = False >>> staff.extend("r8 <c' e' g'>8 ~ <c' e' g'>4") >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.filter_pitches('&', 'C4 E4')
>>> for item in result: ... item ... Note("c'8") Note("e'8") Chord("<c' e' g'>8") Chord("<c' e' g'>4")
Selects logical ties with pitches intersecting C4:
>>> staff = abjad.Staff("c'8 d'8 ~ d'8 e'8") >>> abjad.setting(staff).auto_beaming = False >>> staff.extend("r8 <c' e' g'>8 ~ <c' e' g'>4") >>> abjad.show(staff)
>>> result = abjad.select(staff).logical_ties() >>> result = result.filter_pitches('&', 'C4')
>>> for item in result: ... item ... LogicalTie([Note("c'8")]) LogicalTie([Chord("<c' e' g'>8"), Chord("<c' e' g'>4")])
Returns new selection (or expression).
-
(
Selection
).filter_preprolated
(operator, duration)¶ Filters selection by
operator
and preprolatedduration
.Selects runs with duration equal to 2/8:
Selects runs with duration less than 3/8:
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).runs() >>> result = result.filter_preprolated('<', (3, 8))
>>> for item in result: ... item ... Selection([Note("c'8")]) Selection([Note("d'8"), Note("e'8")])
Returns new selection (or expression).
-
(
Selection
).flatten
(depth=1)¶ Flattens selection to
depth
.Selects first two leaves of each tuplet:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> getter = abjad.select().leaves()[:2] >>> result = abjad.select(staff).tuplets().map(getter)
>>> for item in result: ... item ... Selection([Rest('r16'), Note("bf'16")]) Selection([Rest('r16'), Note("bf'16")]) Selection([Rest('r16'), Note("bf'16")])
Selects first two leaves of all tuplets:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> getter = abjad.select().leaves()[:2] >>> result = abjad.select(staff).tuplets().map(getter) >>> result = result.flatten()
>>> for item in result: ... item ... Rest('r16') Note("bf'16") Rest('r16') Note("bf'16") Rest('r16') Note("bf'16")
Returns new selection (or expression).
-
(
Selection
).group
()¶ Groups selection.
>>> staff = abjad.Staff(r''' ... c'8 ~ c'16 c'16 r8 c'16 c'16 ... d'8 ~ d'16 d'16 r8 d'16 d'16 ... ''') >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff, strict=89)
>>> result = abjad.select(staff).leaves(pitched=True).group()
>>> for item in result: ... item ... Selection([Note("c'8"), Note("c'16"), Note("c'16"), Note("c'16"), Note("c'16"), Note("d'8"), Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")])
>>> selector = abjad.select().leaves(pitched=True).group() >>> result = selector(staff)
>>> selector.print(result) Selection([Selection([Note("c'8"), Note("c'16"), Note("c'16"), Note("c'16"), Note("c'16"), Note("d'8"), Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")])])
>>> selector.color(result) >>> abjad.show(staff, strict=89)
Returns nested selection (or expression).
-
(
Selection
).group_by
(predicate=None)¶ Groups items in selection by
predicate
.Wraps selection in selection when
predicate
is none:>>> staff = abjad.Staff(r""" ... c'8 ~ c'16 c'16 r8 c'16 c'16 ... d'8 ~ d'16 d'16 r8 d'16 d'16 ... """) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves(pitched=True) >>> result = result.group_by()
>>> for item in result: ... item ... Selection([Note("c'8"), Note("c'16"), Note("c'16"), Note("c'16"), Note("c'16"), Note("d'8"), Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")])
>>> selector = abjad.select().leaves(pitched=True).group_by() >>> result = selector(staff)
>>> selector.print(result) Selection([Selection([Note("c'8"), Note("c'16"), Note("c'16"), Note("c'16"), Note("c'16"), Note("d'8"), Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")])])
>>> selector.color(result) >>> abjad.show(staff)
Returns nested selection (or expression).
-
(
Selection
).group_by_contiguity
()¶ Groups items in selection by contiguity.
Groups pitched leaves by contiguity:
>>> string = r"c'8 d' r \times 2/3 { e' r f' } g' a' r" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).auto_beaming = False >>> staff.extend("r8 <c' e' g'>8 ~ <c' e' g'>4") >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves(pitched=True) >>> result = result.group_by_contiguity()
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8")]) Selection([Note("e'8")]) Selection([Note("f'8"), Note("g'8"), Note("a'8")]) Selection([Chord("<c' e' g'>8"), Chord("<c' e' g'>4")])
>>> selector = abjad.select().leaves(pitched=True) >>> selector = selector.group_by_contiguity() >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("d'8")]) Selection([Note("e'8")]) Selection([Note("f'8"), Note("g'8"), Note("a'8")]) Selection([Chord("<c' e' g'>8"), Chord("<c' e' g'>4")])
>>> selector.color(result) >>> abjad.show(staff)
Groups sixteenths by contiguity:
>>> staff = abjad.Staff("c'4 d'16 d' d' d' e'4 f'16 f' f' f'") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.filter_duration('==', (1, 16)) >>> result = result.group_by_contiguity()
>>> for item in result: ... item ... Selection([Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")]) Selection([Note("f'16"), Note("f'16"), Note("f'16"), Note("f'16")])
>>> selector = abjad.select().leaves() >>> selector = selector.filter_duration('==', (1, 16)) >>> selector = selector.group_by_contiguity() >>> result = selector(staff)
>>> selector.print(result) Selection([Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")]) Selection([Note("f'16"), Note("f'16"), Note("f'16"), Note("f'16")])
>>> selector.color(result) >>> abjad.show(staff)
Groups short-duration logical ties by contiguity; then gets leaf 0 in each group:
>>> staff = abjad.Staff("c'4 d'8 ~ d'16 e'16 ~ e'8 f'4 g'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).logical_ties() >>> result = result.filter_duration('<', (1, 4)) >>> result = result.group_by_contiguity() >>> result = result.map(abjad.select().leaves()[0])
>>> for item in result: ... item ... Note("d'8") Note("g'8")
>>> selector = abjad.select().logical_ties() >>> selector = selector.filter_duration('<', (1, 4)) >>> selector = selector.group_by_contiguity() >>> selector = selector.map(abjad.select().leaves()[0]) >>> result = selector(staff)
>>> selector.print(result) Note("d'8") Note("g'8")
>>> selector.color(result) >>> abjad.show(staff)
Groups pitched leaves pitch; then regroups each group by contiguity:
>>> staff = abjad.Staff(r""" ... c'8 ~ c'16 c'16 r8 c'16 c'16 ... d'8 ~ d'16 d'16 r8 d'16 d'16 ... """) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves(pitched=True) >>> result = result.group_by_pitch() >>> result = result.map(abjad.select().group_by_contiguity()) >>> result = result.flatten()
>>> for item in result: ... item ... Selection([Note("c'8"), Note("c'16"), Note("c'16")]) Selection([Note("c'16"), Note("c'16")]) Selection([Note("d'8"), Note("d'16"), Note("d'16")]) Selection([Note("d'16"), Note("d'16")])
>>> selector = abjad.select().leaves(pitched=True) >>> selector = selector.group_by_pitch() >>> selector = selector.map( ... abjad.select().group_by_contiguity() ... ) >>> selector = selector.flatten() >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("c'16"), Note("c'16")]) Selection([Note("c'16"), Note("c'16")]) Selection([Note("d'8"), Note("d'16"), Note("d'16")]) Selection([Note("d'16"), Note("d'16")])
>>> selector.color(result) >>> abjad.show(staff)
Groups pitched logical ties by contiguity; then regroups each group by pitch:
>>> staff = abjad.Staff(r""" ... c'8 ~ c'16 c'16 r8 c'16 c'16 ... d'8 ~ d'16 d'16 r8 d'16 d'16 ... """) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> getter = abjad.select().group_by_pitch()
>>> result = abjad.select(staff).logical_ties(pitched=True) >>> result = result.group_by_contiguity() >>> result = result.map(getter).flatten()
>>> for item in result: ... item ... Selection([LogicalTie([Note("c'8"), Note("c'16")]), LogicalTie([Note("c'16")])]) Selection([LogicalTie([Note("c'16")]), LogicalTie([Note("c'16")])]) Selection([LogicalTie([Note("d'8"), Note("d'16")]), LogicalTie([Note("d'16")])]) Selection([LogicalTie([Note("d'16")]), LogicalTie([Note("d'16")])])
>>> selector = abjad.select().logical_ties(pitched=True) >>> selector = selector.group_by_contiguity() >>> selector = selector.map(getter).flatten() >>> result = selector(staff)
>>> selector.print(result) Selection([LogicalTie([Note("c'8"), Note("c'16")]), LogicalTie([Note("c'16")])]) Selection([LogicalTie([Note("c'16")]), LogicalTie([Note("c'16")])]) Selection([LogicalTie([Note("d'8"), Note("d'16")]), LogicalTie([Note("d'16")])]) Selection([LogicalTie([Note("d'16")]), LogicalTie([Note("d'16")])])
>>> selector.color(result) >>> abjad.show(staff)
Returns new selection (or expression).
-
(
Selection
).group_by_duration
()¶ Groups items in selection by duration.
Groups logical ties by duration:
>>> string = "c'4 ~ c'16 d' ~ d' d' e'4 ~ e'16 f' ~ f' f'" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).logical_ties() >>> result = result.group_by_duration()
>>> for item in result: ... item ... Selection([LogicalTie([Note("c'4"), Note("c'16")])]) Selection([LogicalTie([Note("d'16"), Note("d'16")])]) Selection([LogicalTie([Note("d'16")])]) Selection([LogicalTie([Note("e'4"), Note("e'16")])]) Selection([LogicalTie([Note("f'16"), Note("f'16")])]) Selection([LogicalTie([Note("f'16")])])
>>> selector = abjad.select().logical_ties().group_by_duration() >>> result = selector(staff)
>>> selector.print(result) Selection([LogicalTie([Note("c'4"), Note("c'16")])]) Selection([LogicalTie([Note("d'16"), Note("d'16")])]) Selection([LogicalTie([Note("d'16")])]) Selection([LogicalTie([Note("e'4"), Note("e'16")])]) Selection([LogicalTie([Note("f'16"), Note("f'16")])]) Selection([LogicalTie([Note("f'16")])])
>>> selector.color(result) >>> abjad.show(staff)
Returns nested selection (or expression).
-
(
Selection
).group_by_length
()¶ Groups items in selection by length.
Groups logical ties by length:
>>> string = "c'4 ~ c'16 d' ~ d' d' e'4 ~ e'16 f' ~ f' f'" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).logical_ties().group_by_length()
>>> for item in result: ... item ... Selection([LogicalTie([Note("c'4"), Note("c'16")]), LogicalTie([Note("d'16"), Note("d'16")])]) Selection([LogicalTie([Note("d'16")])]) Selection([LogicalTie([Note("e'4"), Note("e'16")]), LogicalTie([Note("f'16"), Note("f'16")])]) Selection([LogicalTie([Note("f'16")])])
>>> selector = abjad.select().logical_ties().group_by_length() >>> result = selector(staff)
>>> selector.print(result) Selection([LogicalTie([Note("c'4"), Note("c'16")]), LogicalTie([Note("d'16"), Note("d'16")])]) Selection([LogicalTie([Note("d'16")])]) Selection([LogicalTie([Note("e'4"), Note("e'16")]), LogicalTie([Note("f'16"), Note("f'16")])]) Selection([LogicalTie([Note("f'16")])])
>>> selector.color(result) >>> abjad.show(staff)
Returns nested selection (or expression).
-
(
Selection
).group_by_measure
()¶ Groups items in selection by measure.
Groups leaves by logical measure:
>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''") >>> abjad.setting(staff).auto_beaming = False >>> abjad.attach(abjad.TimeSignature((2, 8)), staff[0]) >>> abjad.attach(abjad.TimeSignature((3, 8)), staff[4]) >>> abjad.attach(abjad.TimeSignature((1, 8)), staff[7]) >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.group_by_measure()
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8")]) Selection([Note("e'8"), Note("f'8")]) Selection([Note("g'8"), Note("a'8"), Note("b'8")]) Selection([Note("c''8")])
>>> selector = abjad.select().leaves() >>> selector = selector.group_by_measure() >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("d'8")]) Selection([Note("e'8"), Note("f'8")]) Selection([Note("g'8"), Note("a'8"), Note("b'8")]) Selection([Note("c''8")])
>>> selector.color(result) >>> abjad.show(staff)
Groups leaves by logical measure and joins pairs of consecutive groups:
>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''") >>> abjad.setting(staff).auto_beaming = False >>> abjad.attach(abjad.TimeSignature((2, 8)), staff[0]) >>> abjad.attach(abjad.TimeSignature((3, 8)), staff[4]) >>> abjad.attach(abjad.TimeSignature((1, 8)), staff[7]) >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.group_by_measure() >>> result = result.partition_by_counts([2], cyclic=True) >>> result = result.map(abjad.select().flatten())
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8"), Note("e'8"), Note("f'8")]) Selection([Note("g'8"), Note("a'8"), Note("b'8"), Note("c''8")])
>>> selector = abjad.select().leaves() >>> selector = selector.group_by_measure() >>> selector = selector.partition_by_counts([2], cyclic=True) >>> selector = selector.map(abjad.select().flatten()) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("d'8"), Note("e'8"), Note("f'8")]) Selection([Note("g'8"), Note("a'8"), Note("b'8"), Note("c''8")])
>>> selector.color(result) >>> abjad.show(staff)
Groups leaves by logical measure; then gets item 0 in each group:
>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''") >>> abjad.setting(staff).auto_beaming = False >>> abjad.attach(abjad.TimeSignature((2, 8)), staff[0]) >>> abjad.attach(abjad.TimeSignature((3, 8)), staff[4]) >>> abjad.attach(abjad.TimeSignature((1, 8)), staff[7]) >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.group_by_measure() >>> result = result.map(abjad.select()[0])
>>> for item in result: ... item ... Note("c'8") Note("e'8") Note("g'8") Note("c''8")
Groups leaves by logical measure; then gets item -1 in each group:
>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''") >>> abjad.setting(staff).auto_beaming = False >>> abjad.attach(abjad.TimeSignature((2, 8)), staff[0]) >>> abjad.attach(abjad.TimeSignature((3, 8)), staff[4]) >>> abjad.attach(abjad.TimeSignature((1, 8)), staff[7]) >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.group_by_measure() >>> result = result.map(abjad.select()[-1])
>>> for item in result: ... item ... Note("d'8") Note("f'8") Note("b'8") Note("c''8")
Works with implicit time signatures:
>>> staff = abjad.Staff("c'4 d' e' f' g' a' b' c''") >>> abjad.setting(staff).auto_beaming = False >>> score = abjad.Score([staff]) >>> scheme = abjad.SchemeMoment((1, 16)) >>> abjad.setting(score).proportional_notation_duration = scheme >>> abjad.show(score)
>>> result = abjad.select(score).leaves() >>> result = result.group_by_measure()
>>> for item in result: ... item ... Selection([Note("c'4"), Note("d'4"), Note("e'4"), Note("f'4")]) Selection([Note("g'4"), Note("a'4"), Note("b'4"), Note("c''4")])
>>> selector = abjad.select().leaves() >>> selector = selector.group_by_measure() >>> result = selector(score)
>>> selector.print(result) Selection([Note("c'4"), Note("d'4"), Note("e'4"), Note("f'4")]) Selection([Note("g'4"), Note("a'4"), Note("b'4"), Note("c''4")])
>>> selector.color(result) >>> abjad.show(staff)
Returns new selection (or expression).
-
(
Selection
).group_by_pitch
()¶ Groups items in selection by pitches.
Groups logical ties by pitches:
>>> string = "c'4 ~ c'16 d' ~ d' d' e'4 ~ e'16 f' ~ f' f'" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).logical_ties().group_by_pitch()
>>> for item in result: ... item ... Selection([LogicalTie([Note("c'4"), Note("c'16")])]) Selection([LogicalTie([Note("d'16"), Note("d'16")]), LogicalTie([Note("d'16")])]) Selection([LogicalTie([Note("e'4"), Note("e'16")])]) Selection([LogicalTie([Note("f'16"), Note("f'16")]), LogicalTie([Note("f'16")])])
>>> selector = abjad.select().logical_ties().group_by_pitch() >>> result = selector(staff)
>>> selector.print(result) Selection([LogicalTie([Note("c'4"), Note("c'16")])]) Selection([LogicalTie([Note("d'16"), Note("d'16")]), LogicalTie([Note("d'16")])]) Selection([LogicalTie([Note("e'4"), Note("e'16")])]) Selection([LogicalTie([Note("f'16"), Note("f'16")]), LogicalTie([Note("f'16")])])
>>> selector.color(result) >>> abjad.show(staff)
Returns nested selection (or expression).
-
(
Selection
).leaf
(n)¶ Selects leaf
n
.Selects leaf -1:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).leaf(-1)
>>> result Chord("<fs' gs'>16")
-
(
Selection
).logical_ties
(grace_notes=False, nontrivial=None, pitched=None, reverse=False)¶ Selects logical ties (without grace notes).
Selects logical ties:
>>> staff = abjad.Staff("c'8 d' ~ { d' e' r f'~ } f' r") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).logical_ties()
>>> for item in result: ... item ... LogicalTie([Note("c'8")]) LogicalTie([Note("d'8"), Note("d'8")]) LogicalTie([Note("e'8")]) LogicalTie([Rest('r8')]) LogicalTie([Note("f'8"), Note("f'8")]) LogicalTie([Rest('r8')])
>>> selector = abjad.select().logical_ties() >>> result = selector(staff)
>>> selector.print(result) LogicalTie([Note("c'8")]) LogicalTie([Note("d'8"), Note("d'8")]) LogicalTie([Note("e'8")]) LogicalTie([Rest('r8')]) LogicalTie([Note("f'8"), Note("f'8")]) LogicalTie([Rest('r8')])
>>> selector.color(result) >>> abjad.show(staff)
Selects pitched logical ties:
>>> staff = abjad.Staff("c'8 d' ~ { d' e' r f'~ } f' r") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).logical_ties(pitched=True)
>>> for item in result: ... item ... LogicalTie([Note("c'8")]) LogicalTie([Note("d'8"), Note("d'8")]) LogicalTie([Note("e'8")]) LogicalTie([Note("f'8"), Note("f'8")])
Selects pitched nontrivial logical ties:
>>> staff = abjad.Staff("c'8 d' ~ { d' e' r f'~ } f' r") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).logical_ties( ... pitched=True, ... nontrivial=True, ... )
>>> for item in result: ... item ... LogicalTie([Note("d'8"), Note("d'8")]) LogicalTie([Note("f'8"), Note("f'8")])
Selects pitched logical ties (starting) in each tuplet:
>>> staff = abjad.Staff(r""" ... \times 2/3 { c'8 d' e' ~ } e' f' ~ ... \times 2/3 { f' g' a' ~ } a' b' ~ ... \times 2/3 { b' c'' d'' } ... """) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> getter = abjad.select().logical_ties(pitched=True) >>> result = abjad.select(staff).components(abjad.Tuplet) >>> result = result.map(getter)
>>> for item in result: ... item ... Selection([LogicalTie([Note("c'8")]), LogicalTie([Note("d'8")]), LogicalTie([Note("e'8"), Note("e'8")])]) Selection([LogicalTie([Note("g'8")]), LogicalTie([Note("a'8"), Note("a'8")])]) Selection([LogicalTie([Note("c''8")]), LogicalTie([Note("d''8")])])
>>> selector = abjad.select().components(abjad.Tuplet) >>> selector = selector.map(getter) >>> result = selector(staff)
>>> selector.print(result) Selection([LogicalTie([Note("c'8")]), LogicalTie([Note("d'8")]), LogicalTie([Note("e'8"), Note("e'8")])]) Selection([LogicalTie([Note("g'8")]), LogicalTie([Note("a'8"), Note("a'8")])]) Selection([LogicalTie([Note("c''8")]), LogicalTie([Note("d''8")])])
>>> selector.color(result) >>> abjad.show(staff)
Selects pitched logical ties (starting) in each of the last two tuplets:
>>> staff = abjad.Staff(r""" ... \times 2/3 { c'8 d' e' ~ } e' f' ~ ... \times 2/3 { f' g' a' ~ } a' b' ~ ... \times 2/3 { b' c'' d'' } ... """) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> getter = abjad.select().logical_ties(pitched=True) >>> result = abjad.select(staff).components(abjad.Tuplet)[-2:] >>> result = result.map(getter)
>>> for item in result: ... item ... Selection([LogicalTie([Note("g'8")]), LogicalTie([Note("a'8"), Note("a'8")])]) Selection([LogicalTie([Note("c''8")]), LogicalTie([Note("d''8")])])
>>> selector = abjad.select().components(abjad.Tuplet)[-2:] >>> selector = selector.map(getter) >>> result = selector(staff)
>>> selector.print(result) Selection([LogicalTie([Note("g'8")]), LogicalTie([Note("a'8"), Note("a'8")])]) Selection([LogicalTie([Note("c''8")]), LogicalTie([Note("d''8")])])
>>> selector.color(result) >>> abjad.show(staff)
Returns new selection (or expression).
-
(
Selection
).map
(expression=None)¶ Maps
expression
to items in selection.Selects each tuplet as a separate selection:
>>> staff = abjad.Staff(r""" ... \times 2/3 { r8 d' e' } f' r ... r f' \times 2/3 { e' d' r8 } ... """) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).components(abjad.Tuplet) >>> result = result.map(abjad.select())
>>> for item in result: ... item ... Selection([Tuplet(Multiplier(2, 3), "r8 d'8 e'8")]) Selection([Tuplet(Multiplier(2, 3), "e'8 d'8 r8")])
>>> selector = abjad.select().components(abjad.Tuplet) >>> selector = selector.map(abjad.select()) >>> result = selector(staff)
>>> selector.print(result) Selection([Tuplet(Multiplier(2, 3), "r8 d'8 e'8")]) Selection([Tuplet(Multiplier(2, 3), "e'8 d'8 r8")])
>>> selector.color(result) >>> abjad.show(staff)
Selects leaves in each component:
>>> staff = abjad.Staff(r""" ... \times 2/3 { r8 d' e' } f' r ... r f' \times 2/3 { e' d' r8 } ... """) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = staff[:].map(abjad.select().leaves())
>>> for item in result: ... item ... Selection([Rest('r8'), Note("d'8"), Note("e'8")]) Selection([Note("f'8")]) Selection([Rest('r8')]) Selection([Rest('r8')]) Selection([Note("f'8")]) Selection([Note("e'8"), Note("d'8"), Rest('r8')])
>>> selector = abjad.select().map(abjad.select().leaves()) >>> result = selector(staff[:])
>>> selector.print(result) Selection([Rest('r8'), Note("d'8"), Note("e'8")]) Selection([Note("f'8")]) Selection([Rest('r8')]) Selection([Rest('r8')]) Selection([Note("f'8")]) Selection([Note("e'8"), Note("d'8"), Rest('r8')])
>>> selector.color(result) >>> abjad.show(staff)
Gets item 0 in each note run:
>>> string = r"c'4 \times 2/3 { d'8 r8 e'8 } r16 f'16 g'8 a'4" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).runs() >>> result = result.map(abjad.select()[0])
>>> for item in result: ... item ... Note("c'4") Note("e'8") Note("f'16")
Returns new selection (or expression).
-
(
Selection
).nontrivial
()¶ Filters selection by length greater than 1.
Selects nontrivial runs:
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).runs().nontrivial()
>>> for item in result: ... item ... Selection([Note("d'8"), Note("e'8")]) Selection([Note("f'8"), Note("g'8"), Note("a'8")])
-
(
Selection
).note
(n)¶ Selects note
n
.Selects note -1:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).note(-1)
>>> result Note("e'16")
-
(
Selection
).notes
()¶ Selects notes.
Selects notes:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).notes()
>>> for item in result: ... item ... Note("bf'16") Note("c'16") Note("bf'16") Note("d'16") Note("bf'16") Note("e'16")
-
(
Selection
).partition_by_counts
(counts, cyclic=False, enchain=False, fuse_overhang=False, nonempty=False, overhang=False)¶ Partitions selection by
counts
.Partitions leaves into a single part of length 3; truncates overhang:
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_counts( ... [3], ... cyclic=False, ... overhang=False, ... )
>>> for item in result: ... item ... Selection([Note("c'8"), Rest('r8'), Note("d'8")])
Cyclically partitions leaves into parts of length 3; truncates overhang:
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves().partition_by_counts( ... [3], ... cyclic=True, ... overhang=False, ... )
>>> for item in result: ... item ... Selection([Note("c'8"), Rest('r8'), Note("d'8")]) Selection([Note("e'8"), Rest('r8'), Note("f'8")])
>>> selector = abjad.select().leaves().partition_by_counts( ... [3], ... cyclic=True, ... overhang=False, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Rest('r8'), Note("d'8")]) Selection([Note("e'8"), Rest('r8'), Note("f'8")])
>>> selector.color(result) >>> abjad.show(staff)
Cyclically partitions leaves into parts of length 3; returns overhang at end:
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves().partition_by_counts( ... [3], ... cyclic=True, ... overhang=True, ... )
>>> for item in result: ... item ... Selection([Note("c'8"), Rest('r8'), Note("d'8")]) Selection([Note("e'8"), Rest('r8'), Note("f'8")]) Selection([Note("g'8"), Note("a'8")])
>>> selector = abjad.select().leaves().partition_by_counts( ... [3], ... cyclic=True, ... overhang=True, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Rest('r8'), Note("d'8")]) Selection([Note("e'8"), Rest('r8'), Note("f'8")]) Selection([Note("g'8"), Note("a'8")])
>>> selector.color(result) >>> abjad.show(staff)
Cyclically partitions leaves into parts of length 3; fuses overhang to last part:
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves().partition_by_counts( ... [3], ... cyclic=True, ... fuse_overhang=True, ... overhang=True, ... )
>>> for item in result: ... item ... Selection([Note("c'8"), Rest('r8'), Note("d'8")]) Selection([Note("e'8"), Rest('r8'), Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector = abjad.select().leaves().partition_by_counts( ... [3], ... cyclic=True, ... fuse_overhang=True, ... overhang=True, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Rest('r8'), Note("d'8")]) Selection([Note("e'8"), Rest('r8'), Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector.color(result) >>> abjad.show(staff)
Cyclically partitions leaves into parts of length 3; returns overhang at end:
>>> string = "c'8 r8 d'8 e'8 r8 f'8 g'8 a'8 b'8 r8 c''8" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves().partition_by_counts( ... [1, 2, 3], ... cyclic=True, ... overhang=True, ... )
>>> for item in result: ... item ... Selection([Note("c'8")]) Selection([Rest('r8'), Note("d'8")]) Selection([Note("e'8"), Rest('r8'), Note("f'8")]) Selection([Note("g'8")]) Selection([Note("a'8"), Note("b'8")]) Selection([Rest('r8'), Note("c''8")])
>>> selector = abjad.select().leaves().partition_by_counts( ... [1, 2, 3], ... cyclic=True, ... overhang=True, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8")]) Selection([Rest('r8'), Note("d'8")]) Selection([Note("e'8"), Rest('r8'), Note("f'8")]) Selection([Note("g'8")]) Selection([Note("a'8"), Note("b'8")]) Selection([Rest('r8'), Note("c''8")])
>>> selector.color(result, ['red', 'blue', 'cyan']) >>> abjad.show(staff)
Returns nested selection (or expression):
>>> type(result).__name__ 'Selection'
-
(
Selection
).partition_by_durations
(durations, cyclic=False, fill=None, in_seconds=False, overhang=False)¶ Partitions selection by
durations
.Cyclically partitions leaves into parts equal to exactly 3/8; returns overhang at end:
>>> staff = abjad.Staff( ... "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" ... "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |" ... ) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves().partition_by_durations( ... [abjad.Duration(3, 8)], ... cyclic=True, ... fill=abjad.Exact, ... in_seconds=False, ... overhang=True, ... )
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8"), Note("e'8")]) Selection([Note("f'8"), Note("g'8"), Note("a'8")]) Selection([Note("b'8"), Note("c''8")])
>>> selector = abjad.select().leaves().partition_by_durations( ... [abjad.Duration(3, 8)], ... cyclic=True, ... fill=abjad.Exact, ... in_seconds=False, ... overhang=True, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("d'8"), Note("e'8")]) Selection([Note("f'8"), Note("g'8"), Note("a'8")]) Selection([Note("b'8"), Note("c''8")])
>>> selector.color(result) >>> abjad.show(staff)
Partitions leaves into one part equal to exactly 3/8; truncates overhang:
>>> staff = abjad.Staff( ... "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" ... "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |" ... ) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_durations( ... [abjad.Duration(3, 8)], ... cyclic=False, ... fill=abjad.Exact, ... in_seconds=False, ... overhang=False, ... )
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8"), Note("e'8")])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_durations( ... [abjad.Duration(3, 8)], ... cyclic=False, ... fill=abjad.Exact, ... in_seconds=False, ... overhang=False, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("d'8"), Note("e'8")])
>>> selector.color(result) >>> abjad.show(staff)
Cyclically partitions leaves into parts equal to (or just less than) 3/16 and 1/16; returns overhang at end:
>>> staff = abjad.Staff( ... "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" ... "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |" ... ) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_durations( ... [abjad.Duration(3, 16), abjad.Duration(1, 16)], ... cyclic=True, ... fill=abjad.More, ... in_seconds=False, ... overhang=True, ... )
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8")]) Selection([Note("e'8")]) Selection([Note("f'8"), Note("g'8")]) Selection([Note("a'8")]) Selection([Note("b'8"), Note("c''8")])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_durations( ... [abjad.Duration(3, 16), abjad.Duration(1, 16)], ... cyclic=True, ... fill=abjad.More, ... in_seconds=False, ... overhang=True, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("d'8")]) Selection([Note("e'8")]) Selection([Note("f'8"), Note("g'8")]) Selection([Note("a'8")]) Selection([Note("b'8"), Note("c''8")])
>>> selector.color(result) >>> abjad.show(staff)
Cyclically partitions leaves into parts equal to (or just less than) 3/16; truncates overhang:
>>> staff = abjad.Staff( ... "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" ... "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |" ... ) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_durations( ... [abjad.Duration(3, 16)], ... cyclic=True, ... fill=abjad.Less, ... in_seconds=False, ... overhang=False, ... )
>>> for item in result: ... item ... Selection([Note("c'8")]) Selection([Note("d'8")]) Selection([Note("e'8")]) Selection([Note("f'8")]) Selection([Note("g'8")]) Selection([Note("a'8")]) Selection([Note("b'8")])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_durations( ... [abjad.Duration(3, 16)], ... cyclic=True, ... fill=abjad.Less, ... in_seconds=False, ... overhang=False, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8")]) Selection([Note("d'8")]) Selection([Note("e'8")]) Selection([Note("f'8")]) Selection([Note("g'8")]) Selection([Note("a'8")]) Selection([Note("b'8")])
>>> selector.color(result) >>> abjad.show(staff)
Partitions leaves into a single part equal to (or just less than) 3/16; truncates overhang:
>>> staff = abjad.Staff( ... "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" ... "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |" ... ) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_durations( ... [abjad.Duration(3, 16)], ... cyclic=False, ... fill=abjad.Less, ... in_seconds=False, ... overhang=False, ... )
>>> for item in result: ... item ... Selection([Note("c'8")])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_durations( ... [abjad.Duration(3, 16)], ... cyclic=False, ... fill=abjad.Less, ... in_seconds=False, ... overhang=False, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8")])
>>> selector.color(result) >>> abjad.show(staff)
Cyclically partitions leaves into parts equal to exactly 1.5 seconds; truncates overhang:
>>> staff = abjad.Staff( ... "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" ... "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |" ... ) >>> abjad.setting(staff).auto_beaming = False >>> mark = abjad.MetronomeMark((1, 4), 60) >>> leaf = abjad.inspect(staff).leaf(0) >>> abjad.attach(mark, leaf, context='Staff') >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_durations( ... [1.5], ... cyclic=True, ... fill=abjad.Exact, ... in_seconds=True, ... overhang=False, ... )
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8"), Note("e'8")]) Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_durations( ... [1.5], ... cyclic=True, ... fill=abjad.Exact, ... in_seconds=True, ... overhang=False, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("d'8"), Note("e'8")]) Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector.color(result) >>> abjad.show(staff)
Cyclically partitions leaves into parts equal to exactly 1.5 seconds; returns overhang at end:
>>> staff = abjad.Staff( ... "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" ... "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |" ... ) >>> abjad.setting(staff).auto_beaming = False >>> mark = abjad.MetronomeMark((1, 4), 60) >>> leaf = abjad.inspect(staff).leaf(0) >>> abjad.attach(mark, leaf, context='Staff') >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_durations( ... [1.5], ... cyclic=True, ... fill=abjad.Exact, ... in_seconds=True, ... overhang=True, ... )
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8"), Note("e'8")]) Selection([Note("f'8"), Note("g'8"), Note("a'8")]) Selection([Note("b'8"), Note("c''8")])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_durations( ... [1.5], ... cyclic=True, ... fill=abjad.Exact, ... in_seconds=True, ... overhang=True, ... )
>>> selector.print(result) Selection([Note("c'8"), Note("d'8"), Note("e'8")]) Selection([Note("f'8"), Note("g'8"), Note("a'8")]) Selection([Note("b'8"), Note("c''8")])
>>> selector.color(result) >>> abjad.show(staff)
Partitions leaves into a single part equal to exactly 1.5 seconds; truncates overhang:
>>> staff = abjad.Staff( ... "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" ... "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |" ... ) >>> abjad.setting(staff).auto_beaming = False >>> mark = abjad.MetronomeMark((1, 4), 60) >>> leaf = abjad.inspect(staff).leaf(0) >>> abjad.attach(mark, leaf, context='Staff') >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_durations( ... [1.5], ... cyclic=False, ... fill=abjad.Exact, ... in_seconds=True, ... overhang=False, ... )
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8"), Note("e'8")])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_durations( ... [1.5], ... cyclic=False, ... fill=abjad.Exact, ... in_seconds=True, ... overhang=False, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("d'8"), Note("e'8")])
>>> selector.color(result) >>> abjad.show(staff)
Cyclically partitions leaves into parts equal to (or just less than) 0.75 seconds; truncates overhang:
>>> staff = abjad.Staff( ... "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" ... "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |" ... ) >>> abjad.setting(staff).auto_beaming = False >>> mark = abjad.MetronomeMark((1, 4), 60) >>> leaf = abjad.inspect(staff).leaf(0) >>> abjad.attach(mark, leaf, context='Staff') >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_durations( ... [0.75], ... cyclic=True, ... fill=abjad.Less, ... in_seconds=True, ... overhang=False, ... )
>>> for item in result: ... item ... Selection([Note("c'8")]) Selection([Note("d'8")]) Selection([Note("e'8")]) Selection([Note("f'8")]) Selection([Note("g'8")]) Selection([Note("a'8")]) Selection([Note("b'8")])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_durations( ... [0.75], ... cyclic=True, ... fill=abjad.Less, ... in_seconds=True, ... overhang=False, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8")]) Selection([Note("d'8")]) Selection([Note("e'8")]) Selection([Note("f'8")]) Selection([Note("g'8")]) Selection([Note("a'8")]) Selection([Note("b'8")])
>>> selector.color(result) >>> abjad.show(staff)
Partitions leaves into one part equal to (or just less than) 0.75 seconds; truncates overhang:
>>> staff = abjad.Staff( ... "abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |" ... "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |" ... ) >>> abjad.setting(staff).auto_beaming = False >>> mark = abjad.MetronomeMark((1, 4), 60) >>> leaf = abjad.inspect(staff).leaf(0) >>> abjad.attach(mark, leaf, context='Staff') >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_durations( ... [0.75], ... cyclic=False, ... fill=abjad.Less, ... in_seconds=True, ... overhang=False, ... )
>>> for item in result: ... item ... Selection([Note("c'8")])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_durations( ... [0.75], ... cyclic=False, ... fill=abjad.Less, ... in_seconds=True, ... overhang=False, ... ) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8")])
>>> selector.color(result) >>> abjad.show(staff)
Interprets
fill
asExact
whenfill
is none.Parts must equal
durations
exactly whenfill
isExact
.Parts must be less than or equal to
durations
whenfill
isLess
.Parts must be greater or equal to
durations
whenfill
isMore
.Reads
durations
cyclically whencyclic
is true.Reads component durations in seconds when
in_seconds
is true.Returns remaining components at end in final part when
overhang
is true.Returns nested selection (or expression):
>>> type(result).__name__ 'Selection'
-
(
Selection
).partition_by_ratio
(ratio)¶ Partitions selection by
ratio
.Partitions leaves by a ratio of 1:1:
>>> string = r"c'8 d' r \times 2/3 { e' r f' } g' a' r" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_ratio((1, 1))
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8"), Rest('r8'), Note("e'8"), Rest('r8')]) Selection([Note("f'8"), Note("g'8"), Note("a'8"), Rest('r8')])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_ratio((1, 1)) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("d'8"), Rest('r8'), Note("e'8"), Rest('r8')]) Selection([Note("f'8"), Note("g'8"), Note("a'8"), Rest('r8')])
>>> selector.color(result) >>> abjad.show(staff)
Partitions leaves by a ratio of 1:1:1:
>>> string = r"c'8 d' r \times 2/3 { e' r f' } g' a' r" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves() >>> result = result.partition_by_ratio((1, 1, 1))
>>> for item in result: ... item ... Selection([Note("c'8"), Note("d'8"), Rest('r8')]) Selection([Note("e'8"), Rest('r8'), Note("f'8")]) Selection([Note("g'8"), Note("a'8"), Rest('r8')])
>>> selector = abjad.select().leaves() >>> selector = selector.partition_by_ratio((1, 1, 1)) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Note("d'8"), Rest('r8')]) Selection([Note("e'8"), Rest('r8'), Note("f'8")]) Selection([Note("g'8"), Note("a'8"), Rest('r8')])
>>> selector.color(result, ['red', 'blue', 'cyan']) >>> abjad.show(staff)
Returns nested selection (or expression):
>>> type(result).__name__ 'Selection'
-
(
Selection
).rest
(n)¶ Selects rest
n
.Selects rest -1:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).rest(-1)
>>> result Rest('r16')
-
(
Selection
).rests
()¶ Selects rests.
Selects rests:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).rests()
>>> for item in result: ... item ... Rest('r16') Rest('r16') Rest('r16')
-
(
Selection
).run
(n)¶ Selects run
n
.Selects run -1:
>>> tuplets = [ ... "r16 c'16 c'16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 d'16 d'16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 e'16 e'16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).run(-1)
>>> result Selection([Note("e'16"), Note("e'16"), Note("e'16"), Chord("<fs' gs'>4"), Chord("<fs' gs'>16")])
-
(
Selection
).runs
()¶ Selects runs.
Selects runs:
>>> tuplets = [ ... "r16 c'16 c'16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 d'16 d'16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 e'16 e'16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).runs()
>>> for item in result: ... item ... Selection([Note("c'16"), Note("c'16"), Note("c'16"), Chord("<d' e'>4"), Chord("<d' e'>16")]) Selection([Note("d'16"), Note("d'16"), Note("d'16"), Chord("<e' fs'>4"), Chord("<e' fs'>16")]) Selection([Note("e'16"), Note("e'16"), Note("e'16"), Chord("<fs' gs'>4"), Chord("<fs' gs'>16")])
>>> selector = abjad.select().runs() >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'16"), Note("c'16"), Note("c'16"), Chord("<d' e'>4"), Chord("<d' e'>16")]) Selection([Note("d'16"), Note("d'16"), Note("d'16"), Chord("<e' fs'>4"), Chord("<e' fs'>16")]) Selection([Note("e'16"), Note("e'16"), Note("e'16"), Chord("<fs' gs'>4"), Chord("<fs' gs'>16")])
>>> selector.color(result) >>> abjad.show(lilypond_file)
-
to_tuplet
(proportions)¶ Changes logical tie to tuplet.
>>> staff = abjad.Staff(r"df'8 c'8 ~ c'16 cqs''4") >>> abjad.attach(abjad.Dynamic('p'), staff[0]) >>> abjad.attach(abjad.DynamicTrend('<'), staff[0]) >>> abjad.attach(abjad.Dynamic('f'), staff[-1]) >>> abjad.override(staff).dynamic_line_spanner.staff_padding = 3 >>> time_signature = abjad.TimeSignature((9, 16)) >>> abjad.attach(time_signature, staff[0]) >>> abjad.show(staff)
>>> logical_tie = abjad.inspect(staff[1]).logical_tie() >>> logical_tie.to_tuplet([2, 1, 1, 1]) Tuplet(Multiplier(3, 5), "c'8 c'16 c'16 c'16")
>>> abjad.show(staff)
>>> staff = abjad.Staff(r"c'8 ~ c'16 cqs''4") >>> crescendo = abjad.Hairpin('p < f') >>> abjad.attach(crescendo, staff[:]) >>> abjad.override(staff).dynamic_line_spanner.staff_padding = 3 >>> time_signature = abjad.TimeSignature((7, 16)) >>> abjad.attach(time_signature, staff[0]) >>> abjad.show(staff)
Returns tuplet.
-
(
Selection
).top
()¶ Selects top components.
Selects top components (up from leaves):
>>> string = r"c'8 d' r \times 2/3 { e' r f' } g' a' r" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).leaves().top()
>>> for item in result: ... item ... Note("c'8") Note("d'8") Rest('r8') Tuplet(Multiplier(2, 3), "e'8 r8 f'8") Note("g'8") Note("a'8") Rest('r8')
-
(
Selection
).tuplet
(n)¶ Selects tuplet
n
.Selects tuplet -1:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).tuplet(-1)
>>> result Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16")
-
(
Selection
).tuplets
()¶ Selects tuplets.
Selects tuplets:
>>> tuplets = [ ... "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16", ... "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16", ... "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16", ... ] >>> tuplets = zip([(10, 9), (8, 9), (10, 9)], tuplets) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> tuplets = [abjad.select(tuplets)] >>> lilypond_file = abjad.LilyPondFile.rhythm(tuplets) >>> staff = lilypond_file[abjad.Staff] >>> abjad.setting(staff).auto_beaming = False >>> abjad.override(staff).tuplet_bracket.direction = abjad.Up >>> abjad.override(staff).tuplet_bracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select(staff).tuplets()
>>> for item in result: ... item ... Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16") Tuplet(Multiplier(8, 9), "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16") Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16")
>>> selector = abjad.select().tuplets() >>> result = selector(staff)
>>> selector.print(result) Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 c'16 <d' e'>4 ~ <d' e'>16") Tuplet(Multiplier(8, 9), "r16 bf'16 <a'' b''>16 d'16 <e' fs'>4 ~ <e' fs'>16") Tuplet(Multiplier(10, 9), "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 ~ <fs' gs'>16")
>>> selector.color(result) >>> abjad.show(lilypond_file)
-
(
Selection
).with_next_leaf
()¶ Extends selection with next leaf.
Selects runs (each with next leaf):
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).runs() >>> result = result.map(abjad.select().with_next_leaf())
>>> for item in result: ... item ... Selection([Note("c'8"), Rest('r8')]) Selection([Note("d'8"), Note("e'8"), Rest('r8')]) Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector = abjad.select().runs() >>> selector = selector.map(abjad.select().with_next_leaf()) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Rest('r8')]) Selection([Note("d'8"), Note("e'8"), Rest('r8')]) Selection([Note("f'8"), Note("g'8"), Note("a'8")])
>>> selector.color(result) >>> abjad.show(staff)
Selects pitched tails (each with next leaf):
>>> staff = abjad.Staff(r"c'8 r d' ~ d' e' ~ e' r8 f'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> getter = abjad.select()[-1].select().with_next_leaf() >>> result = abjad.select(staff).logical_ties(pitched=True) >>> result = result.map(getter)
>>> for item in result: ... item ... Selection([Note("c'8"), Rest('r8')]) Selection([Note("d'8"), Note("e'8")]) Selection([Note("e'8"), Rest('r8')]) Selection([Note("f'8")])
>>> selector = abjad.select().logical_ties(pitched=True) >>> selector = selector.map(getter) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Rest('r8')]) Selection([Note("d'8"), Note("e'8")]) Selection([Note("e'8"), Rest('r8')]) Selection([Note("f'8")])
>>> selector.color(result) >>> abjad.show(staff)
Pitched logical ties (each with next leaf) is the correct selection for single-pitch sustain pedal applications.
Selects pitched logical ties (each with next leaf):
>>> staff = abjad.Staff(r"c'8 r d' ~ d' e' ~ e' r8 f'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> result = abjad.select(staff).logical_ties(pitched=True) >>> result = result.map(abjad.select().with_next_leaf())
>>> for item in result: ... item ... Selection([Note("c'8"), Rest('r8')]) Selection([Note("d'8"), Note("d'8"), Note("e'8")]) Selection([Note("e'8"), Note("e'8"), Rest('r8')]) Selection([Note("f'8")])
>>> selector = abjad.select().logical_ties(pitched=True) >>> selector = selector.map(abjad.select().with_next_leaf()) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8"), Rest('r8')]) Selection([Note("d'8"), Note("d'8"), Note("e'8")]) Selection([Note("e'8"), Note("e'8"), Rest('r8')]) Selection([Note("f'8")])
>>> for item in result: ... abjad.attach(abjad.PianoPedalSpanner(), item) ...
>>> selector.color(result) >>> manager = abjad.override(staff).sustain_pedal_line_spanner >>> manager.staff_padding = 6 >>> abjad.show(staff)
Returns new selection (or expression).
-
(
Selection
).with_previous_leaf
()¶ Extends selection with previous leaf.
Selects runs (each with previous leaf):
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> getter = abjad.select().with_previous_leaf() >>> result = abjad.select(staff).runs().map(getter)
>>> for item in result: ... item ... Selection([Note("c'8")]) Selection([Rest('r8'), Note("d'8"), Note("e'8")]) Selection([Rest('r8'), Note("f'8"), Note("g'8"), Note("a'8")])
Selects pitched heads (each with previous leaf):
>>> staff = abjad.Staff(r"c'8 r d' ~ d' e' ~ e' r8 f'8") >>> abjad.setting(staff).auto_beaming = False >>> abjad.show(staff)
>>> getter = abjad.select()[0].select().with_previous_leaf() >>> result = abjad.select(staff).logical_ties(pitched=True) >>> result = result.map(getter)
>>> for item in result: ... item ... Selection([Note("c'8")]) Selection([Rest('r8'), Note("d'8")]) Selection([Note("d'8"), Note("e'8")]) Selection([Rest('r8'), Note("f'8")])
>>> selector = abjad.select().logical_ties(pitched=True) >>> selector = selector.map(getter) >>> result = selector(staff)
>>> selector.print(result) Selection([Note("c'8")]) Selection([Rest('r8'), Note("d'8")]) Selection([Note("d'8"), Note("e'8")]) Selection([Rest('r8'), Note("f'8")])
>>> selector.color(result) >>> abjad.show(staff)
Returns new selection (or expression).
Read-only properties
-
head
¶ Reference to element
0
in logical tie.Returns component.
-
is_pitched
¶ Is true when logical tie head is a note or chord.
Returns true or false.
-
is_trivial
¶ Is true when length of logical tie is less than or equal to
1
.Returns true or false.
-
leaves
¶ Gets leaves in logical tie.
Returns selection.
-
tail
¶ Gets last leaf in logical tie.
Returns leaf.
-
tie
¶ Gets tie spanner governing logical tie.
Returns tie spanner.
-
written_duration
¶ Sum of written duration of all components in logical tie.
Returns duration.
-