make_leaves

scoretools.make_leaves(pitches, durations, decrease_durations_monotonically=True, forbidden_written_duration=None, is_diminution=True, metrical_hiearchy=None, skips_instead_of_rests=False, use_messiaen_style_ties=False, use_multimeasure_rests=False)

Makes leaves.

Example 1. Integer and string elements in pitches result in notes:

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

Example 2. Tuple elements in pitches result in chords:

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

Example 3. None-valued elements in pitches result in rests:

>>> pitches = 4 * [None]
>>> durations = [Duration(1, 4)]
>>> leaves = scoretools.make_leaves(pitches, durations)
>>> staff = Staff(leaves)
>>> staff.context_name = 'RhythmicStaff'
>>> show(staff) 

Example 4. You can mix and match values passed to pitches:

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

Example 5. Read pitches cyclically when the length of pitches is less than the length of durations:

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

Example 6. Read durations cyclically when the length of durations is less than the length of pitches:

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

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

>>> pitches = ['D5']
>>> durations = [Duration(1, 3), Duration(1, 3), Duration(1, 3)]
>>> leaves = scoretools.make_leaves(pitches, durations)
>>> staff = Staff(leaves)
>>> show(staff) 

Example 8. Set decrease_durations_monotonically to true to return nonassignable durations tied from greatest to least:

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

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

>>> pitches = ['E5']
>>> durations = [Duration(13, 16)]
>>> leaves = scoretools.make_leaves(
...     pitches,
...     durations,
...     decrease_durations_monotonically=False,
...     )
>>> staff = Staff(leaves)
>>> time_signature = TimeSignature((13, 16))
>>> attach(time_signature, staff)
>>> show(staff) 

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

>>> pitches = "f' g'"
>>> durations = [Duration(5, 8)]
>>> leaves = scoretools.make_leaves(
...     pitches,
...     durations,
...     forbidden_written_duration=Duration(1, 2),
...     )
>>> staff = Staff(leaves)
>>> time_signature = TimeSignature((5, 4))
>>> attach(time_signature, staff)
>>> show(staff) 

Example 11. You may set forbidden_written_duration and decrease_durations_monotonically together:

>>> pitches = "f' g'"
>>> durations = [Duration(5, 8)]
>>> leaves = scoretools.make_leaves(
...     pitches,
...     durations,
...     forbidden_written_duration=Duration(1, 2),
...     decrease_durations_monotonically=False,
...     )
>>> staff = Staff(leaves)
>>> time_signature = TimeSignature((5, 4))
>>> attach(time_signature, staff)
>>> show(staff) 

Example 12. Set is_diminution to true to produce diminished tuplets:

>>> pitches = "f'"
>>> durations = [Duration(5, 14)]
>>> leaves = scoretools.make_leaves(
...     pitches,
...     durations,
...     is_diminution=True
...     )
>>> staff = Staff(leaves)
>>> time_signature = TimeSignature((5, 14))
>>> attach(time_signature, staff)
>>> show(staff) 

This is default behavior.

Example 13. Set is_diminution to false to produce agumented tuplets:

>>> pitches = "f'"
>>> durations = [Duration(5, 14)]
>>> leaves = scoretools.make_leaves(
...     pitches,
...     durations,
...     is_diminution=False
...     )
>>> staff = Staff(leaves)
>>> time_signature = TimeSignature((5, 14))
>>> attach(time_signature, staff)
>>> show(staff) 

Example 14. None-valued elements in pitches result in multimeasure rests when the multimeasure rest keyword is set:

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

Example 15. Uses Messiaen-style ties:

>>> pitches = [0]
>>> durations = [Duration(13, 16)]
>>> leaves = scoretools.make_leaves(
...     pitches,
...     durations,
...     use_messiaen_style_ties=True,
...     )
>>> staff = Staff(leaves)
>>> show(staff) 

Example 16. Works with numbered pitch-class:

>>> pitches = [pitchtools.NumberedPitchClass(6)]
>>> durations = [Duration(13, 16)]
>>> leaves = scoretools.make_leaves(
...     pitches,
...     durations,
...     )
>>> staff = Staff(leaves)
>>> show(staff) 

Example 17. Makes skips instead of rests:

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

Returns selection of leaves.