LeafMaker

class scoretools.LeafMaker(decrease_durations_monotonically=True, forbidden_written_duration=None, is_diminution=True, metrical_hierarchy=None, skips_instead_of_rests=False, use_messiaen_style_ties=False, use_multimeasure_rests=False)

Leaf-maker.

>>> import abjad

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)
>>> 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)
>>> 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.context_name = 'RhythmicStaff'
>>> 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)
>>> 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)
>>> 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)
>>> 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)
>>> 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)
>>> show(staff) 

Set decrease_durations_monotonically 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])
>>> show(staff) 

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

>>> maker = abjad.LeafMaker(
...     decrease_durations_monotonically=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])
>>> show(staff) 

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

>>> maker = abjad.LeafMaker(
...     forbidden_written_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])
>>> show(staff) 

You may set forbidden_written_duration and decrease_durations_monotonically together:

>>> maker = abjad.LeafMaker(
...     forbidden_written_duration=abjad.Duration(1, 2),
...     decrease_durations_monotonically=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])
>>> show(staff) 

Set is_diminution to true to produce diminished tuplets:

>>> maker = abjad.LeafMaker(is_diminution=True)
>>> 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).get_leaf(0)
>>> abjad.attach(time_signature, leaf)
>>> show(staff) 

This is default behavior.

Set is_diminution to false to produce agumented tuplets:

>>> maker = abjad.LeafMaker(is_diminution=False)
>>> 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).get_leaf(0)
>>> abjad.attach(time_signature, leaf)
>>> show(staff) 

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.context_name = 'RhythmicStaff'
>>> show(staff) 

Uses Messiaen-style ties:

>>> maker = abjad.LeafMaker(use_messiaen_style_ties=True)
>>> pitches = [0]
>>> durations = [abjad.Duration(13, 16)]
>>> leaves = maker(pitches, durations)
>>> staff = abjad.Staff(leaves)
>>> 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)
>>> 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.

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" [color=1, group=0, label=AbjadValueObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.abctools.AbjadValueObject.AbjadValueObject"; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_scoretools { graph [label=scoretools]; "abjad.tools.scoretools.LeafMaker.LeafMaker" [color=black, fontcolor=white, group=2, label=<<B>LeafMaker</B>>, shape=box, style="filled, rounded"]; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadValueObject.AbjadValueObject" -> "abjad.tools.scoretools.LeafMaker.LeafMaker"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

decrease_durations_monotonically Is true when durations decrease monotonically.
forbidden_written_duration Gets forbidden written duration.
is_diminution Is true when tuplets notate diminutions.
metrical_hierarchy Gets metrical hierarchy.
skips_instead_of_rests Is true when skips appear in place of rests.
use_messiaen_style_ties Is true when ties are Messiaen-style.
use_multimeasure_rests Is true when rests are multimeasure.
__call__(pitches, durations) Calls leaf-maker on pitches and durations.
__copy__(*arguments) Copies Abjad value object.
__eq__(argument) Is true when all initialization values of Abjad value object equal the initialization values of argument.
__format__([format_specification]) Formats Abjad object.
__hash__() Hashes Abjad value object.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

LeafMaker.decrease_durations_monotonically

Is true when durations decrease monotonically. Otherwise false.

Returns true, false or none.

LeafMaker.forbidden_written_duration

Gets forbidden written duration.

Returns duration or none.

LeafMaker.is_diminution

Is true when tuplets notate diminutions. Otherwise false.

Returns true, false or none.

LeafMaker.metrical_hierarchy

Gets metrical hierarchy.

Returns metrical hierarchy or none.

LeafMaker.skips_instead_of_rests

Is true when skips appear in place of rests. Otherwise false.

Returns true, false or none.

LeafMaker.use_messiaen_style_ties

Is true when ties are Messiaen-style. Otherwise false.

Returns true, false or none.

LeafMaker.use_multimeasure_rests

Is true when rests are multimeasure. Otherwise false.

Returns true, false or none.

Special methods

LeafMaker.__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).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.