rtm

Rhythm tree functions.

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_abjadext.rmakers.makers" { graph [label="abjadext.rmakers.makers"]; node [color=1]; "abjadext.rmakers.makers.RhythmMaker" [label="Rhythm\nMaker"]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.7/library/functions.html#object", label=object, target=_top]; } subgraph "cluster_evans.rtm" { graph [label="evans.rtm"]; node [color=3]; "evans.rtm.RTMMaker" [URL="../api/evans/rtm.html#evans.rtm.RTMMaker", color=black, fontcolor=white, label=RTMMaker, target=_top]; "evans.rtm.RhythmTreeQuantizer" [URL="../api/evans/rtm.html#evans.rtm.RhythmTreeQuantizer", color=black, fontcolor=white, label="Rhythm\nTree\nQuantizer", target=_top]; } "abjadext.rmakers.makers.RhythmMaker" -> "evans.rtm.RTMMaker"; "builtins.object" -> "abjadext.rmakers.makers.RhythmMaker"; "builtins.object" -> "evans.rtm.RhythmTreeQuantizer"; }


Classes

RhythmTreeQuantizer

class evans.rtm.RhythmTreeQuantizer[source]

Attributes Summary

__call__

Call self as a function.


Special methods

overridden __call__(string)[source]

Call self as a function.


Functions

flatten_tree_level

funnel_inner_tree_to_x

funnel_tree_to_x

nested_list_to_rtm

rotate_tree

evans.rtm.flatten_tree_level(rtm, recurse=False)[source]
>>> string = "(1 (1 (1 ((2 (1 1 1)) 2 2 1))))"
>>> rhythm_tree_container_ = evans.flatten_tree_level(
...     string,
...     recurse=False,
... )
>>> strings = [string, rhythm_tree_container_]
>>> durations = [abjad.Duration(1, 1), abjad.Duration(1, 1)]
>>> h = evans.RhythmHandler(evans.RTMMaker(strings), forget=False)
>>> selections = h(durations)
>>> staff = abjad.Staff()
>>> staff.extend(selections)
>>> abjad.show(staff)  
>>> string = "(1 (1 (1 ((2 (1 1 1)) 2 2 1))))"
>>> rhythm_tree_container_ = evans.flatten_tree_level(
...     string,
...     recurse=True,
... )
>>> strings = [string, rhythm_tree_container_]
>>> durations = [abjad.Duration(1, 1), abjad.Duration(1, 1)]
>>> h = evans.RhythmHandler(evans.RTMMaker(strings), forget=False)
>>> selections = h(durations)
>>> staff = abjad.Staff()
>>> staff.extend(selections)
>>> abjad.show(staff)  
evans.rtm.funnel_inner_tree_to_x(rtm_string, x=1)[source]
>>> rtm = "(1 (3 (2 (1 2 1 1)) 3))"
>>> for x in evans.funnel_inner_tree_to_x(rtm_string=rtm, x=5):
...     print(x)
... 
(1 (3 (2 (1 2 1 1)) 3))
(1 (4 (3 (2 3 2 2)) 4))
(1 (5 (4 (3 4 3 3)) 5))
(1 (5 (5 (4 5 4 4)) 5))
(1 (5 (5 (5 5 5 5)) 5))
>>> rtm_list = evans.funnel_inner_tree_to_x(rtm_string=rtm, x=5)
>>> maker = evans.RTMMaker(rtm=rtm_list)
>>> divisions = [abjad.Duration(1, 1) for _ in rtm_list]
>>> selections = maker(divisions)
>>> staff = abjad.Staff()
>>> staff.extend(selections)
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> file = abjad.LilyPondFile(
...     items=[score],
...     includes=["abjad.ily"],
...     global_staff_size=16,
... )
>>> abjad.show(file)  
>>> rtm_list = evans.funnel_inner_tree_to_x(
...     rtm_string="(1 ((4 (1 1 (2 (3 1)))) 1))", x=1
... )
>>> maker = evans.RTMMaker(rtm=rtm_list)
>>> divisions = [abjad.Duration(1, 1) for _ in rtm_list]
>>> selections = maker(divisions)
>>> staff = abjad.Staff()
>>> staff.extend(selections)
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> file = abjad.LilyPondFile(
...     items=[score],
...     includes=["abjad.ily"],
...     global_staff_size=16,
... )
>>> abjad.show(file)  
evans.rtm.funnel_tree_to_x(rtm, x)[source]
evans.rtm.nested_list_to_rtm(nested_list)[source]
>>> nested_list = [1, [1, 1, [1, [1, 1]], 1]]
>>> rtm_string = evans.nested_list_to_rtm(nested_list)
>>> print(rtm_string)
(1 (1 1 (1 (1 1)) 1))
>>> rtm_list = [rtm_string]
>>> maker = evans.RTMMaker(rtm=rtm_list)
>>> divisions = [abjad.Duration(1, 1)]
>>> selections = maker(divisions)
>>> staff = abjad.Staff()
>>> staff.extend(selections)
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> file = abjad.LilyPondFile(
...     items=[score],
...     includes=["abjad.ily"],
...     global_staff_size=16,
... )
>>> abjad.show(file)  
evans.rtm.rotate_tree(rtm_string, n=1)[source]
>>> rtm = "(1 (2 (1 (1 2)) 1))"
>>> for x in range(6):
...     new_rtm = evans.rotate_tree(rtm, x)
...     print(new_rtm)
... 
(1 (2 (1 (1 2)) 1))
(1 (1 (1 (2 1)) 2))
(1 (1 (2 (1 2)) 1))
(1 (2 (1 (2 1)) 1))
(1 (1 (2 (1 1)) 2))
(1 (2 (1 (1 2)) 1))
>>> rtm_list = [evans.rotate_tree(rtm, x) for x in range(6)]
>>> maker = evans.RTMMaker(rtm=rtm_list)
>>> divisions = [abjad.Duration(1, 1) for _ in rtm_list]
>>> selections = maker(divisions)
>>> staff = abjad.Staff()
>>> staff.extend(selections)
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> file = abjad.LilyPondFile(
...     items=[score],
...     includes=["abjad.ily"],
...     global_staff_size=16,
... )
>>> abjad.show(file)  
>>> divisions = [
...     abjad.Duration(1, 2),
...     abjad.Duration(1, 4),
...     abjad.Duration(1, 4),
...     abjad.Duration(1, 1),
...     abjad.Duration(1, 4),
...     abjad.Duration(3, 4),
...     abjad.Duration(2, 1),
...     abjad.Duration(5, 8),
...     abjad.Duration(3, 8),
... ]
>>> selections = maker(divisions)
>>> staff = abjad.Staff()
>>> staff.extend(selections)
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> file = abjad.LilyPondFile(
...     items=[score],
...     includes=["abjad.ily"],
...     global_staff_size=16,
... )
>>> abjad.show(file)  

Rhythm-makers

RTMMaker

class evans.rtm.RTMMaker(rtm, tie_across_divisions=False)[source]
>>> rtm = ["(1 (1 1))", "(1 (1 1 1))", "(1 (1 1 1 1))"]
>>> maker = evans.RTMMaker(rtm=rtm)
>>> divisions = [abjad.Duration(1, 1), abjad.Duration(1, 1), abjad.Duration(1, 1)]
>>> selections = maker(divisions)
>>> staff = abjad.Staff()
>>> staff.extend(selections)
>>> score = abjad.Score([staff])
>>> moment = "#(ly:make-moment 1 25)"
>>> abjad.setting(score).proportional_notation_duration = moment
>>> file = abjad.LilyPondFile(
...     items=[score],
...     includes=["abjad.ily"],
...     global_staff_size=16,
... )
>>> abjad.show(file)  

Attributes Summary

__call__

Calls rhythm-maker.

__repr__

Delegates to storage format manager.

__str__

Return str(self).


Special methods

overridden __call__(divisions, previous_state=- 1)[source]

Calls rhythm-maker.

(RhythmMaker).__eq__(argument)

Delegates to storage format manager.

Return type

bool

(RhythmMaker).__hash__()

Delegates to storage format manager.

Return type

int

overridden __repr__()[source]

Delegates to storage format manager.

overridden __str__()[source]

Return str(self).


Read-only properties

(RhythmMaker).previous_state

Gets previous state dictionary.

Return type

OrderedDict

(RhythmMaker).spelling

Gets duration specifier.

Return type

Optional[Spelling]

(RhythmMaker).state

Gets state dictionary.

Return type

OrderedDict

(RhythmMaker).tag

Gets tag.

Return type

Optional[Tag]