abjad.rhythmtrees
|
Calls each node in |
Extracts trivial tuplets from |
|
|
Parses RTM |
Rhythm-tree container. |
|
|
Rhythm-tree leaf. |
Rhythm-tree node. |
|
|
Rhythm-tree parser. |
- abjad.rhythmtrees.call(nodes, duration: Duration = Duration(1, 4)) list[Leaf | Tuplet] [source]
Calls each node in
nodes
withduration
.
- abjad.rhythmtrees.extract_trivial_tuplets(argument) None [source]
Extracts trivial tuplets from
argument
.
- abjad.rhythmtrees.parse(string: str) list[RhythmTreeContainer | RhythmTreeLeaf] [source]
Parses RTM
string
.Quarter note:
>>> nodes = abjad.rhythmtrees.parse("1") >>> components = abjad.rhythmtrees.call(nodes) >>> voice = abjad.Voice(components) >>> abjad.setting(voice[0]).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
Series of quarter notes:
>>> nodes = abjad.rhythmtrees.parse("1 1 1 1 1 1") >>> components = abjad.rhythmtrees.call(nodes) >>> voice = abjad.Voice(components) >>> abjad.setting(voice[0]).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
Half-note duration divided into 1 part:
>>> string = "(2 (1))" >>> nodes = abjad.rhythmtrees.parse(string) >>> components = abjad.rhythmtrees.call(nodes) >>> voice = abjad.Voice(components) >>> leaf = abjad.select.leaf(voice, 0) >>> abjad.setting(leaf).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
>>> abjad.rhythmtrees.extract_trivial_tuplets(voice) >>> abjad.show(voice)
Half-note duration divided
1:1
:>>> string = "(2 (1 1))" >>> nodes = abjad.rhythmtrees.parse(string) >>> components = abjad.rhythmtrees.call(nodes) >>> voice = abjad.Voice(components) >>> leaf = abjad.select.leaf(voice, 0) >>> abjad.setting(leaf).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
>>> abjad.rhythmtrees.extract_trivial_tuplets(voice) >>> abjad.show(voice)
Half-note duration divided
1:2
:>>> string = "(2 (1 2))" >>> nodes = abjad.rhythmtrees.parse(string) >>> components = abjad.rhythmtrees.call(nodes) >>> voice = abjad.Voice(components) >>> leaf = abjad.select.leaf(voice, 0) >>> abjad.setting(leaf).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
Successive quarter-note durations, divided
1
,1:1
,1:2
:>>> string = "(1 (1)) (1 (1 1)) (1 (1 2))" >>> nodes = abjad.rhythmtrees.parse(string) >>> components = abjad.rhythmtrees.call(nodes) >>> voice = abjad.Voice(components) >>> leaf = abjad.select.leaf(voice, 0) >>> abjad.setting(leaf).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
>>> abjad.rhythmtrees.extract_trivial_tuplets(voice) >>> abjad.show(voice)
Dyadic durations:
>>> nodes = abjad.rhythmtrees.parse("1 1/2 1/2 3/2 1/4") >>> components = abjad.rhythmtrees.call(nodes) >>> voice = abjad.Voice(components) >>> abjad.setting(voice[0]).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
Tuplets without dotted values:
>>> string = "(1 (1 (1 (1 1)) 1))" >>> nodes = abjad.rhythmtrees.parse(string) >>> components = abjad.rhythmtrees.call(nodes, abjad.Duration(1, 2)) >>> voice = abjad.Voice(components) >>> leaf = abjad.select.leaf(voice, 0) >>> abjad.setting(leaf).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
>>> abjad.rhythmtrees.extract_trivial_tuplets(voice) >>> abjad.show(voice)
- class abjad.rhythmtrees.RhythmTreeContainer(pair: tuple[int, int], children: Sequence[RhythmTreeNode] = (), *, name: str = '')[source]
Rhythm-tree container.
Extend rhythm-tree containers with rhythm-tree leaves or other rhythm-tree containers:
>>> rtc = abjad.rhythmtrees.RhythmTreeContainer((1, 1)) >>> rtc.append(abjad.rhythmtrees.RhythmTreeLeaf((1, 1))) >>> rtc.append(abjad.rhythmtrees.RhythmTreeLeaf((2, 1))) >>> rtc.append(abjad.rhythmtrees.RhythmTreeLeaf((2, 1)))
Use RTM format strings to view the structure of rhythm-tree containers:
>>> print(rtc.rtm_format) (1 (1 2 2))
>>> print(rtc.pretty_rtm_format) (1 ( 1 2 2))
Call rhythm-tree containers with a duration to make components:
>>> components = rtc(abjad.Duration(1, 1)) >>> voice = abjad.Voice(components) >>> abjad.setting(voice[0]).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
Gets RTM format of rhythm-tree container.
- rtm_format
Gets RTM format of rhythm-tree container.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> rtc = abjad.rhythmtrees.parse(string)[0]
>>> rtc.rtm_format '(1 ((1 (1 1)) (1 (1 1))))'
>>> rtc[0].rtm_format '(1 (1 1))'
>>> rtc[0][0].rtm_format '1'
- class abjad.rhythmtrees.RhythmTreeLeaf(pair: tuple[int, int], *, is_unpitched: bool = False, name: str | None = None)[source]
Rhythm-tree leaf.
Pitched rhythm-tree leaves makes notes:
>>> rtl = abjad.rhythmtrees.RhythmTreeLeaf((5, 1), is_unpitched=False) >>> components = rtl(abjad.Duration(1, 4)) >>> voice = abjad.Voice(components) >>> abjad.setting(voice[0]).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
Unpitched rhythm-tree leaves make rests:
>>> rtl = abjad.rhythmtrees.RhythmTreeLeaf((5, 1), is_unpitched=True) >>> components = rtl(abjad.Duration(1, 4)) >>> voice = abjad.Voice(components) >>> abjad.setting(voice[0]).Score.proportionalNotationDuration = "#1/12" >>> abjad.show(voice)
Is true when rhythm-tree leaf is unpitched.
Gets RTM format of rhythm-tree leaf.
- is_unpitched
Is true when rhythm-tree leaf is unpitched.
- rtm_format
Gets RTM format of rhythm-tree leaf.
>>> abjad.rhythmtrees.RhythmTreeLeaf((5, 1), is_unpitched=False).rtm_format '5'
>>> abjad.rhythmtrees.RhythmTreeLeaf((5, 1), is_unpitched=True).rtm_format '-5'
- class abjad.rhythmtrees.RhythmTreeNode(pair: tuple[int, int])[source]
Rhythm-tree node.
Gets duration of rhythm-tree node.
Gets pair of rhythm-tree node.
Gets pretty-printed RTM format of rhythm-tree node.
Gets prolation of rhythm-tree node.
Gets prolations of rhythm-tree node.
Gets start offset of rhythm-tree node.
Gets stop offset of rhythm-tree node.
- duration
Gets duration of rhythm-tree node.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> rtc = abjad.rhythmtrees.parse(string)[0] >>> components = rtc(abjad.Duration(1, 1)) >>> voice = abjad.Voice(components) >>> score = abjad.Score([voice]) >>> abjad.setting(score).proportionalNotationDuration = "#1/12" >>> abjad.show(score)
>>> rtc.duration Duration(1, 1)
>>> rtc[1].duration Duration(1, 2)
>>> rtc[1][1].duration Duration(1, 4)
- pair
Gets pair of rhythm-tree node.
>>> abjad.rhythmtrees.RhythmTreeLeaf((1, 1)).pair (1, 1)
>>> abjad.rhythmtrees.RhythmTreeLeaf((2, 4)).pair (2, 4)
- pretty_rtm_format
Gets pretty-printed RTM format of rhythm-tree node.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> rtc = abjad.rhythmtrees.parse(string)[0]
>>> print(rtc.pretty_rtm_format) (1 ( (1 ( 1 1)) (1 ( 1 1))))
>>> print(rtc[0].pretty_rtm_format) (1 ( 1 1))
>>> print(rtc[0][0].pretty_rtm_format) 1
- prolation
Gets prolation of rhythm-tree node.
- prolations
Gets prolations of rhythm-tree node.
- start_offset
Gets start offset of rhythm-tree node.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> rtc = abjad.rhythmtrees.parse(string)[0]
>>> rtc.start_offset Offset((0, 1))
>>> rtc[1].start_offset Offset((1, 2))
>>> rtc[1][1].start_offset Offset((3, 4))
- stop_offset
Gets stop offset of rhythm-tree node.
>>> string = "(1 ((1 (1 1)) (1 (1 1))))" >>> rtc = abjad.rhythmtrees.parse(string)[0]
>>> rtc.stop_offset Offset((1, 1))
>>> rtc[0].stop_offset Offset((1, 2))
>>> rtc[0][0].stop_offset Offset((1, 4))
- class abjad.rhythmtrees.RhythmTreeParser(debug=False)[source]
Rhythm-tree parser.
Parses a microlanguage resembling Ircam’s Lisp-based RTM syntax. Generates a list of rhythm trees. Composers can manipulate rhythm trees and convert them to score components.
>>> parser = abjad.rhythmtrees.RhythmTreeParser() >>> string = "(3 (1 (1 ((2 (1 1 1)) 2 2 1))))" >>> rtc = parser(string)[0]
>>> print(rtc.pretty_rtm_format) (3 ( 1 (1 ( (2 ( 1 1 1)) 2 2 1))))
>>> components = rtc(abjad.Duration(1, 2)) >>> abjad.tweak(components[0], r"\tweak text #tuplet-number::calc-fraction-text") >>> voice = abjad.Voice(components) >>> staff = abjad.Staff([voice]) >>> score = abjad.Score([staff]) >>> abjad.setting(score).proportionalNotationDuration = "#1/12" >>> time_signature = abjad.TimeSignature((6, 4)) >>> leaf = abjad.select.leaf(voice, 0) >>> abjad.attach(time_signature, leaf) >>> abjad.show(score)
container : LPAREN DURATION node_list_closed RPAREN
p_error
(p)leaf : DURATION
node : container
p_node__leaf
(p)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
t_DURATION
(t)-?[1-9]d*(/[1-9]d*)?
t_error
(t)t_newline
(t)n+
- lexer_rules_object
- 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
- parser_rules_object