rhythmtrees¶
Tools for modeling IRCAM-style rhythm trees.
Classes
Rhythm-tree container. |
|
Rhythm-tree leaf. |
|
Abstract rhythm-tree node. |
|
Rhythm-tree parser. |
- class abjad.rhythmtrees.RhythmTreeContainer(children=None, preprolated_duration=Duration(1, 1), name=None)[source]¶
Rhythm-tree container.
Initializes rhythm-tree container:
>>> container = abjad.rhythmtrees.RhythmTreeContainer( ... preprolated_duration=abjad.Duration(1), ... children=[], ... ) >>> container RhythmTreeContainer((1, 1))
Similar to Abjad containers,
RhythmTreeContainer
supports a list interface, and can be appended, extended, indexed and so forth by otherRhythmTreeMixin
subclasses:>>> leaf_a = abjad.rhythmtrees.RhythmTreeLeaf( ... preprolated_duration=abjad.Duration(1) ... ) >>> leaf_b = abjad.rhythmtrees.RhythmTreeLeaf( ... preprolated_duration=abjad.Duration(2) ... ) >>> container.extend([leaf_a, leaf_b]) >>> for _ in container: ... _ ... RhythmTreeLeaf(preprolated_duration=Duration(1, 1), is_pitched=True) RhythmTreeLeaf(preprolated_duration=Duration(2, 1), is_pitched=True)
>>> another_container = abjad.rhythmtrees.RhythmTreeContainer( ... preprolated_duration=abjad.Duration(2) ... ) >>> another_container.append( ... abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=abjad.Duration(3)) ... ) >>> another_container.append(container[1]) >>> container.append(another_container) >>> for _ in container: ... _ ... RhythmTreeLeaf(preprolated_duration=Duration(1, 1), is_pitched=True) RhythmTreeContainer((2, 3))
Call
RhythmTreeContainer
with a duration to make tuplets:>>> components = container((1, 4)) >>> tuplet = components[0] >>> abjad.show(tuplet)
Attributes Summary
Concatenate containers self and argument.
Makes list of leaves and /or tuplets equal to
pulse_duration
.Graphs rhythm-tree container.
Concatenates containers argument and self.
Gets interpreter representation of rhythm-tree container.
Gets rhythm-tree container RTM format.
Special methods
- __add__(argument)[source]¶
Concatenate containers self and argument. The operation c = a + b returns a new RhythmTreeContainer c with the content of both a and b, and a preprolated_duration equal to the sum of the durations of a and b. The operation is non-commutative: the content of the first operand will be placed before the content of the second operand:
>>> a = abjad.rhythmtrees.RhythmTreeParser()("(1 (1 1 1))")[0] >>> b = abjad.rhythmtrees.RhythmTreeParser()("(2 (3 4))")[0] >>> c = a + b >>> c.preprolated_duration Duration(3, 1)
>>> for _ in c: ... _ ... RhythmTreeLeaf(preprolated_duration=Duration(1, 1), is_pitched=True) RhythmTreeLeaf(preprolated_duration=Duration(1, 1), is_pitched=True) RhythmTreeLeaf(preprolated_duration=Duration(1, 1), is_pitched=True) RhythmTreeLeaf(preprolated_duration=Duration(3, 1), is_pitched=True) RhythmTreeLeaf(preprolated_duration=Duration(4, 1), is_pitched=True)
- Return type:
- overridden __call__(pulse_duration)[source]¶
Makes list of leaves and /or tuplets equal to
pulse_duration
.>>> string = "(1 (1 (2 (1 1 1)) 2))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0]
>>> components = tree((1, 4)) >>> components [Tuplet('5:4', "c'16 { 2/3 c'16 c'16 c'16 } c'8")]
>>> staff = abjad.Staff(components) >>> abjad.show(staff)
-
(
UniqueTreeContainer
).__contains__(expr)¶
-
(
UniqueTreeList
).__delitem__(i)¶
-
(
UniqueTreeList
).__getitem__(expr)¶
- __graph__(**keywords)[source]¶
Graphs rhythm-tree container.
>>> string = "(1 (1 (2 (1 1 1)) 2))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0] >>> graph = tree.__graph__() >>> print(format(graph, "graphviz")) digraph G { graph [bgcolor=transparent, truecolor=true]; node_0 [label="1", shape=triangle]; node_1 [label="1", shape=box]; node_2 [label="2", shape=triangle]; node_3 [label="1", shape=box]; node_4 [label="1", shape=box]; node_5 [label="1", shape=box]; node_6 [label="2", shape=box]; node_0 -> node_1; node_0 -> node_2; node_0 -> node_6; node_2 -> node_3; node_2 -> node_4; node_2 -> node_5; }
>>> abjad.graph(graph)
- Return type:
-
(
UniqueTreeContainer
).__iter__()¶
-
(
UniqueTreeContainer
).__len__()¶
- overridden __repr__()[source]¶
Gets interpreter representation of rhythm-tree container.
- Return type:
-
(
UniqueTreeList
).__setitem__(i, new_items)¶
Methods
-
(
UniqueTreeList
).append(expr)¶
-
(
UniqueTreeContainer
).depth_first(top_down=True, prototype=None)¶
-
(
UniqueTreeList
).extend(expr)¶
-
(
UniqueTreeList
).index(expr)¶
-
(
UniqueTreeList
).insert(i, expr)¶
-
(
UniqueTreeList
).pop(i=-1)¶
-
(
UniqueTreeContainer
).recurse(prototype=None)¶
-
(
UniqueTreeList
).remove(node)¶
Read/write properties
-
(
UniqueTreeNode
).name¶
-
(
RhythmTreeMixin
).preprolated_duration¶ Gets node duration in pulses.
>>> node = abjad.rhythmtrees.RhythmTreeLeaf(abjad.Duration(1)) >>> node.preprolated_duration Duration(1, 1)
>>> node.preprolated_duration = abjad.Duration(2) >>> node.preprolated_duration Duration(2, 1)
>>> node = abjad.rhythmtrees.RhythmTreeLeaf((2, 4)) >>> node.preprolated_duration (2, 4)
Read-only properties
-
(
UniqueTreeContainer
).children¶
-
(
UniqueTreeNode
).depth¶
-
(
RhythmTreeMixin
).duration¶ Gets node duration.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0]
>>> tree.duration Duration(1, 1)
>>> tree[1].duration Duration(1, 2)
>>> tree[1][1].duration Duration(1, 4)
-
(
UniqueTreeNode
).graph_order¶ Get graph-order tuple for node.
>>> from uqbar.containers import UniqueTreeList, UniqueTreeNode >>> root_container = UniqueTreeList(name="root") >>> outer_container = UniqueTreeList(name="outer") >>> inner_container = UniqueTreeList(name="inner") >>> node_a = UniqueTreeNode(name="a") >>> node_b = UniqueTreeNode(name="b") >>> node_c = UniqueTreeNode(name="c") >>> node_d = UniqueTreeNode(name="d") >>> root_container.extend([node_a, outer_container]) >>> outer_container.extend([inner_container, node_d]) >>> inner_container.extend([node_b, node_c])
>>> for node in root_container.depth_first(): ... print(node.name, node.graph_order) ... a (0,) outer (1,) inner (1, 0) b (1, 0, 0) c (1, 0, 1) d (1, 1)
-
(
RhythmTreeMixin
).pair¶ Gets preprolated duration as pair.
-
(
UniqueTreeNode
).parent¶
-
(
UniqueTreeNode
).parentage¶
-
(
RhythmTreeMixin
).parentage_ratios¶ A sequence describing the relative durations of the nodes in a node’s improper parentage.
The first item in the sequence is the preprolated_duration of the root node, and subsequent items are pairs of the preprolated duration of the next node in the parentage and the total preprolated_duration of that node and its siblings:
>>> a = abjad.rhythmtrees.RhythmTreeContainer( ... preprolated_duration=abjad.Duration(1) ... ) >>> b = abjad.rhythmtrees.RhythmTreeContainer( ... preprolated_duration=abjad.Duration(2) ... ) >>> c = abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=abjad.Duration(3)) >>> d = abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=abjad.Duration(4)) >>> e = abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=abjad.Duration(5))
>>> a.extend([b, c]) >>> b.extend([d, e])
>>> a.parentage_ratios (Duration(1, 1),)
>>> for item in b.parentage_ratios: ... item ... Duration(1, 1) (Duration(2, 1), Duration(5, 1))
>>> for item in c.parentage_ratios: ... item ... Duration(1, 1) (Duration(3, 1), Duration(5, 1))
>>> for item in d.parentage_ratios: ... item ... Duration(1, 1) (Duration(2, 1), Duration(5, 1)) (Duration(4, 1), Duration(9, 1))
>>> for item in e.parentage_ratios: ... item ... Duration(1, 1) (Duration(2, 1), Duration(5, 1)) (Duration(5, 1), Duration(9, 1))
Returns tuple.
-
(
RhythmTreeMixin
).pretty_rtm_format¶ Gets pretty-printed RTM format of node.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0] >>> print(tree.pretty_rtm_format) (1 ( (1 ( 1 1)) (1 ( 1 1))))
Returns string.
-
(
RhythmTreeMixin
).prolation¶ Gets node prolation.
-
(
RhythmTreeMixin
).prolations¶ Prolations of rhythm tree node.
-
(
UniqueTreeNode
).root¶
- rtm_format¶
Gets rhythm-tree container RTM format.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0] >>> tree.rtm_format '(1 ((1 (1 1)) (1 (1 1))))'
-
(
RhythmTreeMixin
).start_offset¶ Gets node start offset.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0]
>>> tree.start_offset Offset((0, 1))
>>> tree[1].start_offset Offset((1, 2))
>>> tree[0][1].start_offset Offset((1, 4))
-
(
RhythmTreeMixin
).stop_offset¶ Gets node stop offset.
- class abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=Duration(1, 1), is_pitched=True, name=None)[source]¶
Rhythm-tree leaf.
Pitched rhythm-tree leaf makes notes:
>>> leaf = abjad.rhythmtrees.RhythmTreeLeaf( ... preprolated_duration=abjad.Duration(5), is_pitched=True ... )
>>> leaf((1, 8)) [Note("c'2"), Note("c'8")]
Unpitched rhythm-tree leaf makes rests:
>>> leaf = abjad.rhythmtrees.RhythmTreeLeaf( ... preprolated_duration=abjad.Duration(7), is_pitched=False ... ) >>> leaf((1, 16)) [Rest('r4..')]
Attributes Summary
Makes list of leaves and / or tuplets equal to
pulse_duration
.Gets Graphviz graph of rhythm tree leaf.
Gets interpreter representation of rhythm-tree leaf.
Is true when rhythm-tree leaf is pitched.
Gets RTM format of rhythm tree leaf.
Special methods
- overridden __call__(pulse_duration)[source]¶
Makes list of leaves and / or tuplets equal to
pulse_duration
.
Read/write properties
- is_pitched¶
Is true when rhythm-tree leaf is pitched.
-
(
UniqueTreeNode
).name¶
-
(
RhythmTreeMixin
).preprolated_duration¶ Gets node duration in pulses.
>>> node = abjad.rhythmtrees.RhythmTreeLeaf(abjad.Duration(1)) >>> node.preprolated_duration Duration(1, 1)
>>> node.preprolated_duration = abjad.Duration(2) >>> node.preprolated_duration Duration(2, 1)
>>> node = abjad.rhythmtrees.RhythmTreeLeaf((2, 4)) >>> node.preprolated_duration (2, 4)
Read-only properties
-
(
UniqueTreeNode
).depth¶
-
(
RhythmTreeMixin
).duration¶ Gets node duration.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0]
>>> tree.duration Duration(1, 1)
>>> tree[1].duration Duration(1, 2)
>>> tree[1][1].duration Duration(1, 4)
-
(
UniqueTreeNode
).graph_order¶ Get graph-order tuple for node.
>>> from uqbar.containers import UniqueTreeList, UniqueTreeNode >>> root_container = UniqueTreeList(name="root") >>> outer_container = UniqueTreeList(name="outer") >>> inner_container = UniqueTreeList(name="inner") >>> node_a = UniqueTreeNode(name="a") >>> node_b = UniqueTreeNode(name="b") >>> node_c = UniqueTreeNode(name="c") >>> node_d = UniqueTreeNode(name="d") >>> root_container.extend([node_a, outer_container]) >>> outer_container.extend([inner_container, node_d]) >>> inner_container.extend([node_b, node_c])
>>> for node in root_container.depth_first(): ... print(node.name, node.graph_order) ... a (0,) outer (1,) inner (1, 0) b (1, 0, 0) c (1, 0, 1) d (1, 1)
-
(
RhythmTreeMixin
).pair¶ Gets preprolated duration as pair.
-
(
UniqueTreeNode
).parent¶
-
(
UniqueTreeNode
).parentage¶
-
(
RhythmTreeMixin
).parentage_ratios¶ A sequence describing the relative durations of the nodes in a node’s improper parentage.
The first item in the sequence is the preprolated_duration of the root node, and subsequent items are pairs of the preprolated duration of the next node in the parentage and the total preprolated_duration of that node and its siblings:
>>> a = abjad.rhythmtrees.RhythmTreeContainer( ... preprolated_duration=abjad.Duration(1) ... ) >>> b = abjad.rhythmtrees.RhythmTreeContainer( ... preprolated_duration=abjad.Duration(2) ... ) >>> c = abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=abjad.Duration(3)) >>> d = abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=abjad.Duration(4)) >>> e = abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=abjad.Duration(5))
>>> a.extend([b, c]) >>> b.extend([d, e])
>>> a.parentage_ratios (Duration(1, 1),)
>>> for item in b.parentage_ratios: ... item ... Duration(1, 1) (Duration(2, 1), Duration(5, 1))
>>> for item in c.parentage_ratios: ... item ... Duration(1, 1) (Duration(3, 1), Duration(5, 1))
>>> for item in d.parentage_ratios: ... item ... Duration(1, 1) (Duration(2, 1), Duration(5, 1)) (Duration(4, 1), Duration(9, 1))
>>> for item in e.parentage_ratios: ... item ... Duration(1, 1) (Duration(2, 1), Duration(5, 1)) (Duration(5, 1), Duration(9, 1))
Returns tuple.
-
(
RhythmTreeMixin
).pretty_rtm_format¶ Gets pretty-printed RTM format of node.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0] >>> print(tree.pretty_rtm_format) (1 ( (1 ( 1 1)) (1 ( 1 1))))
Returns string.
-
(
RhythmTreeMixin
).prolation¶ Gets node prolation.
-
(
RhythmTreeMixin
).prolations¶ Prolations of rhythm tree node.
-
(
UniqueTreeNode
).root¶
- rtm_format¶
Gets RTM format of rhythm tree leaf.
>>> abjad.rhythmtrees.RhythmTreeLeaf(abjad.Duration(1), is_pitched=True).rtm_format '1'
>>> abjad.rhythmtrees.RhythmTreeLeaf(abjad.Duration(5), is_pitched=False).rtm_format '-5'
-
(
RhythmTreeMixin
).start_offset¶ Gets node start offset.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0]
>>> tree.start_offset Offset((0, 1))
>>> tree[1].start_offset Offset((1, 2))
>>> tree[0][1].start_offset Offset((1, 4))
-
(
RhythmTreeMixin
).stop_offset¶ Gets node stop offset.
- class abjad.rhythmtrees.RhythmTreeMixin(preprolated_duration=Duration(1, 1))[source]¶
Abstract rhythm-tree node.
Attributes Summary
Gets node duration.
Gets preprolated duration as pair.
A sequence describing the relative durations of the nodes in a node's improper parentage.
Gets node duration in pulses.
Gets pretty-printed RTM format of node.
Gets node prolation.
Prolations of rhythm tree node.
Gets node start offset.
Gets node stop offset.
Read/write properties
- preprolated_duration¶
Gets node duration in pulses.
>>> node = abjad.rhythmtrees.RhythmTreeLeaf(abjad.Duration(1)) >>> node.preprolated_duration Duration(1, 1)
>>> node.preprolated_duration = abjad.Duration(2) >>> node.preprolated_duration Duration(2, 1)
>>> node = abjad.rhythmtrees.RhythmTreeLeaf((2, 4)) >>> node.preprolated_duration (2, 4)
Read-only properties
- duration¶
Gets node duration.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0]
>>> tree.duration Duration(1, 1)
>>> tree[1].duration Duration(1, 2)
>>> tree[1][1].duration Duration(1, 4)
- pair¶
Gets preprolated duration as pair.
- parentage_ratios¶
A sequence describing the relative durations of the nodes in a node’s improper parentage.
The first item in the sequence is the preprolated_duration of the root node, and subsequent items are pairs of the preprolated duration of the next node in the parentage and the total preprolated_duration of that node and its siblings:
>>> a = abjad.rhythmtrees.RhythmTreeContainer( ... preprolated_duration=abjad.Duration(1) ... ) >>> b = abjad.rhythmtrees.RhythmTreeContainer( ... preprolated_duration=abjad.Duration(2) ... ) >>> c = abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=abjad.Duration(3)) >>> d = abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=abjad.Duration(4)) >>> e = abjad.rhythmtrees.RhythmTreeLeaf(preprolated_duration=abjad.Duration(5))
>>> a.extend([b, c]) >>> b.extend([d, e])
>>> a.parentage_ratios (Duration(1, 1),)
>>> for item in b.parentage_ratios: ... item ... Duration(1, 1) (Duration(2, 1), Duration(5, 1))
>>> for item in c.parentage_ratios: ... item ... Duration(1, 1) (Duration(3, 1), Duration(5, 1))
>>> for item in d.parentage_ratios: ... item ... Duration(1, 1) (Duration(2, 1), Duration(5, 1)) (Duration(4, 1), Duration(9, 1))
>>> for item in e.parentage_ratios: ... item ... Duration(1, 1) (Duration(2, 1), Duration(5, 1)) (Duration(5, 1), Duration(9, 1))
Returns tuple.
- pretty_rtm_format¶
Gets pretty-printed RTM format of node.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0] >>> print(tree.pretty_rtm_format) (1 ( (1 ( 1 1)) (1 ( 1 1))))
Returns string.
- prolation¶
Gets node prolation.
- prolations¶
Prolations of rhythm tree node.
- start_offset¶
Gets node start offset.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> tree = abjad.rhythmtrees.RhythmTreeParser()(string)[0]
>>> tree.start_offset Offset((0, 1))
>>> tree[1].start_offset Offset((1, 2))
>>> tree[0][1].start_offset Offset((1, 4))
- stop_offset¶
Gets node stop offset.
- class abjad.rhythmtrees.RhythmTreeParser(debug=False)[source]¶
Rhythm-tree parser.
Abjad’s rhythm-tree parser parses a micro-language resembling Ircam’s RTM Lisp syntax, and generates a sequence of rhythm-tree structures. Composers can maniuplate these structures and then convert them to Abjad score components.
>>> parser = abjad.rhythmtrees.RhythmTreeParser() >>> string = "(3 (1 (1 ((2 (1 1 1)) 2 2 1))))" >>> rhythm_tree_list = parser(string) >>> rhythm_tree_container = rhythm_tree_list[0] >>> rhythm_tree_container.rtm_format '(3 (1 (1 ((2 (1 1 1)) 2 2 1))))'
>>> for _ in rhythm_tree_container: ... _ ... RhythmTreeLeaf(preprolated_duration=Duration(1, 1), is_pitched=True) RhythmTreeContainer((3, 2))
>>> base_duration = (1, 4) >>> component_list = rhythm_tree_container(base_duration) >>> tuplet = component_list[0] >>> abjad.show(tuplet)
Attributes Summary
container : LPAREN DURATION node_list_closed RPAREN
leaf : DURATION
node : container
node : leaf
node_list : node_list node_list_item
node_list : node_list_item
node_list_closed : LPAREN node_list RPAREN
node_list_item : node
toplevel :
toplevel : toplevel node
start
-?[1-9]d*(/[1-9]d*)?
t_LPAREN
t_RPAREN
t_ignore
n+
tokens
Special methods
Methods
- p_container__LPAREN__DURATION__node_list_closed__RPAREN(p)[source]¶
container : LPAREN DURATION node_list_closed RPAREN
- p_node_list_closed__LPAREN__node_list__RPAREN(p)[source]¶
node_list_closed : LPAREN node_list RPAREN
Read-only properties
- lexer_rules_object¶
- parser_rules_object¶
Functions
Creates rhythm tree from RTM |
- abjad.rhythmtrees.parse_rtm_syntax(string)[source]¶
Creates rhythm tree from RTM
string
; then calls rhythm tree on quarter-note pulse duration.A single quarter note:
>>> result = abjad.rhythmtrees.parse_rtm_syntax("1") >>> result Note("c'4")
>>> abjad.show(result)
A series of quarter notes:
>>> result = abjad.rhythmtrees.parse_rtm_syntax("1 1 1 1 1 1") >>> result Container("c'4 c'4 c'4 c'4 c'4 c'4")
>>> abjad.show(result)
Notes with durations of the form
n * 1/4
:>>> result = abjad.rhythmtrees.parse_rtm_syntax("1 2 3 4 5") >>> result Container("c'4 c'2 c'2. c'1 c'1 c'4")
>>> abjad.show(result)
Notes with durations of the form
1/n * 1/4
:>>> result = abjad.rhythmtrees.parse_rtm_syntax("1 1/2 1/3 1/4 1/5") >>> result Container("c'4 c'8 { 8/12 c'8 } c'16 { 16/20 c'16 }")
>>> abjad.show(result)
With arbitrary multipliers:
>>> result = abjad.rhythmtrees.parse_rtm_syntax("1 2/3 3/5") >>> result Container("c'4 { 4/6 c'4 } { 16/20 c'8. }")
>>> abjad.show(result)
Divides quarter-note duration into 1 part; results in a note:
>>> string = "(1 (1))" >>> result = abjad.rhythmtrees.parse_rtm_syntax(string) >>> result Note("c'4")
>>> abjad.show(result)
Divides quarter-note duration
1:1
; results in a container:>>> string = "(1 (1 1))" >>> result = abjad.rhythmtrees.parse_rtm_syntax(string) >>> result Container("c'8 c'8")
>>> abjad.show(result)
Divides quarter-note duration
1:2
; results in a tuplet:>>> string = "(1 (1 2))" >>> result = abjad.rhythmtrees.parse_rtm_syntax(string) >>> result Tuplet('3:2', "c'8 c'4")
>>> abjad.show(result)
Divides half-note duration into 1 part; results in a note:
>>> string = "(2 (1))" >>> result = abjad.rhythmtrees.parse_rtm_syntax(string) >>> result Note("c'2")
>>> abjad.show(result)
Divides half-note duration
1:1
; results in a container:>>> string = "(2 (1 1))" >>> result = abjad.rhythmtrees.parse_rtm_syntax(string) >>> result Container("c'4 c'4")
>>> abjad.show(result)
Divides half-note duration
1:2
; results in a tuplet:>>> string = "(2 (1 2))" >>> result = abjad.rhythmtrees.parse_rtm_syntax(string) >>> result Tuplet('3:2', "c'4 c'2")
>>> abjad.show(result)
Divides three successive quarter-note durations, according to ratios of
1
,1:1
,1:2
:>>> string = "(1 (1)) (1 (1 1)) (1 (1 2))" >>> result = abjad.rhythmtrees.parse_rtm_syntax(string) >>> result Container("c'4 c'8 c'8 { 2/3 c'8 c'4 }")
>>> abjad.show(result)
Another example:
>>> string = "(1 (1 (1 (1 1)) 1))" >>> tuplet = abjad.rhythmtrees.parse_rtm_syntax(string) >>> abjad.show(tuplet)
Fractional durations are allowed:
>>> string = "(3/4 (1 1/2 (4/3 (1 -1/2 1))))" >>> tuplet = abjad.rhythmtrees.parse_rtm_syntax(string) >>> abjad.show(tuplet)