Package eu.bandm.music.entities
Class MTreeSpec
- All Implemented Interfaces:
MetrumIndication
A specification for an
A tscore parser is provided; for its syntax see the user doc.
A user constructs an
MTree
, as constructed by a user.
The fields defining the duration values need not be completely filled, but
must be free of conflicts and allow un-ambiguous completion.A tscore parser is provided; for its syntax see the user doc.
A user constructs an
MTreeSpec
and then calls
MTree.install(MTreeSpec,MTree.Parameters)
to expand it to an MTree
.
ATTENTION: In its very first life span, the mere specification has *algebraic* semantics
and the parsers heavily make use of *sharing*.
Fields like "parent", "position" etc. are thus inapplicable.
The opposite is true for any MTree
.-
Field Summary
Modifier and TypeFieldDescriptionprotected static final Translet.Parser<MTreeSpec>
protected static final Translet.Parser<MTreeSpec>
static final Translet.Parser<MTreeSpec>
protected static final Translet.Recursive<MTreeSpec>
static final Translet.Parser<MTreeSpec>
Fields inherited from class eu.bandm.music.entities.MTree_
alternative, duration, equidist, explicitDuration, subs
-
Constructor Summary
ConstructorDescriptionCreate one node with arg nodes as sub-nodes, and an explicit duration.Create one node with arg nodes as sub-nodes.Create one node with arg nodes as sub-nodes, and an explicit duration.Create one node with arg nodes as sub-nodes, and an explicit duration.Create one node with arg nodes as sub-nodes. -
Method Summary
Modifier and TypeMethodDescriptionstatic MTreeSpec
static MTreeSpec
Set every element in the list (but the very first) as the alternative of its predecssor.Deprecated, for removal: This API element is subject to removal in a future version.initialize
(MessageReceiver<SimpleMessage<?>> msg) initialize
(Modifiers.Reaction redundantDuration) Deprecated, for removal: This API element is subject to removal in a future version.useinitialize(Reaction, MessageReceiver)
instead.initialize
(Modifiers.Reaction redundantDuration, MessageReceiver<SimpleMessage<?>> msg) May only be called for the topmost node, representing a complete metric tree/ measure.parseAndInitialize
(MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, String s) Create one top node and all described sub nodes by parsing a specification text.static Translet.Parser<MTreeSpec>
parser()
protected void
propagateToAlts
(Rational dura, Set<MTreeSpec> visited, Modifiers.Reaction redundantDuration, MessageReceiver<SimpleMessage<?>> msg) Distribute found duration to all alternatives,protected void
propagateToChilds
(Set<MTreeSpec> visited, Modifiers.Reaction redundantDuration, MessageReceiver<SimpleMessage<?>> msg) Either all children do not have a duration, then the duration is distributed equally among them, or only one child does not have a duration and gets the rest.propagateUp
(Set<MTreeSpec> contributors) If this has no duration, then induce it from its childs.protected void
react
(Modifiers.Reaction react, MessageReceiver<SimpleMessage<?>> msg, String txt, Object... args) Generates maybe a message with the given text and arguments, either as error or as warning, depending on "react".static MTreeSpec
static MTreeSpec
Create and return one node which contains n times the given subnode as its childs.static MTreeSpec
Create and return one node which contains n times the given subnode as its childs and has the explicitly given duration.protected MTreeSpec
self()
Necessary to avoid "unchecked cast" warning when returning "this" instance in the parameterized superclassMTree_
.Methods inherited from class eu.bandm.music.entities.MTree_
compoundName, constantRationalMeasureDuration, dump, dump, dump, durationName, get_alternative, get_duration, get_explicitDuration, get_size, get_size_binary, get_subs, is_equi_binary, toString
-
Field Details
-
parser_summand_recursive
-
parser_concat
-
parser_alt
-
parser_timed
-
parser_summand
-
-
Constructor Details
-
MTreeSpec
Create one node with arg nodes as sub-nodes. Set context fields ".parent" and ".pos" -
MTreeSpec
Create one node with arg nodes as sub-nodes. -
MTreeSpec
Create one node with arg nodes as sub-nodes, and an explicit duration. -
MTreeSpec
Create one node with arg nodes as sub-nodes, and an explicit duration. -
MTreeSpec
Create one node with arg nodes as sub-nodes, and an explicit duration.
-
-
Method Details
-
self
Necessary to avoid "unchecked cast" warning when returning "this" instance in the parameterized superclassMTree_
. -
REP
Create and return one node which contains n times the given subnode as its childs. Corresponds to the parsing result of an input like "3*<sub>
". -
REP
Create and return one node which contains n times the given subnode as its childs and has the explicitly given duration. Corresponds only roughly to the parsing results of an input like "3/4(3*<sub>)
". (Repetion count and explict duration are not combinable when parsing.) -
REP
-
ALTS
Set every element in the list (but the very first) as the alternative of its predecssor. -
ALTS
- See Also:
-
initialize
public MTreeSpec initialize(Modifiers.Reaction redundantDuration, MessageReceiver<SimpleMessage<?>> msg) May only be called for the topmost node, representing a complete metric tree/ measure. Assumes that initially only a fewMTree_.duration
fields are set. The durations of the children of such a node are calculated by equidistant division. The duration of a node where all childern have a duration is by summing them up. After all durations have been set, the start positions are defined by summing up the preceding siblings. The user is free to define durations at very different positions of a fresh MTreeSpec, before calling the method. This may result in inconsistencies, which are signalled as exceptions. Esp. when tuplets shall be combined, durations must be inserted explicitly.new MTreeSpec(new MTreeSpec (3,4, new MTreeSpec(), new MTreeSpec(), new MTreeSpec()), new MTreeSpec (2,4, new MTreeSpec(), new MTreeSpec(), new MTreeSpec()) ):
... defines a measure with three(3) quarter notes (1/4) in its first part, and three(3) quarter triplets(1/6) in its second part.
The following combinations are possible of nodes not yet carrying a duration:p=dp p=dp p=? / \ \ / \ \ / \ \ x=? y=? z=? x=dx y=? z=dz x=dx y=dy z=dz
- Parameters:
redundantDuration
- how to react when the duration of a particular node is defined by more than one(>1) sources to the same value.
-
initialize
-
initialize
Deprecated, for removal: This API element is subject to removal in a future version.useinitialize(Reaction, MessageReceiver)
instead. -
initialize
Deprecated, for removal: This API element is subject to removal in a future version.useinitialize(Reaction, MessageReceiver)
instead. -
react
protected void react(Modifiers.Reaction react, MessageReceiver<SimpleMessage<?>> msg, String txt, Object... args) Generates maybe a message with the given text and arguments, either as error or as warning, depending on "react". This allows to choose between "silently allow", "warning", and "error". -
propagateUp
If this has no duration, then induce it from its childs. Visit depth-first and sum-up the durations of children, as long as (recursively) possible and necessary, and return the result. -
propagateToAlts
protected void propagateToAlts(Rational dura, Set<MTreeSpec> visited, Modifiers.Reaction redundantDuration, MessageReceiver<SimpleMessage<?>> msg) Distribute found duration to all alternatives, -
propagateToChilds
protected void propagateToChilds(Set<MTreeSpec> visited, Modifiers.Reaction redundantDuration, MessageReceiver<SimpleMessage<?>> msg) Either all children do not have a duration, then the duration is distributed equally among them, or only one child does not have a duration and gets the rest. If all have a duration, then the sum must match the parent's one. -
parseAndInitialize
@Opt public static @Opt MTreeSpec parseAndInitialize(MessageReceiver<SimpleMessage<eu.bandm.tools.util.xml.XMLDocumentIdentifier>> msg, String s) Create one top node and all described sub nodes by parsing a specification text. -
parser
-
initialize(Reaction, MessageReceiver)
instead.