LeafMaker

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.core" { graph [label="abjad.core"]; node [color=1]; "abjad.core.LeafMaker.LeafMaker" [URL="../api/abjad/core/LeafMaker.html#abjad.core.LeafMaker.LeafMaker", color=black, fontcolor=white, label="Leaf\nMaker", target=_top]; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/core/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; "abjad.system.AbjadValueObject.AbjadValueObject" [URL="../api/abjad/core/../system/AbjadValueObject.html#abjad.system.AbjadValueObject.AbjadValueObject", label="Abjad\nValue\nObject", target=_top]; "abjad.system.AbjadObject.AbjadObject" -> "abjad.system.AbjadValueObject.AbjadValueObject"; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadValueObject.AbjadValueObject" -> "abjad.core.LeafMaker.LeafMaker"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }

class abjad.core.LeafMaker.LeafMaker(decrease_monotonic=True, forbidden_duration=None, metrical_hierarchy=None, skips_instead_of_rests=False, repeat_ties=False, use_multimeasure_rests=False)

Leaf-maker.

Integer and string elements in pitches result in notes:

>>> maker = abjad.LeafMaker()
>>> pitches = [2, 4, 'F#5', 'G#5']
>>> duration = abjad.Duration(1, 4)
>>> leaves = maker(pitches, duration)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff) 

Tuple elements in pitches result in chords:

>>> maker = abjad.LeafMaker()
>>> pitches = [(0, 2, 4), ('F#5', 'G#5', 'A#5')]
>>> duration = abjad.Duration(1, 2)
>>> leaves = maker(pitches, duration)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff) 

None-valued elements in pitches result in rests:

>>> maker = abjad.LeafMaker()
>>> pitches = 4 * [None]
>>> durations = [abjad.Duration(1, 4)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> staff.lilypond_type = 'RhythmicStaff'
>>> abjad.show(staff) 

You can mix and match values passed to pitches:

>>> maker = abjad.LeafMaker()
>>> pitches = [(0, 2, 4), None, 'C#5', 'D#5']
>>> durations = [abjad.Duration(1, 4)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff) 

Works with segments:

>>> maker = abjad.LeafMaker()
>>> pitches = abjad.PitchSegment("e'' ef'' d'' df'' c''")
>>> durations = [abjad.Duration(1, 4)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff) 

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

>>> maker = abjad.LeafMaker()
>>> pitches = ['C5']
>>> durations = 2 * [abjad.Duration(3, 8), abjad.Duration(1, 8)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff) 

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

>>> maker = abjad.LeafMaker()
>>> pitches = "c'' d'' e'' f''"
>>> durations = [abjad.Duration(1, 4)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff) 

Elements in durations with non-power-of-two denominators result in tuplet-nested leaves:

>>> maker = abjad.LeafMaker()
>>> pitches = ['D5']
>>> durations = 3 * [abjad.Duration(1, 3)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff) 

Set decrease_monotonic to true to return nonassignable durations tied from greatest to least:

>>> maker = abjad.LeafMaker()
>>> pitches = ['D#5']
>>> durations = [abjad.Duration(13, 16)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> time_signature = abjad.TimeSignature((13, 16))
>>> abjad.attach(time_signature, staff[0])
>>> abjad.show(staff) 

Set decrease_monotonic to false to return nonassignable durations tied from least to greatest:

>>> maker = abjad.LeafMaker(decrease_monotonic=False)
>>> pitches = ['E5']
>>> durations = [abjad.Duration(13, 16)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> time_signature = abjad.TimeSignature((13, 16))
>>> abjad.attach(time_signature, staff[0])
>>> abjad.show(staff) 

Set forbidden_duration to avoid notes greater than or equal to a certain written duration:

>>> maker = abjad.LeafMaker(
...     forbidden_duration=abjad.Duration(1, 2),
...     )
>>> pitches = "f' g'"
>>> durations = [abjad.Duration(5, 8)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> time_signature = abjad.TimeSignature((5, 4))
>>> abjad.attach(time_signature, staff[0])
>>> abjad.show(staff) 

You may set forbidden_duration and decrease_monotonic together:

>>> maker = abjad.LeafMaker(
...     forbidden_duration=abjad.Duration(1, 2),
...     decrease_monotonic=False,
...     )
>>> pitches = "f' g'"
>>> durations = [abjad.Duration(5, 8)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> time_signature = abjad.TimeSignature((5, 4))
>>> abjad.attach(time_signature, staff[0])
>>> abjad.show(staff) 

Produces diminished tuplets:

>>> maker = abjad.LeafMaker()
>>> pitches = "f'"
>>> durations = [abjad.Duration(5, 14)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> time_signature = abjad.TimeSignature((5, 14))
>>> leaf = abjad.inspect(staff).leaf(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:

>>> maker = abjad.LeafMaker(use_multimeasure_rests=True)
>>> pitches = [None]
>>> durations = [abjad.Duration(3, 8), abjad.Duration(5, 8)]
>>> leaves = maker(pitches, durations)
>>> leaves
Selection([MultimeasureRest('R1 * 3/8'), MultimeasureRest('R1 * 5/8')])
>>> staff = abjad.Staff([
...     abjad.Measure((3, 8), [leaves[0]]),
...     abjad.Measure((5, 8), [leaves[1]]),
...     ])
>>> staff.lilypond_type = 'RhythmicStaff'
>>> abjad.show(staff) 

Uses repeat ties:

>>> maker = abjad.LeafMaker(repeat_ties=True)
>>> pitches = [0]
>>> durations = [abjad.Duration(13, 16)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff) 

Works with numbered pitch-class:

>>> maker = abjad.LeafMaker()
>>> pitches = [abjad.NumberedPitchClass(6)]
>>> durations = [abjad.Duration(13, 16)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> abjad.show(staff) 

Makes skips instead of rests:

>>> maker = abjad.LeafMaker(skips_instead_of_rests=True)
>>> pitches = [None]
>>> durations = [abjad.Duration(13, 16)]
>>> maker(pitches, durations)
Selection([Skip('s2.'), Skip('s16')])

Returns selection of leaves.


Attributes Summary

__call__ Calls leaf-maker on pitches and durations.
decrease_monotonic Is true when durations decrease monotonically.
forbidden_duration Gets forbidden written duration.
metrical_hierarchy Gets metrical hierarchy.
repeat_ties Is true when ties are repeat ties.
skips_instead_of_rests Is true when skips appear in place of rests.
use_multimeasure_rests Is true when rests are multimeasure.

Special methods

__call__(pitches, durations)

Calls leaf-maker on pitches and durations.

Returns selection.

(AbjadValueObject).__copy__(*arguments)

Copies Abjad value object.

Returns new Abjad value object.

(AbjadValueObject).__eq__(argument)

Is true when all initialization values of Abjad value object equal the initialization values of argument.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(AbjadValueObject).__hash__()

Hashes Abjad value object.

Returns integer.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Read-only properties

decrease_monotonic

Is true when durations decrease monotonically.

Returns true, false or none.

forbidden_duration

Gets forbidden written duration.

Returns duration or none.

metrical_hierarchy

Gets metrical hierarchy.

Returns metrical hierarchy or none.

repeat_ties

Is true when ties are repeat ties.

Return type:bool
skips_instead_of_rests

Is true when skips appear in place of rests.

Returns true, false or none.

use_multimeasure_rests

Is true when rests are multimeasure.

Returns true, false or none.