makers
Functions
Makes leaves from |
|
Makes notes from |
|
Makes tuplet from |
- abjad.makers.make_leaves(pitches, durations, *, forbidden_note_duration: Duration | None = None, forbidden_rest_duration: Duration | None = None, skips_instead_of_rests: bool = False, increase_monotonic: bool = False, tag: Tag | None = None, use_multimeasure_rests: bool = False)[source]
Makes leaves from
pitches
anddurations
.Integer and string elements in
pitches
result in notes:>>> pitches = [2, 4, "F#5", "G#5"] >>> duration = abjad.Duration(1, 4) >>> leaves = abjad.makers.make_leaves(pitches, duration) >>> staff = abjad.Staff(leaves) >>> abjad.show(staff)
Tuple elements in
pitches
result in chords:>>> pitches = [(0, 2, 4), ("F#5", "G#5", "A#5")] >>> duration = abjad.Duration(1, 2) >>> leaves = abjad.makers.make_leaves(pitches, duration) >>> staff = abjad.Staff(leaves) >>> abjad.show(staff)
None-valued elements in
pitches
result in rests:>>> pitches = 4 * [None] >>> durations = [abjad.Duration(1, 4)] >>> leaves = abjad.makers.make_leaves(pitches, durations) >>> staff = abjad.Staff(leaves, lilypond_type="RhythmicStaff") >>> abjad.show(staff)
You can mix and match values passed to
pitches
:>>> pitches = [(0, 2, 4), None, "C#5", "D#5"] >>> durations = [abjad.Duration(1, 4)] >>> leaves = abjad.makers.make_leaves(pitches, durations) >>> staff = abjad.Staff(leaves) >>> abjad.show(staff)
Works with segments:
>>> pitches = "e'' ef'' d'' df'' c''" >>> durations = [abjad.Duration(1, 4)] >>> leaves = abjad.makers.make_leaves(pitches, durations) >>> staff = abjad.Staff(leaves) >>> abjad.show(staff)
Reads
pitches
cyclically when the length ofpitches
is less than the length ofdurations
:>>> pitches = ["C5"] >>> durations = 2 * [abjad.Duration(3, 8), abjad.Duration(1, 8)] >>> leaves = abjad.makers.make_leaves(pitches, durations) >>> staff = abjad.Staff(leaves) >>> abjad.show(staff)
Reads
durations
cyclically when the length ofdurations
is less than the length ofpitches
:>>> pitches = "c'' d'' e'' f''" >>> durations = [abjad.Duration(1, 4)] >>> leaves = abjad.makers.make_leaves(pitches, durations) >>> staff = abjad.Staff(leaves) >>> abjad.show(staff)
Elements in
durations
with non-power-of-two denominators result in tuplet-nested leaves:>>> pitches = ["D5"] >>> durations = 3 * [abjad.Duration(1, 3)] >>> leaves = abjad.makers.make_leaves(pitches, durations) >>> staff = abjad.Staff(leaves) >>> abjad.show(staff)
Set
increase_monotonic
to false to return nonassignable durations tied from greatest to least:>>> pitches = ["D#5"] >>> durations = [abjad.Duration(13, 16)] >>> leaves = abjad.makers.make_leaves(pitches, durations) >>> staff = abjad.Staff(leaves) >>> score = abjad.Score([staff], name="Score") >>> time_signature = abjad.TimeSignature((13, 16)) >>> abjad.attach(time_signature, staff[0]) >>> abjad.show(staff)
Set
increase_monotonic
to true to return nonassignable durations tied from least to greatest:>>> pitches = ["E5"] >>> durations = [abjad.Duration(13, 16)] >>> leaves = abjad.makers.make_leaves(pitches, durations, increase_monotonic=True) >>> staff = abjad.Staff(leaves) >>> score = abjad.Score([staff], name="Score") >>> time_signature = abjad.TimeSignature((13, 16)) >>> abjad.attach(time_signature, staff[0]) >>> abjad.show(staff)
Set
forbidden_note_duration
to avoid notes greater than or equal to a certain written duration:>>> pitches = "f' g'" >>> durations = [abjad.Duration(5, 8)] >>> leaves = abjad.makers.make_leaves( ... pitches, durations, forbidden_note_duration=abjad.Duration(1, 2) ... ) >>> staff = abjad.Staff(leaves) >>> score = abjad.Score([staff], name="Score") >>> time_signature = abjad.TimeSignature((5, 4)) >>> abjad.attach(time_signature, staff[0]) >>> abjad.show(staff)
You may set
forbidden_note_duration
andincrease_monotonic
together:>>> pitches = "f' g'" >>> durations = [abjad.Duration(5, 8)] >>> leaves = abjad.makers.make_leaves( ... pitches, ... durations, ... forbidden_note_duration=abjad.Duration(1, 2), ... increase_monotonic=True, ... ) >>> staff = abjad.Staff(leaves) >>> score = abjad.Score([staff], name="Score") >>> time_signature = abjad.TimeSignature((5, 4)) >>> abjad.attach(time_signature, staff[0]) >>> abjad.show(staff)
Produces diminished tuplets:
>>> pitches = "f'" >>> durations = [abjad.Duration(5, 14)] >>> leaves = abjad.makers.make_leaves(pitches, durations) >>> staff = abjad.Staff(leaves) >>> score = abjad.Score([staff], name="Score") >>> time_signature = abjad.TimeSignature((5, 14)) >>> leaf = abjad.get.leaf(staff, 0) >>> abjad.attach(time_signature, leaf) >>> abjad.show(staff)
This is default behavior.
None-valued elements in
pitches
result in multimeasure rests when the multimeasure rest keyword is set:>>> pitches = [None] >>> durations = [abjad.Duration(3, 8), abjad.Duration(5, 8)] >>> leaves = abjad.makers.make_leaves( ... pitches, durations, use_multimeasure_rests=True ... ) >>> leaves [MultimeasureRest('R1 * 3/8'), MultimeasureRest('R1 * 5/8')]
>>> staff = abjad.Staff(leaves, lilypond_type="RhythmicStaff") >>> score = abjad.Score([staff], name="Score") >>> abjad.attach(abjad.TimeSignature((3, 8)), leaves[0]) >>> abjad.attach(abjad.TimeSignature((5, 8)), leaves[1]) >>> abjad.show(staff)
Works with numbered pitch-class:
>>> pitches = [abjad.NumberedPitchClass(6)] >>> durations = [abjad.Duration(13, 16)] >>> leaves = abjad.makers.make_leaves(pitches, durations) >>> staff = abjad.Staff(leaves) >>> score = abjad.Score([staff], name="Score") >>> abjad.show(staff)
Makes skips instead of rests:
>>> pitches = [None] >>> durations = [abjad.Duration(13, 16)] >>> abjad.makers.make_leaves(pitches, durations, skips_instead_of_rests=True) [Skip('s2.'), Skip('s16')]
Integer and string elements in
pitches
result in notes:>>> tag = abjad.Tag("leaf_maker") >>> pitches = [2, 4, "F#5", "G#5"] >>> duration = abjad.Duration(1, 4) >>> leaves = abjad.makers.make_leaves(pitches, duration, tag=tag) >>> staff = abjad.Staff(leaves) >>> score = abjad.Score([staff], name="Score") >>> abjad.show(staff)
- abjad.makers.make_notes(pitches, durations, *, increase_monotonic: bool = False, tag: Tag | None = None) list[Note | Tuplet] [source]
Makes notes from
pitches
anddurations
.Set
pitches
to a single pitch or a sequence of pitches.Set
durations
to a single duration or a list of durations.Cycles through
pitches
when the length ofpitches
is less than the length ofdurations
:>>> pitches = [0] >>> durations = [(1, 16), (1, 8), (1, 8)] >>> notes = abjad.makers.make_notes(pitches, durations) >>> staff = abjad.Staff(notes) >>> score = abjad.Score([staff], name="Score") >>> abjad.show(staff)
Cycles through
durations
when the length ofdurations
is less than the length ofpitches
:>>> pitches = [0, 2, 4, 5, 7] >>> durations = [(1, 16), (1, 8), (1, 8)] >>> notes = abjad.makers.make_notes(pitches, durations) >>> staff = abjad.Staff(notes) >>> abjad.show(staff)
Creates ad hoc tuplets for nonassignable durations:
>>> pitches = [0] >>> durations = [(1, 16), (1, 12), (1, 8)] >>> notes = abjad.makers.make_notes(pitches, durations) >>> staff = abjad.Staff(notes) >>> abjad.show(staff)
Tied values are written in decreasing duration by default:
>>> pitches = [0] >>> durations = [(13, 16)] >>> notes = abjad.makers.make_notes(pitches, durations) >>> staff = abjad.Staff(notes) >>> abjad.show(staff)
Set
increase_monotonic=True
to express tied values in increasing duration:>>> pitches = [0] >>> durations = [(13, 16)] >>> notes = abjad.makers.make_notes(pitches, durations, increase_monotonic=True) >>> staff = abjad.Staff(notes) >>> abjad.show(staff)
Works with pitch segments:
>>> pitches = abjad.PitchSegment([-2, -1.5, 6, 7, -1.5, 7]) >>> durations = [(1, 8)] >>> notes = abjad.makers.make_notes(pitches, durations) >>> staff = abjad.Staff(notes) >>> abjad.show(staff)
Tag output like this:
>>> pitches = [0] >>> durations = [(1, 16), (1, 8), (1, 8)] >>> tag = abjad.Tag("note_maker") >>> notes = abjad.makers.make_notes(pitches, durations, tag=tag) >>> staff = abjad.Staff(notes) >>> abjad.show(staff)
- abjad.makers.tuplet_from_ratio_and_pair(ratio: tuple[int, ...], pair: tuple[int, int], *, tag: Tag | None = None) Tuplet [source]
Makes tuplet from
ratio
andpair
.Helper function:
>>> def make_score(ratio, pair): ... tuplet = abjad.makers.tuplet_from_ratio_and_pair(ratio, pair) ... staff = abjad.Staff([tuplet], lilypond_type="RhythmicStaff") ... score = abjad.Score([staff], name="Score") ... time_signature = abjad.TimeSignature(pair) ... leaf = abjad.select.leaf(staff, 0) ... abjad.attach(time_signature, leaf) ... return score ...
Divides duration of 3/16 into increasing number of parts:
>>> score = make_score((1, 2, 2), (3, 16)) >>> abjad.show(score)
>>> score = make_score((1, 2, 2, 3), (3, 16)) >>> abjad.show(score)
>>> score = make_score((1, 2, 2, 3, 3), (3, 16)) >>> abjad.show(score)
>>> score = make_score((1, 2, 2, 3, 3, 4), (3, 16)) >>> abjad.show(score)
Divides duration of 7/16 into increasing number of parts:
>>> score = make_score((1,), (7, 16)) >>> abjad.show(score)
>>> score = make_score((1, 2), (7, 16)) >>> abjad.show(score)
>>> score = make_score((1, 2, 4), (7, 16)) >>> abjad.show(score)
>>> score = make_score((1, 2, 4, 1), (7, 16)) >>> abjad.show(score)
>>> score = make_score((1, 2, 4, 1, 2), (7, 16)) >>> abjad.show(score)
>>> score = make_score((1, 2, 4, 1, 2, 4), (7, 16)) >>> abjad.show(score)
Interprets negative integers in
ratio
as rests:>>> score = make_score((1, 1, 1, -1, 1), (1, 4)) >>> abjad.show(score)
>>> score = make_score((3, -2, 2), (1, 4)) >>> abjad.show(score)
Works with nonassignable rests:
>>> score = make_score((11, -5), (7, 16)) >>> abjad.show(score)
Reduces integers in
ratio
relative to each other:>>> score = make_score((1, 1, 1), (1, 4)) >>> abjad.show(score)
>>> score = make_score((4, 4, 4), (1, 4)) >>> abjad.show(score)