makers


Functions

make_durations

Changes list of arbitrary items to list of durations.

make_leaves

Makes leaves from pitch_lists and durations.

make_notes

Makes notes from pitches and durations.

make_pitch_lists

Changes list or string argument to list of pitch lists.

make_pitches

Changes list or string argument to list of named pitches.

tuplet_from_ratio_and_pair

Makes tuplet from ratio and pair.

tweak_tuplet_bracket_edge_height

Tweaks tuplet bracket edge height of incomplete tuplets in argument.

tweak_tuplet_number_text

Tweaks tuplet number text for tuplets in argument.

abjad.makers.make_durations(items: list) list[Duration][source]

Changes list of arbitrary items to list of durations.

>>> abjad.makers.make_durations([(1, 8), (1, 2), (1, 16)])
[Duration(1, 8), Duration(1, 2), Duration(1, 16)]
abjad.makers.make_leaves(pitch_lists: list[list[NamedPitch]], durations: list[Duration], *, forbidden_note_duration: Duration | None = None, forbidden_rest_duration: Duration | None = None, increase_monotonic: bool = False, skips_instead_of_rests: bool = False, tag: Tag | None = None, use_multimeasure_rests: bool = False)[source]

Makes leaves from pitch_lists and durations.

Interprets empty pitch lists as rests:

>>> items = [[], [], [], []]
>>> pitch_lists = abjad.makers.make_pitch_lists(items)
>>> leaves = abjad.makers.make_leaves(pitch_lists, [abjad.Duration(1, 4)])
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff)  

Interprets length-1 pitch lists as notes:

>>> items = [2, 4, "F#5", "G#5"]
>>> pitch_lists = abjad.makers.make_pitch_lists(items)
>>> leaves = abjad.makers.make_leaves(pitch_lists, [abjad.Duration(1, 4)])
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff)  

Interprets pitch lists with length greater than 1 as chords:

>>> items = [[0, 2, 4], ["F#5", "G#5", "A#5"]]
>>> pitch_lists = abjad.makers.make_pitch_lists(items)
>>> leaves = abjad.makers.make_leaves(pitch_lists, [abjad.Duration(1, 4)])
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff)  

Interprets mixed types of pitch list like this:

>>> items = [[0, 2, 4], [], "C#5", "D#5"]
>>> pitch_lists = abjad.makers.make_pitch_lists(items)
>>> leaves = abjad.makers.make_leaves(pitch_lists, [abjad.Duration(1, 4)])
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff)  

Interprets nondyadic durations as (possibly incomplete) tuplets:

>>> pitch_list = [abjad.NamedPitch("d''")]
>>> durations = [abjad.Duration(1, 3)]
>>> leaves = abjad.makers.make_leaves([pitch_list], durations)
>>> abjad.makers.tweak_tuplet_bracket_edge_height(leaves)
>>> staff = abjad.Staff(leaves)
>>> score = abjad.Score([staff])
>>> abjad.override(score).TupletBracket.bracket_visibility = True
>>> abjad.setting(score).tupletFullLength = True
>>> abjad.show(score)  
>>> pitch_list = [abjad.NamedPitch("d''")]
>>> durations = 2 * [abjad.Duration(1, 3)]
>>> leaves = abjad.makers.make_leaves([pitch_list], durations)
>>> abjad.makers.tweak_tuplet_bracket_edge_height(leaves)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff)  
>>> pitch_list = [abjad.NamedPitch("d''")]
>>> durations = 3 * [abjad.Duration(1, 3)]
>>> leaves = abjad.makers.make_leaves([pitch_list], durations)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff)  
>>> pitch_list = [abjad.NamedPitch("d''")]
>>> leaves = abjad.makers.make_leaves([pitch_list], [abjad.Duration(5, 14)])
>>> abjad.makers.tweak_tuplet_bracket_edge_height(leaves)
>>> staff = abjad.Staff(leaves)
>>> time_signature = abjad.TimeSignature((5, 14))
>>> leaf = abjad.get.leaf(staff, 0)
>>> abjad.attach(time_signature, leaf)
>>> score = abjad.Score([staff], name="Score")
>>> abjad.show(score)  

Reads pitch_lists cyclically when the length of pitch_lists is less than the length of durations:

>>> pitch_lists = abjad.makers.make_pitch_lists([[12, 14], []])
>>> pairs = [(1, 16), (1, 16), (1, 8), (1, 8), (1, 8)]
>>> durations = abjad.makers.make_durations(pairs)
>>> leaves = abjad.makers.make_leaves(pitch_lists, durations)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff)  

Reads durations cyclically when the length of durations is less than the length of pitch_lists:

>>> pitch_lists = abjad.makers.make_pitch_lists([[12, 14], [], 10, 9, 7])
>>> durations = [abjad.Duration(1, 16), abjad.Duration(1, 8)]
>>> leaves = abjad.makers.make_leaves(pitch_lists, durations)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff)  

Avoids durations greater than or equal to forbidden_note_duration:

>>> pitch_lists = abjad.makers.make_pitch_lists("f' g'")
>>> durations = [abjad.Duration(5, 8)]
>>> leaves = abjad.makers.make_leaves(pitch_lists, durations)
>>> 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)  
>>> leaves = abjad.makers.make_leaves(
...     pitch_lists,
...     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)  

Writes tied durations in monotonically decreasing order by default:

>>> pitch_list = [abjad.NamedPitch("ds''")]
>>> durations = [abjad.Duration(13, 16)]
>>> leaves = abjad.makers.make_leaves([pitch_list], 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)  

Writes tied durations in monotonically increasing order when increase_monotonic is true:

>>> leaves = abjad.makers.make_leaves(
...     [[abjad.NamedPitch("e''")]],
...     [abjad.Duration(13, 16)],
...     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)  

Interprets empty pitch lists as skips when skips_instead_of_rests is true:

>>> durations = [abjad.Duration(13, 16)]
>>> abjad.makers.make_leaves([[]], durations, skips_instead_of_rests=True)
[Skip('s2.'), Skip('s16')]

Interprets empty pitch lists as multimeasure rests when use_multimeasure_rests is true:

>>> durations = [abjad.Duration(3, 8), abjad.Duration(5, 8)]
>>> leaves = abjad.makers.make_leaves(
...     [[]],
...     durations,
...     use_multimeasure_rests=True,
... )
>>> staff = abjad.Staff(leaves)
>>> abjad.attach(abjad.TimeSignature((3, 8)), leaves[0])
>>> abjad.attach(abjad.TimeSignature((5, 8)), leaves[1])
>>> score = abjad.Score([staff], name="Score")
>>> abjad.show(score)  
abjad.makers.make_notes(pitches: list[NamedPitch], durations: list[Duration], *, increase_monotonic: bool = False, tag: Tag | None = None) list[Note | Tuplet][source]

Makes notes from pitches and durations.

Cycles through pitches when the length of pitches is less than the length of durations:

>>> pitches = abjad.makers.make_pitches("c' d'")
>>> pairs = [(1, 16), (1, 16), (1, 8), (1, 8), (1, 8)]
>>> durations = abjad.makers.make_durations(pairs)
>>> 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 = abjad.makers.make_pitches("c' d' e' f' g'")
>>> durations = abjad.makers.make_durations([(1, 16), (1, 8)])
>>> notes = abjad.makers.make_notes(pitches, durations)
>>> staff = abjad.Staff(notes)
>>> abjad.show(staff)  

Interprets nondyadic durations as (possibly incomplete) tuplets:

>>> pitches = abjad.makers.make_pitches([0])
>>> durations = abjad.makers.make_durations([(1, 16), (1, 12), (1, 8)])
>>> components = abjad.makers.make_notes(pitches, durations)
>>> abjad.makers.tweak_tuplet_bracket_edge_height(components)
>>> staff = abjad.Staff(components)
>>> score = abjad.Score([staff])
>>> abjad.override(score).TupletBracket.bracket_visibility = True
>>> abjad.setting(score).proportionalNotationDuration = "#1/24"
>>> abjad.setting(score).tupletFullLength = True
>>> abjad.show(score)  

Writes tied durations in monotonically decreasing order by default:

>>> pitches = abjad.makers.make_pitches([0])
>>> durations = [abjad.Duration(13, 16)]
>>> notes = abjad.makers.make_notes(pitches, durations)
>>> staff = abjad.Staff(notes)
>>> abjad.show(staff)  

Writes tied durations in monotonically increasing order when increase_monotonic is true:

>>> pitches = abjad.makers.make_pitches([0])
>>> durations = [abjad.Duration(13, 16)]
>>> notes = abjad.makers.make_notes(pitches, durations, increase_monotonic=True)
>>> staff = abjad.Staff(notes)
>>> abjad.show(staff)  
abjad.makers.make_pitch_lists(argument: list | str) list[list[NamedPitch]][source]

Changes list or string argument to list of pitch lists.

>>> abjad.makers.make_pitch_lists([3, None, [4, 5]])
[[NamedPitch("ef'")], [], [NamedPitch("e'"), NamedPitch("f'")]]
>>> abjad.makers.make_pitch_lists([3, [], [4, 5]])
[[NamedPitch("ef'")], [], [NamedPitch("e'"), NamedPitch("f'")]]
>>> abjad.makers.make_pitch_lists("e'' ef'' d''")
[[NamedPitch("e''")], [NamedPitch("ef''")], [NamedPitch("d''")]]

Use this function to format input for abjad.makers.make_leaves().

abjad.makers.make_pitches(argument: list | str) list[NamedPitch][source]

Changes list or string argument to list of named pitches.

>>> abjad.makers.make_pitches([3, 16, 16.5])
[NamedPitch("ef'"), NamedPitch("e''"), NamedPitch("eqs''")]
>>> abjad.makers.make_pitches("ef' e'' eqs''")
[NamedPitch("ef'"), NamedPitch("e''"), NamedPitch("eqs''")]
>>> abjad.makers.make_pitches(["ef'", "e''", "eqs''"])
[NamedPitch("ef'"), NamedPitch("e''"), NamedPitch("eqs''")]
>>> abjad.makers.make_pitches([3, "e''", abjad.NamedPitch("eqs''")])
[NamedPitch("ef'"), NamedPitch("e''"), NamedPitch("eqs''")]

Use this function to format input for abjad.makers.make_notes().

abjad.makers.tuplet_from_ratio_and_pair(ratio: tuple[int, ...], pair: tuple[int, int], *, tag: Tag | None = None) Tuplet[source]

Makes tuplet from ratio and pair.

Helper function:

>>> def make_score(ratio, pair):
...     tuplet = abjad.makers.tuplet_from_ratio_and_pair(ratio, pair)
...     abjad.makers.tweak_tuplet_number_text(tuplet)
...     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)  
abjad.makers.tweak_tuplet_bracket_edge_height(argument) None[source]

Tweaks tuplet bracket edge height of incomplete tuplets in argument.

A tuplet is defined as incomplete when the denominator d of the tuplet’s duration n/d is nondyadic. For example, the duration of \tuplet 3/2 { c'4 d'4 } is nondyadic because the denominator of 2/3 * 2/4 = 1/3 is 3. But the duration of \tuplet 3/2 { c'4 d'4 e'4 } is dyadic because the denominator of 2/3 * 3/4 = 1/2 is 2.

By default, LilyPond engraves all tuplets with a complete bracket, even those that are incomplete, like the first tuplet below:

>>> string = r"\tuplet 3/2 { c'4 d'4 } \tuplet 3/2 { c'4 d'4 e'4 }"
>>> staff = abjad.Staff(string)
>>> abjad.show(staff)  

Call abjad.makers.tweak_tuplet_bracket_edge_height() to adjust the right edge of incomplete tuplets:

>>> abjad.makers.tweak_tuplet_bracket_edge_height(staff)
>>> abjad.show(staff)  
abjad.makers.tweak_tuplet_number_text(argument) None[source]

Tweaks tuplet number text for tuplets in argument. Sets tuplet number text equal to #tuplet-number::calc-fraction-text when any of these conditions is true:

  • tuplet is an augmentation (like 3:4), or

  • tuplet is nondyadic (like 4:3), or

  • denominator of tuplet multiplier is 1

Does not tweak tuplets for which none of these conditions holds.