makers


Functions

make_leaves

Makes leaves from pitches and durations.

make_notes

Makes notes from pitches and durations.

tuplet_from_duration_and_ratio

Makes tuplet from duration and ratio.

tuplet_from_leaf_and_ratio

Makes tuplet from leaf and ratio.

tuplet_from_ratio_and_pair

Makes tuplet from nonreduced ratio and nonreduced fraction.

abjad.makers.make_leaves(pitches, durations, *, forbidden_note_duration=None, forbidden_rest_duration=None, skips_instead_of_rests=False, increase_monotonic=False, tag=None, use_multimeasure_rests=False)[source]

Makes leaves from pitches and durations.

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 of pitches is less than the length of durations:

>>> 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 of durations is less than the length of pitches:

>>> 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 and increase_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=False, tag=None)[source]

Makes notes from pitches and durations.

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 of pitches is less than the length of durations:

>>> 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 of durations is less than the length of pitches:

>>> 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)  
Return type:

list[Note | Tuplet]

abjad.makers.tuplet_from_duration_and_ratio(duration, ratio, *, increase_monotonic=False, tag=None)[source]

Makes tuplet from duration and ratio.

Makes tupletted leaves strictly without dots when all ratio equal 1:

>>> tuplet = abjad.makers.tuplet_from_duration_and_ratio(
...     abjad.Duration(3, 16),
...     (1, 1, 1, -1, -1),
... )
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  

Allows tupletted leaves to return with dots when some ratio do not equal 1:

>>> tuplet = abjad.makers.tuplet_from_duration_and_ratio(
...     abjad.Duration(3, 16),
...     (1, -2, -2, 3, 3),
... )
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  

Interprets nonassignable ratio according to increase_monotonic:

>>> tuplet = abjad.makers.tuplet_from_duration_and_ratio(
...     abjad.Duration(3, 16),
...     (5, -1, 5),
...     increase_monotonic=True,
... )
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  

Makes augmented tuplet from duration and ratio and encourages dots:

>>> tuplet = abjad.makers.tuplet_from_duration_and_ratio(
...     abjad.Duration(3, 16),
...     (1, 1, 1, -1, -1),
... )
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  

Interprets nonassignable ratio according to increase_monotonic:

>>> tuplet = abjad.makers.tuplet_from_duration_and_ratio(
...     abjad.Duration(3, 16),
...     (5, -1, 5),
...     increase_monotonic=True,
... )
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  

Makes diminished tuplet from duration and nonzero integer ratio.

Makes tupletted leaves strictly without dots when all ratio equal 1:

>>> tuplet = abjad.makers.tuplet_from_duration_and_ratio(
...     abjad.Duration(3, 16),
...     (1, 1, 1, -1, -1),
... )
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  

Allows tupletted leaves to return with dots when some ratio do not equal 1:

>>> tuplet = abjad.makers.tuplet_from_duration_and_ratio(
...     abjad.Duration(3, 16),
...     (1, -2, -2, 3, 3),
... )
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  

Interprets nonassignable ratio according to increase_monotonic:

>>> tuplet = abjad.makers.tuplet_from_duration_and_ratio(
...     abjad.Duration(3, 16),
...     (5, -1, 5),
...     increase_monotonic=True,
... )
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  

Makes diminished tuplet from duration and ratio and encourages dots:

>>> tuplet = abjad.makers.tuplet_from_duration_and_ratio(
...     abjad.Duration(3, 16),
...     (1, 1, 1, -1, -1),
... )
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  

Interprets nonassignable ratio according to direction:

>>> tuplet = abjad.makers.tuplet_from_duration_and_ratio(
...     abjad.Duration(3, 16),
...     (5, -1, 5),
...     increase_monotonic=True,
... )
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  

Reduces ratio relative to each other.

Interprets negative ratio as rests.

Return type:

Tuplet

abjad.makers.tuplet_from_leaf_and_ratio(leaf, ratio)[source]

Makes tuplet from leaf and ratio. :rtype: Tuplet

>>> note = abjad.Note("c'8.")
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1,))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1, 2))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1, 2, 2))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1, 2, 2, 3))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1, 2, 2, 3, 3))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1, 2, 2, 3, 3, 4))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1,))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1, 2))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1, 2, 2))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1, 2, 2, 3))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1, 2, 2, 3, 3))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_leaf_and_ratio(note, (1, 2, 2, 3, 3, 4))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((3, 16)), tuplet[0])
>>> abjad.show(staff)  
abjad.makers.tuplet_from_ratio_and_pair(ratio, fraction, *, tag=None)[source]

Makes tuplet from nonreduced ratio and nonreduced fraction.

>>> tuplet = abjad.makers.tuplet_from_ratio_and_pair((1,), (7, 16))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((7, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_ratio_and_pair((1, 2), (7, 16))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((7, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_ratio_and_pair((1, 2, 4), (7, 16))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((7, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_ratio_and_pair((1, 2, 4, 1), (7, 16))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((7, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_ratio_and_pair((1, 2, 4, 1, 2), (7, 16))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((7, 16)), tuplet[0])
>>> abjad.show(staff)  
>>> tuplet = abjad.makers.tuplet_from_ratio_and_pair((1, 2, 4, 1, 2, 4), (7, 16))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((7, 16)), tuplet[0])
>>> abjad.show(staff)  

Works with nonassignable rests:

>>> tuplet = abjad.makers.tuplet_from_ratio_and_pair((11, -5), (5, 16))
>>> staff = abjad.Staff(
...     [tuplet],
...     lilypond_type="RhythmicStaff",
... )
>>> score = abjad.Score([staff], name="Score")
>>> abjad.attach(abjad.TimeSignature((7, 16)), tuplet[0])
>>> abjad.show(staff)  

Interprets d as tuplet denominator.

Return type:

Tuplet