abjad.select
|
Selects chord |
|
Selects chords in |
|
Selects components. |
|
Excludes items at |
|
Filters |
|
Flattens |
|
Gets items in |
|
Groups |
|
Groups items in |
|
Groups items in |
|
Groups items in |
|
Groups items in |
|
Groups items in |
|
Groups items in |
|
Selects leaf |
|
Selects leaves in |
|
Selects logical tie |
|
Selects logical ties in |
|
Selects nontrivial items in |
|
Selects note |
|
Selects notes in |
|
Partitions items in |
|
Partitions items in |
Partitions items in |
|
|
Selects rest |
|
Selects rests in |
|
Selects run |
|
Selects runs in |
|
Selects top components in |
|
Selects tuplet |
|
Selects tuplets in |
|
Extends |
|
Extends |
- abjad.select.chord(argument, n: int, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None) Chord[source]
Selects chord
ninargument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.chord(staff, -1) >>> result Chord("<fs' gs'>16")
>>> abjad.label.color_leaves(result, "#green") >>> abjad.show(lilypond_file)
- abjad.select.chords(argument, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None) list[Chord][source]
Selects chords in
argument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.chords(staff) >>> 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")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> abjad.show(lilypond_file)
- abjad.select.components(argument, prototype: Type[T] | tuple[Type[T], ...] | None = None, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None, reverse: bool | None = None) list[T][source]
Selects components.
Selects notes:
>>> staff = abjad.Staff("c'4 d'8 ~ d'16 e'16 ~ e'8 r4 g'8") >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Note) >>> for item in result: ... item ... Note("c'4") Note("d'8") Note("d'16") Note("e'16") Note("e'8") Note("g'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects both main notes and graces when
grace=None:>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> container = abjad.BeforeGraceContainer("cf''16 bf'16") >>> abjad.attach(container, staff[1]) >>> container = abjad.AfterGraceContainer("af'16 gf'16") >>> abjad.attach(container, staff[1]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Leaf, grace=None) >>> for item in result: ... item ... Note("c'8") Note("cf''16") Note("bf'16") Note("d'8") Note("af'16") Note("gf'16") Note("e'8") Note("f'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers:
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Leaf, grace=None) >>> for item in result: ... item ... Note("c'4") Note("d'4") Note("e'4") Note("gf'16") Note("f'4")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Excludes grace notes when
grace=False:>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> container = abjad.BeforeGraceContainer("cf''16 bf'16") >>> abjad.attach(container, staff[1]) >>> container = abjad.AfterGraceContainer("af'16 gf'16") >>> abjad.attach(container, staff[1]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Leaf, grace=False) >>> for item in result: ... item ... Note("c'8") Note("d'8") Note("e'8") Note("f'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers:
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Leaf, grace=False) >>> for item in result: ... item ... Note("c'4") Note("d'4") Note("e'4") Note("f'4")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects only grace notes when
grace=True:>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> container = abjad.BeforeGraceContainer("cf''16 bf'16") >>> abjad.attach(container, staff[1]) >>> container = abjad.AfterGraceContainer("af'16 gf'16") >>> abjad.attach(container, staff[1]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Leaf, grace=True) >>> for item in result: ... item ... Note("cf''16") Note("bf'16") Note("af'16") Note("gf'16")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers:
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Leaf, grace=True) >>> for item in result: ... item ... Note("gf'16")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.exclude(argument, indices: Sequence[int], period: int | None = None) list[source]
Excludes items at
indicesbyperiod.Excludes every other leaf:
>>> string = r"c'8 d'8 ~ d'8 e'8 ~ e'8 ~ e'8 r8 f'8" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.exclude(result, [0], 2) >>> for item in result: ... item ... Note("d'8") Note("e'8") Note("e'8") Note("f'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Excludes every other logical tie:
>>> string = r"c'8 d'8 ~ d'8 e'8 ~ e'8 ~ e'8 r8 f'8" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, pitched=True) >>> result = abjad.select.exclude(result, [0], 2) >>> for item in result: ... item ... [Note("d'8"), Note("d'8")] [Note("f'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Excludes note 1 (or nothing) in each pitched logical tie:
>>> staff = abjad.Staff(r"c'8 d'8 ~ d'8 e'8 ~ e'8 ~ e'8 r8 f'8") >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, pitched=True) >>> result = [abjad.select.leaves(_) for _ in result] >>> result = [abjad.select.exclude(_, [1]) for _ in result] >>> for item in result: ... item ... [Note("c'8")] [Note("d'8")] [Note("e'8"), Note("e'8")] [Note("f'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.filter(argument, predicate=None) list[source]
Filters
argumentbypredicate.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).autoBeaming = False
>>> result = abjad.select.runs(staff) >>> result = abjad.select.filter( ... result, lambda _: abjad.get.duration(_) == abjad.Duration(2, 8) ... ) >>> for item in result: ... item ... [Note("d'8"), Note("e'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.flatten(argument, depth: int = 1) list[source]
Flattens
argument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.tuplets(staff) >>> result = [abjad.select.leaves(_)[:2] for _ in result] >>> for item in result: ... item ... [Rest('r16'), Note("bf'16")] [Rest('r16'), Note("bf'16")] [Rest('r16'), Note("bf'16")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> abjad.show(lilypond_file)
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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.tuplets(staff) >>> result = [abjad.select.leaves(_)[:2] for _ in result] >>> result = abjad.select.flatten(result) >>> for item in result: ... item ... Rest('r16') Note("bf'16") Rest('r16') Note("bf'16") Rest('r16') Note("bf'16")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> abjad.show(lilypond_file)
- abjad.select.get(argument, indices: Sequence[int] | tuple[list[int], int] | Pattern, period: int | None = None, *, invert: bool = False) list[source]
Gets items in
argumentatindicesaccording toperiod.Gets every other leaf:
>>> string = r"c'8 d'8 ~ d'8 e'8 ~ e'8 ~ e'8 r8 f'8" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.get(result, [0], 2) >>> for item in result: ... item ... Note("c'8") Note("d'8") Note("e'8") Rest('r8')
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Gets every other logical tie:
>>> string = r"c'8 d'8 ~ d'8 e'8 ~ e'8 ~ e'8 r8 f'8" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, pitched=True) >>> result = abjad.select.get(result, [0], 2) >>> for item in result: ... item ... [Note("c'8")] [Note("e'8"), Note("e'8"), Note("e'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Gets note 1 (or nothing) in each pitched logical tie:
>>> staff = abjad.Staff(r"c'8 d'8 ~ d'8 e'8 ~ e'8 ~ e'8 r8 f'8") >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, pitched=True) >>> result = [abjad.select.leaves(_) for _ in result] >>> result = [abjad.select.get(_, [1]) for _ in result] >>> for item in result: ... item ... [] [Note("d'8")] [Note("e'8")] []
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group(argument) list[list][source]
Groups
argument.>>> 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).autoBeaming = False
>>> result = abjad.select.leaves(staff, pitched=True) >>> result = abjad.select.group(result) >>> for item in result: ... item ... [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")]
>>> abjad.label.color_leaves(result, "#green") >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group_by(argument, predicate=None) list[list][source]
Groups items in
argumentbypredicate.Wraps
argumentin list whenpredicateis 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).autoBeaming = False
>>> result = abjad.select.leaves(staff, pitched=True) >>> result = abjad.select.group_by(result) >>> for item in result: ... item ... [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")]
>>> abjad.label.color_leaves(result, "#green") >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group_by_contiguity(argument) list[list][source]
Groups items in
argumentby contiguity.Groups pitched leaves by contiguity:
>>> string = r"c'8 d' r \tuplet 3/2 { e' r f' } g' a' r" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).autoBeaming = False >>> staff.extend("r8 <c' e' g'>8 ~ <c' e' g'>4")
>>> result = abjad.select.leaves(staff, pitched=True) >>> result = abjad.select.group_by_contiguity(result) >>> for item in result: ... item ... [Note("c'8"), Note("d'8")] [Note("e'8")] [Note("f'8"), Note("g'8"), Note("a'8")] [Chord("<c' e' g'>8"), Chord("<c' e' g'>4")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Groups sixteenths by contiguity:
>>> staff = abjad.Staff("c'4 d'16 d' d' d' e'4 f'16 f' f' f'") >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.filter( ... result, lambda _: abjad.get.duration(_) == abjad.Duration(1, 16) ... ) >>> result = abjad.select.group_by_contiguity(result) >>> for item in result: ... item ... [Note("d'16"), Note("d'16"), Note("d'16"), Note("d'16")] [Note("f'16"), Note("f'16"), Note("f'16"), Note("f'16")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
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).autoBeaming = False
>>> result = abjad.select.logical_ties(staff) >>> result = abjad.select.filter( ... result, lambda _: abjad.get.duration(_) < abjad.Duration(1, 4) ... ) >>> result = abjad.select.group_by_contiguity(result) >>> result = [abjad.select.leaf(_, 0) for _ in result] >>> for item in result: ... item ... Note("d'8") Note("g'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
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).autoBeaming = False
>>> result = abjad.select.leaves(staff, pitched=True) >>> result = abjad.select.group_by_pitch(result) >>> result = [abjad.select.group_by_contiguity(_) for _ in result] >>> result = abjad.select.flatten(result) >>> for item in result: ... item ... [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")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
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).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, pitched=True) >>> result = abjad.select.group_by_contiguity(result) >>> result = [abjad.select.group_by_pitch(_) for _ in result] >>> result = abjad.select.flatten(result) >>> for item in result: ... item ... [[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")]]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group_by_duration(argument) list[list][source]
Groups items in
argumentby 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).autoBeaming = False
>>> result = abjad.select.logical_ties(staff) >>> result = abjad.select.group_by_duration(result) >>> for item in result: ... item ... [[Note("c'4"), Note("c'16")]] [[Note("d'16"), Note("d'16")]] [[Note("d'16")]] [[Note("e'4"), Note("e'16")]] [[Note("f'16"), Note("f'16")]] [[Note("f'16")]]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group_by_length(argument) list[list][source]
Groups items in
argumentby 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).autoBeaming = False
>>> result = abjad.select.logical_ties(staff) >>> result = abjad.select.group_by_length(result) >>> for item in result: ... item ... [[Note("c'4"), Note("c'16")], [Note("d'16"), Note("d'16")]] [[Note("d'16")]] [[Note("e'4"), Note("e'16")], [Note("f'16"), Note("f'16")]] [[Note("f'16")]]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group_by_measure(argument) list[list][source]
Groups items in
argumentby measure.Groups leaves by measure:
>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''") >>> score = abjad.Score([staff], name="Score") >>> abjad.setting(staff).autoBeaming = 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])
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.group_by_measure(result) >>> for item in result: ... item ... [Note("c'8"), Note("d'8")] [Note("e'8"), Note("f'8")] [Note("g'8"), Note("a'8"), Note("b'8")] [Note("c''8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Groups leaves by measure and joins pairs of consecutive groups:
>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''") >>> score = abjad.Score([staff], name="Score") >>> abjad.setting(staff).autoBeaming = 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])
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.group_by_measure(result) >>> result = abjad.select.partition_by_counts(result, [2], cyclic=True) >>> result = [abjad.select.flatten(_) for _ in result] >>> for item in result: ... item ... [Note("c'8"), Note("d'8"), Note("e'8"), Note("f'8")] [Note("g'8"), Note("a'8"), Note("b'8"), Note("c''8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Groups leaves by measure; then gets item 0 in each group:
>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''") >>> score = abjad.Score([staff], name="Score") >>> abjad.setting(staff).autoBeaming = 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])
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.group_by_measure(result) >>> result = [_[0] for _ in result] >>> for item in result: ... item ... Note("c'8") Note("e'8") Note("g'8") Note("c''8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Groups leaves by measure; then gets item -1 in each group:
>>> staff = abjad.Staff("c'8 d' e' f' g' a' b' c''") >>> score = abjad.Score([staff], name="Score") >>> abjad.setting(staff).autoBeaming = 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])
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.group_by_measure(result) >>> result = [_[-1] for _ in result] >>> for item in result: ... item ... Note("d'8") Note("f'8") Note("b'8") Note("c''8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with implicit time signatures:
>>> staff = abjad.Staff("c'4 d' e' f' g' a' b' c''") >>> abjad.setting(staff).autoBeaming = False >>> score = abjad.Score([staff]) >>> string = r"\musicLength 16" >>> abjad.setting(score).proportionalNotationDuration = string
>>> result = abjad.select.leaves(score) >>> result = abjad.select.group_by_measure(result) >>> for item in result: ... item ... [Note("c'4"), Note("d'4"), Note("e'4"), Note("f'4")] [Note("g'4"), Note("a'4"), Note("b'4"), Note("c''4")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Groups logical ties by measure:
>>> staff = abjad.Staff("c'8 d' ~ d' e' ~ e' f' g' ~ g'") >>> score = abjad.Score([staff], name="Score") >>> abjad.setting(staff).autoBeaming = 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])
>>> result = abjad.select.logical_ties(staff) >>> result = abjad.select.group_by_measure(result) >>> for item in result: ... item ... [[Note("c'8")], [Note("d'8"), Note("d'8")]] [[Note("e'8"), Note("e'8")]] [[Note("f'8")], [Note("g'8"), Note("g'8")]]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
REGRESSION: works for pickup measure:
>>> staff = abjad.Staff(r"c'4 | d'4 e'4 f'4 | g'4 a'4 b'4") >>> score = abjad.Score([staff], name="Score") >>> time_signature = abjad.TimeSignature((3, 4), partial=abjad.Duration(1, 4)) >>> abjad.attach(time_signature, staff[0])
>>> leaves = abjad.select.leaves(staff) >>> for measure in abjad.select.group_by_measure(leaves): ... print(measure) ... [Note("c'4")] [Note("d'4"), Note("e'4"), Note("f'4")] [Note("g'4"), Note("a'4"), Note("b'4")]
- abjad.select.group_by_pitch(argument) list[list][source]
Groups items in
argumentby pitch.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).autoBeaming = False
>>> lts = abjad.select.logical_ties(staff) >>> result = abjad.select.group_by_pitch(lts) >>> for item in result: ... item ... [[Note("c'4"), Note("c'16")]] [[Note("d'16"), Note("d'16")], [Note("d'16")]] [[Note("e'4"), Note("e'16")]] [[Note("f'16"), Note("f'16")], [Note("f'16")]]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.leaf(argument, n: int, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None, head: bool | None = None, pitched: bool | None = None, prototype=None, reverse: bool | None = None, tail: bool | None = None, trim: bool | Horizontal | None = None) Leaf[source]
Selects leaf
ninargument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.leaf(staff, -1) >>> result Chord("<fs' gs'>16")
>>> abjad.label.color_leaves(result, "#green") >>> abjad.show(lilypond_file)
- abjad.select.leaves(argument, prototype: Type[Leaf] | tuple[Type[Leaf], ...] | None = None, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None, head: bool | None = None, pitched: bool | None = None, reverse: bool | None = None, tail: bool | None = None, trim: bool | Horizontal | None = None) list[Leaf][source]
Selects leaves in
argument.Selects leaves:
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { r8 d' e' } f' r ... r f' \tuplet 3/2 { e' d' r8 } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> for item in result: ... item ... Rest('r8') Note("d'8") Note("e'8") Note("f'8") Rest('r8') Rest('r8') Note("f'8") Note("e'8") Note("d'8") Rest('r8')
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects pitched leaves:
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { r8 d' e' } f' r ... r f' \tuplet 3/2 { e' d' r8 } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, pitched=True) >>> for item in result: ... item ... Note("d'8") Note("e'8") Note("f'8") Note("f'8") Note("e'8") Note("d'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Ottava brackets attach to trimmed leaves.
Selects trimmed leaves:
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { r8 d' e' } f' r ... r f' \tuplet 3/2 { e' d' r8 } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, trim=True) >>> for item in result: ... item ... Note("d'8") Note("e'8") Note("f'8") Rest('r8') Rest('r8') Note("f'8") Note("e'8") Note("d'8")
>>> abjad.ottava(result) >>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Set
trimtoabjad.LEFTto trim rests at left (and preserve rests at right):>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { r8 d' e' } f' r ... r f' \tuplet 3/2 { e' d' r8 } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, trim=abjad.LEFT) >>> for item in result: ... item ... Note("d'8") Note("e'8") Note("f'8") Rest('r8') Rest('r8') Note("f'8") Note("e'8") Note("d'8") Rest('r8')
>>> abjad.ottava(result) >>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
REGRESSION: selects trimmed leaves (even when there are no rests to trim):
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { c'8 d' e' } f' r ... r f' \tuplet 3/2 { e' d' c' } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, trim=True) >>> for item in result: ... item ... Note("c'8") Note("d'8") Note("e'8") Note("f'8") Rest('r8') Rest('r8') Note("f'8") Note("e'8") Note("d'8") Note("c'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects leaves in tuplets:
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { r8 d' e' } f' r ... r f' \tuplet 3/2 { e' d' r8 } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Tuplet) >>> result = abjad.select.leaves(result) >>> for item in result: ... item ... Rest('r8') Note("d'8") Note("e'8") Note("e'8") Note("d'8") Rest('r8')
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects trimmed leaves in tuplets:
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { r8 d' e' } f' r ... r f' \tuplet 3/2 { e' d' r8 } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Tuplet) >>> result = abjad.select.leaves(result, trim=True) >>> for item in result: ... item ... Note("d'8") Note("e'8") Note("e'8") Note("d'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Most articulations attach to pitched heads.
Selects pitched heads in tuplets:
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { c'8 d' ~ d' } e' r ... r e' \tuplet 3/2 { d' ~ d' c' } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Tuplet) >>> result = abjad.select.leaves(result, head=True, pitched=True) >>> for item in result: ... item ... Note("c'8") Note("d'8") Note("d'8") Note("c'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Laissez vibrer indicators attach to pitched tails.
Selects pitched tails in tuplets:
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { c'8 d' ~ d' } e' r ... r e' \tuplet 3/2 { d' ~ d' c' } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Tuplet) >>> result = abjad.select.leaves(result, tail=True, pitched=True) >>> for item in result: ... item ... Note("c'8") Note("d'8") Note("d'8") Note("c'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Arpeggios attach to chord heads.
Selects chord heads in tuplets:
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { <c' e' g'>8 ~ <c' e' g'> d' } e' r ... r <g d' fs'> \tuplet 3/2 { e' <c' d'> ~ <c' d'> } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Tuplet) >>> result = abjad.select.leaves(result, abjad.Chord, head=True) >>> for item in result: ... item ... Chord("<c' e' g'>8") Chord("<c' d'>8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Excludes leaves with
"HIDDEN"indicator:>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { r8 d' e' } f' r ... r f' \tuplet 3/2 { e' d' r8 } ... """ ... ) >>> abjad.attach("HIDDEN", staff[-1][-2]) >>> abjad.attach("HIDDEN", staff[-1][-1]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, exclude="HIDDEN") >>> for item in result: ... item ... Rest('r8') Note("d'8") Note("e'8") Note("f'8") Rest('r8') Rest('r8') Note("f'8") Note("e'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects both main notes and graces when
grace=None:>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> container = abjad.BeforeGraceContainer("cf''16 bf'16") >>> abjad.attach(container, staff[1]) >>> container = abjad.AfterGraceContainer("af'16 gf'16") >>> abjad.attach(container, staff[1]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, grace=None) >>> for item in result: ... item ... Note("c'8") Note("cf''16") Note("bf'16") Note("d'8") Note("af'16") Note("gf'16") Note("e'8") Note("f'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers:
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, grace=None) >>> for item in result: ... item ... Note("c'4") Note("d'4") Note("e'4") Note("gf'16") Note("f'4")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Excludes grace notes when
grace=False:>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> container = abjad.BeforeGraceContainer("cf''16 bf'16") >>> abjad.attach(container, staff[1]) >>> container = abjad.AfterGraceContainer("af'16 gf'16") >>> abjad.attach(container, staff[1]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, grace=False) >>> for item in result: ... item ... Note("c'8") Note("d'8") Note("e'8") Note("f'8")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers:
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, grace=False) >>> for item in result: ... item ... Note("c'4") Note("d'4") Note("e'4") Note("f'4")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects only grace notes when
grace=True:>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> container = abjad.BeforeGraceContainer("cf''16 bf'16") >>> abjad.attach(container, staff[1]) >>> container = abjad.AfterGraceContainer("af'16 gf'16") >>> abjad.attach(container, staff[1]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, grace=True) >>> for item in result: ... item ... Note("cf''16") Note("bf'16") Note("af'16") Note("gf'16")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers:
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff, grace=True) >>> for item in result: ... item ... Note("gf'16")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.logical_tie(argument, n: int = 0, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None, nontrivial: bool | None = None, pitched: bool | None = None, reverse: bool | None = None) list[Leaf][source]
Selects logical tie
ninargument.Todo
Make work on nonhead leaves.
Todo
Write examples.
Todo
Remove
abjad.get.logical_tie().
- abjad.select.logical_ties(argument, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None, nontrivial: bool | None = None, pitched: bool | None = None, reverse: bool | None = None) list[list[Leaf]][source]
Selects logical ties in
argument.Selects logical ties:
>>> staff = abjad.Staff("c'8 d' ~ { d' e' r f'~ } f' r") >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff) >>> for item in result: ... item ... [Note("c'8")] [Note("d'8"), Note("d'8")] [Note("e'8")] [Rest('r8')] [Note("f'8"), Note("f'8")] [Rest('r8')]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects pitched logical ties:
>>> staff = abjad.Staff("c'8 d' ~ { d' e' r f'~ } f' r") >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, pitched=True) >>> for item in result: ... item ... [Note("c'8")] [Note("d'8"), Note("d'8")] [Note("e'8")] [Note("f'8"), Note("f'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects pitched nontrivial logical ties:
>>> staff = abjad.Staff("c'8 d' ~ { d' e' r f'~ } f' r") >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties( ... staff, ... pitched=True, ... nontrivial=True, ... ) >>> for item in result: ... item ... [Note("d'8"), Note("d'8")] [Note("f'8"), Note("f'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects pitched logical ties (starting) in each tuplet:
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { c'8 d' e' ~ } e' f' ~ ... \tuplet 3/2 { f' g' a' ~ } a' b' ~ ... \tuplet 3/2 { b' c'' d'' } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Tuplet) >>> result = [abjad.select.logical_ties(_, pitched=True) for _ in result] >>> for item in result: ... item ... [[Note("c'8")], [Note("d'8")], [Note("e'8"), Note("e'8")]] [[Note("g'8")], [Note("a'8"), Note("a'8")]] [[Note("c''8")], [Note("d''8")]]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects pitched logical ties (starting) in each of the last two tuplets:
>>> staff = abjad.Staff( ... r""" ... \tuplet 3/2 { c'8 d' e' ~ } e' f' ~ ... \tuplet 3/2 { f' g' a' ~ } a' b' ~ ... \tuplet 3/2 { b' c'' d'' } ... """ ... ) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Tuplet)[-2:] >>> result = [abjad.select.logical_ties(_, pitched=True) for _ in result] >>> for item in result: ... item ... [[Note("g'8")], [Note("a'8"), Note("a'8")]] [[Note("c''8")], [Note("d''8")]]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects both main notes and graces when
grace=None:>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> container = abjad.BeforeGraceContainer("cf''16 bf'16") >>> abjad.attach(container, staff[1]) >>> container = abjad.AfterGraceContainer("af'16 gf'16") >>> abjad.attach(container, staff[1]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, grace=None) >>> for item in result: ... item ... [Note("c'8")] [Note("cf''16")] [Note("bf'16")] [Note("d'8")] [Note("af'16")] [Note("gf'16")] [Note("e'8")] [Note("f'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers:
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, grace=None) >>> for item in result: ... item ... [Note("c'4")] [Note("d'4")] [Note("e'4")] [Note("gf'16")] [Note("f'4")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Excludes grace notes when
grace=False:>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> container = abjad.BeforeGraceContainer("cf''16 bf'16") >>> abjad.attach(container, staff[1]) >>> container = abjad.AfterGraceContainer("af'16 gf'16") >>> abjad.attach(container, staff[1]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, grace=False) >>> for item in result: ... item ... [Note("c'8")] [Note("d'8")] [Note("e'8")] [Note("f'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers:
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, grace=False) >>> for item in result: ... item ... [Note("c'4")] [Note("d'4")] [Note("e'4")] [Note("f'4")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects only grace notes when
grace=True:>>> staff = abjad.Staff("c'8 d'8 e'8 f'8") >>> container = abjad.BeforeGraceContainer("cf''16 bf'16") >>> abjad.attach(container, staff[1]) >>> container = abjad.AfterGraceContainer("af'16 gf'16") >>> abjad.attach(container, staff[1]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, grace=True) >>> for item in result: ... item ... [Note("cf''16")] [Note("bf'16")] [Note("af'16")] [Note("gf'16")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers:
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, grace=True) >>> for item in result: ... item ... [Note("gf'16")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.nontrivial(argument) list[source]
Selects nontrivial items in
argument.Selects nontrivial runs:
>>> staff = abjad.Staff("c'8 r8 d'8 e'8 r8 f'8 g'8 a'8") >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.runs(staff) >>> result = abjad.select.nontrivial(result) >>> for item in result: ... item ... [Note("d'8"), Note("e'8")] [Note("f'8"), Note("g'8"), Note("a'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.note(argument, n: int, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None) Note[source]
Selects note
ninargument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.note(staff, -1) >>> result Note("e'16")
>>> abjad.label.color_leaves(result, "#green") >>> abjad.show(lilypond_file)
- abjad.select.notes(argument, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None) list[Note][source]
Selects notes in
argument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.notes(staff) >>> for item in result: ... item ... Note("bf'16") Note("c'16") Note("bf'16") Note("d'16") Note("bf'16") Note("e'16")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> abjad.show(lilypond_file)
- abjad.select.partition_by_counts(argument, counts, *, cyclic: bool = False, enchain: bool = False, fuse_overhang: bool = False, nonempty: bool = False, overhang: bool | Comparison = False) list[list][source]
Partitions items in
argumentbycounts.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).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_counts( ... result, ... [3], ... cyclic=False, ... overhang=False, ... ) >>> for item in result: ... item ... [Note("c'8"), Rest('r8'), Note("d'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
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).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_counts( ... result, ... [3], ... cyclic=True, ... overhang=False, ... ) >>> for item in result: ... item ... [Note("c'8"), Rest('r8'), Note("d'8")] [Note("e'8"), Rest('r8'), Note("f'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
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).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_counts( ... result, ... [3], ... cyclic=True, ... overhang=True, ... ) >>> for item in result: ... item ... [Note("c'8"), Rest('r8'), Note("d'8")] [Note("e'8"), Rest('r8'), Note("f'8")] [Note("g'8"), Note("a'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
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).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_counts( ... result, ... [3], ... cyclic=True, ... fuse_overhang=True, ... overhang=True, ... ) >>> for item in result: ... item ... [Note("c'8"), Rest('r8'), Note("d'8")] [Note("e'8"), Rest('r8'), Note("f'8"), Note("g'8"), Note("a'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
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).autoBeaming = False
>>> leaves = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_counts( ... leaves, ... [1, 2, 3], ... cyclic=True, ... overhang=True, ... ) >>> for item in result: ... item ... [Note("c'8")] [Rest('r8'), Note("d'8")] [Note("e'8"), Rest('r8'), Note("f'8")] [Note("g'8")] [Note("a'8"), Note("b'8")] [Rest('r8'), Note("c''8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue", "#cyan"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
With negative
counts.Partitions leaves alternately into parts 2 and -3 (without overhang):
>>> 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).autoBeaming = False
>>> leaves = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_counts( ... leaves, ... [2, -3], ... cyclic=True, ... ) >>> for item in result: ... item ... [Note("c'8"), Rest('r8')] [Note("f'8"), Note("g'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
With negative
counts.Partitions leaves alternately into parts 2 and -3 (with overhang):
>>> 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).autoBeaming = False
>>> leaves = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_counts( ... leaves, ... [2, -3], ... cyclic=True, ... overhang=True, ... ) >>> for item in result: ... item ... [Note("c'8"), Rest('r8')] [Note("f'8"), Note("g'8")] [Note("c''8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
REGRESSION. Noncyclic counts work when
overhangis true:>>> 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).autoBeaming = False
>>> leaves = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_counts( ... leaves, ... [3], ... overhang=True, ... ) >>> for item in result: ... item ... [Note("c'8"), Rest('r8'), Note("d'8")] [Note("e'8"), Rest('r8'), Note("f'8"), Note("g'8"), Note("a'8"), Note("b'8"), Rest('r8'), Note("c''8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.partition_by_durations(argument, durations, *, cyclic: bool = False, fill: Comparison | None = None, in_seconds: bool = False, overhang: bool | Comparison = False) list[list][source]
Partitions items in
argumentbydurations.Interprets
fillasExactwhenfillis none.Parts must equal
durationsexactly whenfillisExact.Parts must be less than or equal to
durationswhenfillisLess.Parts must be greater or equal to
durationswhenfillisMore.Reads
durationscyclically whencyclicis true.Reads component durations in seconds when
in_secondsis true.Returns remaining components at end in final part when
overhangis true.Cyclically partitions leaves into parts equal to exactly 3/8; returns overhang at end:
>>> staff = abjad.Staff( ... [ ... abjad.Container("c'8 d'"), ... abjad.Container("e'8 f'"), ... abjad.Container("g'8 a'"), ... abjad.Container("b'8 c''"), ... ] ... ) >>> score = abjad.Score([staff], name="Score") >>> for container in staff: ... time_signature = abjad.TimeSignature((2, 8)) ... abjad.attach(time_signature, container[0]) ... >>> abjad.setting(staff).autoBeaming = False >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
>>> leaves = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_durations( ... leaves, ... [abjad.Duration(3, 8)], ... cyclic=True, ... fill=abjad.EXACT, ... in_seconds=False, ... overhang=True, ... ) >>> for item in result: ... item ... [Note("c'8"), Note("d'8"), Note("e'8")] [Note("f'8"), Note("g'8"), Note("a'8")] [Note("b'8"), Note("c''8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Partitions leaves into one part equal to exactly 3/8; truncates overhang:
>>> staff = abjad.Staff( ... [ ... abjad.Container("c'8 d'"), ... abjad.Container("e'8 f'"), ... abjad.Container("g'8 a'"), ... abjad.Container("b'8 c''"), ... ] ... ) >>> score = abjad.Score([staff], name="Score") >>> for container in staff: ... time_signature = abjad.TimeSignature((2, 8)) ... abjad.attach(time_signature, container[0]) ... >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_durations( ... result, ... [abjad.Duration(3, 8)], ... cyclic=False, ... fill=abjad.EXACT, ... in_seconds=False, ... overhang=False, ... ) >>> for item in result: ... item ... [Note("c'8"), Note("d'8"), Note("e'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Cyclically partitions leaves into parts equal to (or just less than) 3/16 and 1/16; returns overhang at end:
>>> staff = abjad.Staff( ... [ ... abjad.Container("c'8 d'"), ... abjad.Container("e'8 f'"), ... abjad.Container("g'8 a'"), ... abjad.Container("b'8 c''"), ... ] ... ) >>> score = abjad.Score([staff], name="Score") >>> for container in staff: ... time_signature = abjad.TimeSignature((2, 8)) ... abjad.attach(time_signature, container[0]) ... >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_durations( ... result, ... [abjad.Duration(3, 16), abjad.Duration(1, 16)], ... cyclic=True, ... fill=abjad.MORE, ... in_seconds=False, ... overhang=True, ... ) >>> for item in result: ... item ... [Note("c'8"), Note("d'8")] [Note("e'8")] [Note("f'8"), Note("g'8")] [Note("a'8")] [Note("b'8"), Note("c''8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Cyclically partitions leaves into parts equal to (or just less than) 3/16; truncates overhang:
>>> staff = abjad.Staff( ... [ ... abjad.Container("c'8 d'"), ... abjad.Container("e'8 f'"), ... abjad.Container("g'8 a'"), ... abjad.Container("b'8 c''"), ... ] ... ) >>> score = abjad.Score([staff], name="Score") >>> for container in staff: ... time_signature = abjad.TimeSignature((2, 8)) ... abjad.attach(time_signature, container[0]) ... >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_durations( ... result, ... [abjad.Duration(3, 16)], ... cyclic=True, ... fill=abjad.LESS, ... in_seconds=False, ... overhang=False, ... ) >>> for item in result: ... item ... [Note("c'8")] [Note("d'8")] [Note("e'8")] [Note("f'8")] [Note("g'8")] [Note("a'8")] [Note("b'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Partitions leaves into a single part equal to (or just less than) 3/16; truncates overhang:
>>> staff = abjad.Staff( ... [ ... abjad.Container("c'8 d'"), ... abjad.Container("e'8 f'"), ... abjad.Container("g'8 a'"), ... abjad.Container("b'8 c''"), ... ] ... ) >>> score = abjad.Score([staff], name="Score") >>> for container in staff: ... time_signature = abjad.TimeSignature((2, 8)) ... abjad.attach(time_signature, container[0]) ... >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_durations( ... result, ... [abjad.Duration(3, 16)], ... cyclic=False, ... fill=abjad.LESS, ... in_seconds=False, ... overhang=False, ... ) >>> for item in result: ... item ... [Note("c'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Cyclically partitions leaves into parts equal to exactly 1.5 seconds; truncates overhang:
>>> staff = abjad.Staff( ... [ ... abjad.Container("c'8 d'"), ... abjad.Container("e'8 f'"), ... abjad.Container("g'8 a'"), ... abjad.Container("b'8 c''"), ... ] ... ) >>> score = abjad.Score([staff], name="Score") >>> for container in staff: ... time_signature = abjad.TimeSignature((2, 8)) ... abjad.attach(time_signature, container[0]) ... >>> abjad.setting(staff).autoBeaming = False >>> mark = abjad.MetronomeMark(abjad.Duration(1, 4), 60) >>> leaf = abjad.get.leaf(staff, 0) >>> abjad.attach(mark, leaf, context="Staff")
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_durations( ... result, ... [1.5], ... cyclic=True, ... fill=abjad.EXACT, ... in_seconds=True, ... overhang=False, ... ) >>> for item in result: ... item ... [Note("c'8"), Note("d'8"), Note("e'8")] [Note("f'8"), Note("g'8"), Note("a'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Cyclically partitions leaves into parts equal to exactly 1.5 seconds; returns overhang at end:
>>> staff = abjad.Staff( ... [ ... abjad.Container("c'8 d'"), ... abjad.Container("e'8 f'"), ... abjad.Container("g'8 a'"), ... abjad.Container("b'8 c''"), ... ] ... ) >>> score = abjad.Score([staff], name="Score") >>> for container in staff: ... time_signature = abjad.TimeSignature((2, 8)) ... abjad.attach(time_signature, container[0]) ... >>> abjad.setting(staff).autoBeaming = False >>> mark = abjad.MetronomeMark(abjad.Duration(1, 4), 60) >>> leaf = abjad.get.leaf(staff, 0) >>> abjad.attach(mark, leaf, context="Staff")
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_durations( ... result, ... [1.5], ... cyclic=True, ... fill=abjad.EXACT, ... in_seconds=True, ... overhang=True, ... ) >>> for item in result: ... item ... [Note("c'8"), Note("d'8"), Note("e'8")] [Note("f'8"), Note("g'8"), Note("a'8")] [Note("b'8"), Note("c''8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Partitions leaves into a single part equal to exactly 1.5 seconds; truncates overhang:
>>> staff = abjad.Staff( ... [ ... abjad.Container("c'8 d'"), ... abjad.Container("e'8 f'"), ... abjad.Container("g'8 a'"), ... abjad.Container("b'8 c''"), ... ] ... ) >>> score = abjad.Score([staff], name="Score") >>> for container in staff: ... time_signature = abjad.TimeSignature((2, 8)) ... abjad.attach(time_signature, container[0]) ... >>> abjad.setting(staff).autoBeaming = False >>> mark = abjad.MetronomeMark(abjad.Duration(1, 4), 60) >>> leaf = abjad.get.leaf(staff, 0) >>> abjad.attach(mark, leaf, context="Staff")
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_durations( ... result, ... [1.5], ... cyclic=False, ... fill=abjad.EXACT, ... in_seconds=True, ... overhang=False, ... ) >>> for item in result: ... item ... [Note("c'8"), Note("d'8"), Note("e'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Cyclically partitions leaves into parts equal to (or just less than) 0.75 seconds; truncates overhang:
>>> staff = abjad.Staff( ... [ ... abjad.Container("c'8 d'"), ... abjad.Container("e'8 f'"), ... abjad.Container("g'8 a'"), ... abjad.Container("b'8 c''"), ... ] ... ) >>> score = abjad.Score([staff], name="Score") >>> for container in staff: ... time_signature = abjad.TimeSignature((2, 8)) ... abjad.attach(time_signature, container[0]) ... >>> abjad.setting(staff).autoBeaming = False >>> mark = abjad.MetronomeMark(abjad.Duration(1, 4), 60) >>> leaf = abjad.get.leaf(staff, 0) >>> abjad.attach(mark, leaf, context="Staff")
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_durations( ... result, ... [0.75], ... cyclic=True, ... fill=abjad.LESS, ... in_seconds=True, ... overhang=False, ... ) >>> for item in result: ... item ... [Note("c'8")] [Note("d'8")] [Note("e'8")] [Note("f'8")] [Note("g'8")] [Note("a'8")] [Note("b'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Partitions leaves into one part equal to (or just less than) 0.75 seconds; truncates overhang:
>>> staff = abjad.Staff( ... [ ... abjad.Container("c'8 d'"), ... abjad.Container("e'8 f'"), ... abjad.Container("g'8 a'"), ... abjad.Container("b'8 c''"), ... ] ... ) >>> score = abjad.Score([staff], name="Score") >>> for container in staff: ... time_signature = abjad.TimeSignature((2, 8)) ... abjad.attach(time_signature, container[0]) ... >>> abjad.setting(staff).autoBeaming = False >>> mark = abjad.MetronomeMark(abjad.Duration(1, 4), 60) >>> leaf = abjad.get.leaf(staff, 0) >>> abjad.attach(mark, leaf, context="Staff")
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_durations( ... result, ... [0.75], ... cyclic=False, ... fill=abjad.LESS, ... in_seconds=True, ... overhang=False, ... ) >>> for item in result: ... item ... [Note("c'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.partition_by_proportion(argument, proportion: tuple[int, ...]) list[list][source]
Partitions items in
argumentbyproportion.Partitions leaves by a proportion of 1:1:
>>> string = r"c'8 d' r \tuplet 3/2 { e' r f' } g' a' r" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_proportion(result, (1, 1)) >>> for item in result: ... item ... [Note("c'8"), Note("d'8"), Rest('r8'), Note("e'8"), Rest('r8')] [Note("f'8"), Note("g'8"), Note("a'8"), Rest('r8')]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Partitions leaves by a proportion of 1:1:1:
>>> string = r"c'8 d' r \tuplet 3/2 { e' r f' } g' a' r" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_proportion(result, (1, 1, 1)) >>> for item in result: ... item ... [Note("c'8"), Note("d'8"), Rest('r8')] [Note("e'8"), Rest('r8'), Note("f'8")] [Note("g'8"), Note("a'8"), Rest('r8')]
>>> abjad.label.color_leaves(result, ["#red", "#blue", "#cyan"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.rest(argument, n: int, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None) Rest | MultimeasureRest[source]
Selects rest
ninargument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.rest(staff, -1) >>> result Rest('r16')
>>> abjad.label.color_leaves(result, "#green") >>> abjad.show(lilypond_file)
- abjad.select.rests(argument, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None) list[Rest | MultimeasureRest][source]
Selects rests in
argument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.rests(staff) >>> for item in result: ... item ... Rest('r16') Rest('r16') Rest('r16')
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> abjad.show(lilypond_file)
- abjad.select.run(argument, n: int, *, exclude: str | Enum | Sequence[str | Enum] | None = None) list[Leaf][source]
Selects run
ninargument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.run(staff, -1) >>> result [Note("e'16"), Note("e'16"), Note("e'16"), Chord("<fs' gs'>4"), Chord("<fs' gs'>16")]
>>> abjad.label.color_leaves(result, "#green") >>> abjad.show(lilypond_file)
- abjad.select.runs(argument, *, exclude: str | Enum | Sequence[str | Enum] | None = None, grace: bool | None = None) list[list][source]
Selects runs in
argument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.runs(staff) >>> for item in result: ... item ... [Note("c'16"), Note("c'16"), Note("c'16"), Chord("<d' e'>4"), Chord("<d' e'>16")] [Note("d'16"), Note("d'16"), Note("d'16"), Chord("<e' fs'>4"), Chord("<e' fs'>16")] [Note("e'16"), Note("e'16"), Note("e'16"), Chord("<fs' gs'>4"), Chord("<fs' gs'>16")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> abjad.show(lilypond_file)
REGRESSION. Works with grace note (and containers):
>>> music_voice = abjad.Voice("c'16 d' e' r d'4 e' r8 f'", name="MusicVoice") >>> container = abjad.BeforeGraceContainer("cs'16") >>> abjad.attach(container, music_voice[4]) >>> obgc = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[5:7]) >>> abjad.attach(abjad.Articulation(">"), obgc[0]) >>> container = abjad.AfterGraceContainer("fs'16") >>> abjad.attach(container, music_voice[-1]) >>> staff = abjad.Staff([music_voice])
>>> result = abjad.select.runs(staff) >>> for item in result: ... item ... [Note("c'16"), Note("d'16"), Note("e'16")] [Note("cs'16"), Note("d'4"), Chord("<e' g'>16"), Note("gs'16"), Note("a'16"), Note("as'16"), Note("e'4")] [Note("f'8"), Note("fs'16")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.top(argument, *, exclude: str | Enum | Sequence[str | Enum] | None = None) list[Component][source]
Selects top components in
argument.Selects top components (up from leaves):
>>> string = r"c'8 d' r \tuplet 3/2 { e' r f' } g' a' r" >>> staff = abjad.Staff(string) >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.top(result) >>> for item in result: ... item ... Note("c'8") Note("d'8") Rest('r8') Tuplet('3:2', "e'8 r8 f'8") Note("g'8") Note("a'8") Rest('r8')
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.tuplet(argument, n: int, *, exclude: str | Enum | Sequence[str | Enum] | None = None, level: int | None = None) Tuplet[source]
Selects tuplet
ninargument.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(["9:8", "9:8", "9:8"], tuplets, strict=True) >>> tuplets = [abjad.Tuplet(*_) for _ in tuplets] >>> lilypond_file = abjad.illustrators.components(tuplets) >>> staff = lilypond_file["Staff"] >>> abjad.setting(staff).autoBeaming = False >>> abjad.override(staff).TupletBracket.direction = abjad.UP >>> abjad.override(staff).TupletBracket.staff_padding = 3 >>> abjad.show(lilypond_file)
>>> result = abjad.select.tuplet(staff, -1) >>> result Tuplet('9:8', "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 <fs' gs'>16")
>>> abjad.label.color_leaves(result, "#green") >>> abjad.show(lilypond_file)
- abjad.select.tuplets(argument, *, exclude: str | Enum | Sequence[str | Enum] | None = None, level: int | None = None) list[Tuplet][source]
Selects tuplets in
argument.Selects tuplets at every level:
>>> staff = abjad.Staff( ... r"\tuplet 3/2 { c'2 \tuplet 3/2 { d'8 e' f' } } \tuplet 3/2 { c'4 d' e' }" ... )
>>> result = abjad.select.tuplets(staff) >>> for item in result: ... item ... Tuplet('3:2', "c'2 { 3:2 d'8 e'8 f'8 }") Tuplet('3:2', "d'8 e'8 f'8") Tuplet('3:2', "c'4 d'4 e'4")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects tuplets at level -1; tuplets at level -1 are bottom-level tuplet: tuplets at level -1 contain only one tuplet (themselves) and do not contain any other tuplets:
>>> staff = abjad.Staff( ... r"\tuplet 3/2 { c'2 \tuplet 3/2 { d'8 e' f' } } \tuplet 3/2 { c'4 d' e' }" ... )
>>> result = abjad.select.tuplets(staff, level=-1) >>> for item in result: ... item ... Tuplet('3:2', "d'8 e'8 f'8") Tuplet('3:2', "c'4 d'4 e'4")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects tuplets at level 1; tuplets at level 1 are top-level tuplets: level-1 tuplets contain only 1 tuplet (themselves) and are not contained by any other tuplets:
>>> staff = abjad.Staff( ... r"\tuplet 3/2 { c'2 \tuplet 3/2 { d'8 e' f' } } \tuplet 3/2 { c'4 d' e' }" ... )
>>> result = abjad.select.tuplets(staff, level=1) >>> for item in result: ... item ... Tuplet('3:2', "c'2 { 3:2 d'8 e'8 f'8 }") Tuplet('3:2', "c'4 d'4 e'4")
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.with_next_leaf(argument, *, grace: bool | None = None) list[Leaf][source]
Extends
argumentwith 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).autoBeaming = False
>>> result = abjad.select.runs(staff) >>> result = [abjad.select.with_next_leaf(_) for _ in result] >>> for item in result: ... item ... [Note("c'8"), Rest('r8')] [Note("d'8"), Note("e'8"), Rest('r8')] [Note("f'8"), Note("g'8"), Note("a'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects pitched tails (each with next leaf):
>>> staff = abjad.Staff(r"c'8 r d' ~ d' e' ~ e' r8 f'8") >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, pitched=True) >>> result = [abjad.select.with_next_leaf(_[-1:]) for _ in result] >>> for item in result: ... item ... [Note("c'8"), Rest('r8')] [Note("d'8"), Note("e'8")] [Note("e'8"), Rest('r8')] [Note("f'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Single-pitch sustain pedal indicators attach to pitched logical ties (each with next leaf).
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).autoBeaming = False >>> abjad.setting(staff).pedalSustainStyle = "#'mixed"
>>> result = abjad.select.logical_ties(staff, pitched=True) >>> result = [abjad.select.with_next_leaf(_) for _ in result] >>> for item in result: ... item ... [Note("c'8"), Rest('r8')] [Note("d'8"), Note("d'8"), Note("e'8")] [Note("e'8"), Note("e'8"), Rest('r8')] [Note("f'8")]
>>> for item in result: ... abjad.piano_pedal(item, context="Staff") ...
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> abjad.override(staff).SustainPedalLineSpanner.staff_padding = 6 >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
REGRESSION. Works with grace note (and containers):
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.BeforeGraceContainer("cs'16") >>> abjad.attach(container, music_voice[1]) >>> obgc = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3]) >>> abjad.attach(abjad.Articulation(">"), obgc[0]) >>> container = abjad.AfterGraceContainer("fs'16") >>> abjad.attach(container, music_voice[3]) >>> staff = abjad.Staff([music_voice])
>>> prototype = ( ... abjad.BeforeGraceContainer, ... abjad.OnBeatGraceContainer, ... abjad.AfterGraceContainer, ... ) >>> result = abjad.select.components(staff, prototype) >>> result = [abjad.select.leaves(_) for _ in result] >>> result = [abjad.select.with_next_leaf(_) for _ in result] >>> for item in result: ... item ... [Note("cs'16"), Note("d'4")] [Chord("<e' g'>16"), Note("gs'16"), Note("a'16"), Note("as'16"), Note("e'4")] [Note("fs'16")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers (grace-to-main):
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> leaves = abjad.select.leaves(staff) >>> result = [abjad.select.with_next_leaf(_) for _ in [leaves[2:3]]] >>> for item in result: ... item ... [Note("e'4"), Note("gf'16")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers (grace-to-main):
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> leaves = abjad.select.leaves(staff) >>> result = [abjad.select.with_next_leaf(_) for _ in [leaves[3:4]]] >>> for item in result: ... item ... [Note("gf'16"), Note("f'4")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.with_previous_leaf(argument) list[Leaf][source]
Extends
argumentwith 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).autoBeaming = False
>>> result = abjad.select.runs(staff) >>> result = [abjad.select.with_previous_leaf(_) for _ in result] >>> for item in result: ... item ... [Note("c'8")] [Rest('r8'), Note("d'8"), Note("e'8")] [Rest('r8'), Note("f'8"), Note("g'8"), Note("a'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects pitched heads (each with previous leaf):
>>> staff = abjad.Staff(r"c'8 r d' ~ d' e' ~ e' r8 f'8") >>> abjad.setting(staff).autoBeaming = False
>>> result = abjad.select.logical_ties(staff, pitched=True) >>> result = [abjad.select.with_previous_leaf(_[:1]) for _ in result] >>> for item in result: ... item ... [Note("c'8")] [Rest('r8'), Note("d'8")] [Note("d'8"), Note("e'8")] [Rest('r8'), Note("f'8")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
REGRESSION. Works with grace note (and containers):
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.BeforeGraceContainer("cs'16") >>> abjad.attach(container, music_voice[1]) >>> obgc = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3]) >>> abjad.attach(abjad.Articulation(">"), obgc[0]) >>> container = abjad.AfterGraceContainer("fs'16") >>> abjad.attach(container, music_voice[3]) >>> staff = abjad.Staff([music_voice])
>>> prototype = ( ... abjad.BeforeGraceContainer, ... abjad.OnBeatGraceContainer, ... abjad.AfterGraceContainer, ... ) >>> result = abjad.select.components(staff, prototype) >>> result = [abjad.select.leaves(_) for _ in result] >>> result = [abjad.select.with_previous_leaf(_) for _ in result] >>> for item in result: ... item ... [Note("c'4"), Note("cs'16")] [Note("d'4"), Chord("<e' g'>16"), Note("gs'16"), Note("a'16"), Note("as'16")] [Note("f'4"), Note("fs'16")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers (grace-to-main):
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> leaves = abjad.select.leaves(staff) >>> result = [abjad.select.with_previous_leaf(_) for _ in [leaves[3:4]]] >>> for item in result: ... item ... [Note("e'4"), Note("gf'16")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Works with independent after-grace containers (main-to-grace):
>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice") >>> container = abjad.IndependentAfterGraceContainer("gf'16") >>> music_voice.insert(3, container) >>> staff = abjad.Staff([music_voice]) >>> abjad.setting(staff).autoBeaming = False
>>> leaves = abjad.select.leaves(staff) >>> result = [abjad.select.with_previous_leaf(_) for _ in [leaves[-1:]]] >>> for item in result: ... item ... [Note("gf'16"), Note("f'4")]
>>> abjad.label.color_leaves(result, ["#red", "#blue"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)