select¶
Classes
Logical tie of a component. |
- class abjad.select.LogicalTie(items=None)[source]¶
Logical tie of a component.
>>> staff = abjad.Staff("c' d' e' ~ e'") >>> abjad.show(staff)
>>> abjad.select.logical_tie(staff[2]) LogicalTie(items=[Note("e'4"), Note("e'4")])
Attributes Summary
Is true when
argument
is in selection.Is true when selection and
argument
are of the same type and when items in selection equal item inargument
.Gets
argument
.Hashes selection.
Gets number of items in selection.
Gets interpreter representation of selection.
Reference to element
0
in logical tie.Is true when logical tie head is a note or chord.
Is true when length of logical tie is less than or equal to
1
.Gets items in selection.
Gets last leaf in logical tie.
Sum of written duration of all components in logical tie.
Special methods
- overridden __eq__(argument)[source]¶
Is true when selection and
argument
are of the same type and when items in selection equal item inargument
.- Return type:
- overridden __getitem__(argument)[source]¶
Gets
argument
.Returns component or list (not logical tie).
Methods
Read-only properties
- 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
.
- items¶
Gets items in selection.
- tail¶
Gets last leaf in logical tie.
- written_duration¶
Sum of written duration of all components in logical tie.
Functions
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, *, exclude=None, grace=None)[source]¶
Selects chord
n
inargument
.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] >>> 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.by_selector(result, lone=True) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.chords(argument, *, exclude=None, grace=None)[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([(10, 9), (8, 9), (10, 9)], tuplets) >>> 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.by_selector(result, True) >>> abjad.show(lilypond_file)
- abjad.select.components(argument, prototype=None, *, exclude=None, grace=None, reverse=None)[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.by_selector(result, True) >>> 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.by_selector(result, True) >>> 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.by_selector(result, True) >>> 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.by_selector(result, True) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.exclude(argument, indices, period=None)[source]¶
Excludes items at
indices
byperiod
.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.by_selector(result) >>> 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 ... LogicalTie(items=[Note("d'8"), Note("d'8")]) LogicalTie(items=[Note("f'8")])
>>> abjad.label.by_selector(result) >>> 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.by_selector(result, True) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.filter(argument, predicate=None)[source]¶
Filters
argument
bypredicate
.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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.flatten(argument, depth=1)[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([(10, 9), (8, 9), (10, 9)], tuplets) >>> 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.by_selector(result, True) >>> 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([(10, 9), (8, 9), (10, 9)], tuplets) >>> 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.by_selector(result, True) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.get(argument, indices, period=None, *, invert=False)[source]¶
Gets items in
argument
atindices
according 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.by_selector(result) >>> 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 ... LogicalTie(items=[Note("c'8")]) LogicalTie(items=[Note("e'8"), Note("e'8"), Note("e'8")])
>>> abjad.label.by_selector(result) >>> 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.by_selector(result, True) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.group(argument)[source]¶
Groups
argument
in 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).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.by_selector(result, lone=True) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group_by(argument, predicate=None)[source]¶
Groups items in
argument
bypredicate
.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).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.by_selector(result, lone=True) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group_by_contiguity(argument)[source]¶
Groups items in
argument
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).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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result, True) >>> 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.by_selector(result, True) >>> 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 ... [LogicalTie(items=[Note("c'8"), Note("c'16")]), LogicalTie(items=[Note("c'16")])] [LogicalTie(items=[Note("c'16")]), LogicalTie(items=[Note("c'16")])] [LogicalTie(items=[Note("d'8"), Note("d'16")]), LogicalTie(items=[Note("d'16")])] [LogicalTie(items=[Note("d'16")]), LogicalTie(items=[Note("d'16")])]
>>> abjad.label.by_selector(result, True) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group_by_duration(argument)[source]¶
Groups items in
argument
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).autoBeaming = False
>>> result = abjad.select.logical_ties(staff) >>> result = abjad.select.group_by_duration(result) >>> for item in result: ... item ... [LogicalTie(items=[Note("c'4"), Note("c'16")])] [LogicalTie(items=[Note("d'16"), Note("d'16")])] [LogicalTie(items=[Note("d'16")])] [LogicalTie(items=[Note("e'4"), Note("e'16")])] [LogicalTie(items=[Note("f'16"), Note("f'16")])] [LogicalTie(items=[Note("f'16")])]
>>> abjad.label.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group_by_length(argument)[source]¶
Groups items in
argument
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).autoBeaming = False
>>> result = abjad.select.logical_ties(staff) >>> result = abjad.select.group_by_length(result) >>> for item in result: ... item ... [LogicalTie(items=[Note("c'4"), Note("c'16")]), LogicalTie(items=[Note("d'16"), Note("d'16")])] [LogicalTie(items=[Note("d'16")])] [LogicalTie(items=[Note("e'4"), Note("e'16")]), LogicalTie(items=[Note("f'16"), Note("f'16")])] [LogicalTie(items=[Note("f'16")])]
>>> abjad.label.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.group_by_measure(argument)[source]¶
Groups items in
argument
by 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.by_selector(result) >>> 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.by_selector(result, True) >>> 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.by_selector(result, True) >>> 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.by_selector(result, True) >>> 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 = "#(ly:make-moment 1 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.by_selector(result) >>> 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 ... [LogicalTie(items=[Note("c'8")]), LogicalTie(items=[Note("d'8"), Note("d'8")])] [LogicalTie(items=[Note("e'8"), Note("e'8")])] [LogicalTie(items=[Note("f'8")]), LogicalTie(items=[Note("g'8"), Note("g'8")])]
>>> abjad.label.by_selector(result) >>> 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)[source]¶
Groups items in
argument
by 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 ... [LogicalTie(items=[Note("c'4"), Note("c'16")])] [LogicalTie(items=[Note("d'16"), Note("d'16")]), LogicalTie(items=[Note("d'16")])] [LogicalTie(items=[Note("e'4"), Note("e'16")])] [LogicalTie(items=[Note("f'16"), Note("f'16")]), LogicalTie(items=[Note("f'16")])]
>>> abjad.label.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.leaf(argument, n, *, exclude=None, grace=None, head=None, pitched=None, prototype=None, reverse=None, tail=None, trim=None)[source]¶
Selects leaf
n` in ``argument
.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] >>> 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.by_selector(result, lone=True) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.leaves(argument, prototype=None, *, exclude=None, grace=None, head=None, pitched=None, reverse=None, tail=None, trim=None)[source]¶
Selects leaves in
argument
.Selects leaves:
>>> staff = abjad.Staff( ... r""" ... \times 2/3 { r8 d' e' } f' r ... r f' \times 2/3 { 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects pitched leaves:
>>> staff = abjad.Staff( ... r""" ... \times 2/3 { r8 d' e' } f' r ... r f' \times 2/3 { 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Trimmed leaves are the correct selection for ottava brackets.
Selects trimmed leaves:
>>> staff = abjad.Staff( ... r""" ... \times 2/3 { r8 d' e' } f' r ... r f' \times 2/3 { 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Set
trim
toabjad.LEFT
to trim rests at left (and preserve rests at right):>>> staff = abjad.Staff( ... r""" ... \times 2/3 { r8 d' e' } f' r ... r f' \times 2/3 { 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.by_selector(result) >>> 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""" ... \times 2/3 { c'8 d' e' } f' r ... r f' \times 2/3 { 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects leaves in tuplets:
>>> staff = abjad.Staff( ... r""" ... \times 2/3 { r8 d' e' } f' r ... r f' \times 2/3 { 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects trimmed leaves in tuplets:
>>> staff = abjad.Staff( ... r""" ... \times 2/3 { r8 d' e' } f' r ... r f' \times 2/3 { 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Pitched heads is the correct selection for most articulations.
Selects pitched heads in tuplets:
>>> staff = abjad.Staff( ... r""" ... \times 2/3 { c'8 d' ~ d' } e' r ... r e' \times 2/3 { 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Pitched tails in the correct selection for laissez vibrer.
Selects pitched tails in tuplets:
>>> staff = abjad.Staff( ... r""" ... \times 2/3 { c'8 d' ~ d' } e' r ... r e' \times 2/3 { 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Chord heads are the correct selection for arpeggios.
Selects chord heads in tuplets:
>>> staff = abjad.Staff( ... r""" ... \times 2/3 { <c' e' g'>8 ~ <c' e' g'> d' } e' r ... r <g d' fs'> \times 2/3 { 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Excludes leaves with
"HIDDEN"
indicator:>>> staff = abjad.Staff( ... r""" ... \times 2/3 { r8 d' e' } f' r ... r f' \times 2/3 { 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.logical_tie(argument, n=0, *, exclude=None, grace=None, nontrivial=None, pitched=None, reverse=None)[source]¶
Selects logical tie
n
inargument
. :rtype:LogicalTie
Todo
Make work on nonhead leaves.
Todo
Write examples.
Todo
Remove
abjad.get.logical_tie()
.
- abjad.select.logical_ties(argument, *, exclude=None, grace=None, nontrivial=None, pitched=None, reverse=None)[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 ... LogicalTie(items=[Note("c'8")]) LogicalTie(items=[Note("d'8"), Note("d'8")]) LogicalTie(items=[Note("e'8")]) LogicalTie(items=[Rest('r8')]) LogicalTie(items=[Note("f'8"), Note("f'8")]) LogicalTie(items=[Rest('r8')])
>>> abjad.label.by_selector(result) >>> 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 ... LogicalTie(items=[Note("c'8")]) LogicalTie(items=[Note("d'8"), Note("d'8")]) LogicalTie(items=[Note("e'8")]) LogicalTie(items=[Note("f'8"), Note("f'8")])
>>> abjad.label.by_selector(result) >>> 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 ... LogicalTie(items=[Note("d'8"), Note("d'8")]) LogicalTie(items=[Note("f'8"), Note("f'8")])
>>> abjad.label.by_selector(result) >>> 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""" ... \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).autoBeaming = False
>>> result = abjad.select.components(staff, abjad.Tuplet) >>> result = [abjad.select.logical_ties(_, pitched=True) for _ in result] >>> for item in result: ... item ... [LogicalTie(items=[Note("c'8")]), LogicalTie(items=[Note("d'8")]), LogicalTie(items=[Note("e'8"), Note("e'8")])] [LogicalTie(items=[Note("g'8")]), LogicalTie(items=[Note("a'8"), Note("a'8")])] [LogicalTie(items=[Note("c''8")]), LogicalTie(items=[Note("d''8")])]
>>> abjad.label.by_selector(result, True) >>> 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""" ... \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).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 ... [LogicalTie(items=[Note("g'8")]), LogicalTie(items=[Note("a'8"), Note("a'8")])] [LogicalTie(items=[Note("c''8")]), LogicalTie(items=[Note("d''8")])]
>>> abjad.label.by_selector(result, True) >>> 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 ... LogicalTie(items=[Note("c'8")]) LogicalTie(items=[Note("cf''16")]) LogicalTie(items=[Note("bf'16")]) LogicalTie(items=[Note("d'8")]) LogicalTie(items=[Note("af'16")]) LogicalTie(items=[Note("gf'16")]) LogicalTie(items=[Note("e'8")]) LogicalTie(items=[Note("f'8")])
>>> abjad.label.by_selector(result) >>> 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 ... LogicalTie(items=[Note("c'8")]) LogicalTie(items=[Note("d'8")]) LogicalTie(items=[Note("e'8")]) LogicalTie(items=[Note("f'8")])
>>> abjad.label.by_selector(result) >>> 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 ... LogicalTie(items=[Note("cf''16")]) LogicalTie(items=[Note("bf'16")]) LogicalTie(items=[Note("af'16")]) LogicalTie(items=[Note("gf'16")])
>>> abjad.label.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.nontrivial(argument)[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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.note(argument, n, *, exclude=None, grace=None)[source]¶
Selects note
n
inargument
.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] >>> 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.by_selector(result, lone=True) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.notes(argument, *, exclude=None, grace=None)[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([(10, 9), (8, 9), (10, 9)], tuplets) >>> 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.by_selector(result) >>> abjad.show(lilypond_file)
- abjad.select.partition_by_counts(argument, counts, *, cyclic=False, enchain=False, fuse_overhang=False, nonempty=False, overhang=False)[source]¶
Partitions items in
argument
bycounts
.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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result, colors=["#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.by_selector(result) >>> 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
REGRESSION. Noncyclic counts work when
overhang
is 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.partition_by_durations(argument, durations, *, cyclic=False, fill=None, in_seconds=False, overhang=False)[source]¶
Partitions items in
argument
bydurations
.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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
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.
- abjad.select.partition_by_ratio(argument, ratio)[source]¶
Partitions items in
argument
byratio
.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).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_ratio(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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
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).autoBeaming = False
>>> result = abjad.select.leaves(staff) >>> result = abjad.select.partition_by_ratio(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.by_selector(result, colors=["#red", "#blue", "#cyan"]) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.rest(argument, n, *, exclude=None, grace=None)[source]¶
Selects rest
n
inargument
.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] >>> 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.by_selector(result, lone=True) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.rests(argument, *, exclude=None, grace=None)[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([(10, 9), (8, 9), (10, 9)], tuplets) >>> 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.by_selector(result) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.run(argument, n, *, exclude=None)[source]¶
Selects run
n
inargument
.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] >>> 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.by_selector(result, lone=True) >>> abjad.show(lilypond_file)
- abjad.select.runs(argument, *, exclude=None, grace=None)[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([(10, 9), (8, 9), (10, 9)], tuplets) >>> 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.by_selector(result) >>> 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]) >>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[5:7]) >>> abjad.attach(abjad.Articulation(">"), container[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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.top(argument, *, exclude=None)[source]¶
Selects top components in
argument
.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).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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.tuplet(argument, n, *, exclude=None, level=None)[source]¶
Selects tuplet
n
inargument
.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] >>> 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:10', "r16 bf'16 <a'' b''>16 e'16 <fs' gs'>4 <fs' gs'>16")
>>> abjad.label.by_selector(result, lone=True) >>> abjad.show(lilypond_file)
- Return type:
- abjad.select.tuplets(argument, *, exclude=None, level=None)[source]¶
Selects tuplets in
argument
.Selects tuplets at every level:
>>> staff = abjad.Staff( ... r"\times 2/3 { c'2 \times 2/3 { d'8 e' f' } } \times 2/3 { c'4 d' e' }" ... )
>>> result = abjad.select.tuplets(staff) >>> for item in result: ... item ... Tuplet('3:2', "c'2 { 2/3 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Selects tuplets at level -1:
>>> staff = abjad.Staff( ... r"\times 2/3 { c'2 \times 2/3 { d'8 e' f' } } \times 2/3 { 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.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Tuplets at level -1 are bottom-level tuplet: tuplets at level -1 contain only one tuplet (themselves) and do not contain any other tuplets.
Selects tuplets at level 1:
>>> staff = abjad.Staff( ... r"\times 2/3 { c'2 \times 2/3 { d'8 e' f' } } \times 2/3 { c'4 d' e' }" ... )
>>> result = abjad.select.tuplets(staff, level=1) >>> for item in result: ... item ... Tuplet('3:2', "c'2 { 2/3 d'8 e'8 f'8 }") Tuplet('3:2', "c'4 d'4 e'4")
>>> abjad.label.by_selector(result) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
Tuplets at level 1 are top-level tuplets: level-1 tuplets contain only 1 tuplet (themselves) and are not contained by any other tuplets.
- abjad.select.with_next_leaf(argument, *, grace=None)[source]¶
Extends
argument
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).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.by_selector(result, True) >>> 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.by_selector(result, True) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
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).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.by_selector(result, True) >>> 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]) >>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3]) >>> abjad.attach(abjad.Articulation(">"), container[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.by_selector(result, True) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)
- abjad.select.with_previous_leaf(argument)[source]¶
Extends
argument
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).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.by_selector(result, True) >>> 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.by_selector(result, True) >>> 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]) >>> container = abjad.on_beat_grace_container("g'16 gs' a' as'", music_voice[2:3]) >>> abjad.attach(abjad.Articulation(">"), container[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.by_selector(result, True) >>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff]) >>> abjad.show(lilypond_file)