Package eu.bandm.music.entities
Class MTree_<M extends MTree_<M>>
java.lang.Object
eu.bandm.music.entities.MTree_<M>
- Type Parameters:
M
- the concrete type of the concrete instance. Can currently beMTree
orMTreeSpec
.
- All Implemented Interfaces:
MetrumIndication
Abstract superclass for
Both subclasses are a representation of the internal metrical hierarchies of one single measure, used for interpretation of rhythms. Both subclasses add VERY DIFFERENT semantics: MTreeSpec are purely algebraic and sharing is heavily employed by theparser, while MTree adds back-pointers to context and siblings, so sharing is no longer possible>.
MTree
and MTreeSpec
.
It realizes common methods for retrieval, inquiry, visualisation, etc.
Both subclasses are a representation of the internal metrical hierarchies of one single measure, used for interpretation of rhythms. Both subclasses add VERY DIFFERENT semantics: MTreeSpec are purely algebraic and sharing is heavily employed by theparser, while MTree adds back-pointers to context and siblings, so sharing is no longer possible>.
They have in common: Every node represents an interval of the time of the measure. The sequence of the intervals represented by the childs of a node cover the interval of this parent node, in the same order. As a consequence, every node has a duration. (MTree additionally: startpoint and endpoint). The children of each node can be of different length and/or structure. A node can have alternatives = other nodes which impose a different sttucture / list of child nodes on the same interval of the measure.
>
Most algorithms work on an MTree
.
A user constructs an MTreeSpec
, for representing a specifications, and then calls
MTree.install(MTreeSpec,MTree.Parameters)
to expand these.
-
Field Summary
Modifier and TypeFieldDescription(package private) M
An alternative to this node.The duration of the time interval (of a measure) represented by this node.(package private) boolean
Whether all child nodes of this node have equal durations.(package private) boolean
Whether the duration of this node has been given explicitly with its specification.List of child nodes. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the length of a measure.void
dump()
Prints an indented visualization to System.err.void
dump
(PrintStream p) Prints an indented visualization.void
dump
(PrintWriter p) Prints an indented visualization.Return the (first) alternative node.Get the duration value.boolean
Return whether the duration has been set explicitly, when speficfying this node.int
get_size()
int
Returns the number of children of this node.get_subs()
boolean
Returns whether the child level is divided equidistantly by two.protected abstract M
self()
Necessary to avoid "unchecked cast" warning when returning "this" instance as a result of a methode declared of type "M".toString()
gives one-line rendering.
-
Field Details
-
subs
List of child nodes. -
alternative
An alternative to this node. Has same duration, start, end, but different internal structure by a different list of child nodes. -
duration
The duration of the time interval (of a measure) represented by this node. Can be==null
in a mere parsing result, but will be filled != null byMTreeSpec.initialize(eu.bandm.tscore.base.Modifiers.Reaction,MessageReceiver)
. It will be calculated by the constraints imposed by parents and siblings, etc. -
explicitDuration
boolean explicitDurationWhether the duration of this node has been given explicitly with its specification. -
equidist
boolean equidistWhether all child nodes of this node have equal durations.
-
-
Constructor Details
-
MTree_
public MTree_()
-
-
Method Details
-
constantRationalMeasureDuration
Returns the length of a measure. This is defined by the interface MetrumIndication, which MAY throw an UnsupportedOperationException in other implementations.- Specified by:
constantRationalMeasureDuration
in interfaceMetrumIndication
-
get_size
public int get_size()- Returns:
- number of child nodes.
-
get_subs
- Returns:
- unmodifiable list of child nodes.
-
get_alternative
Return the (first) alternative node. -
get_duration
Get the duration value. Between parsing and initializing an MTreeSpec this field can be ==null But for each MTree and each MTreeSpec afterMTreeSpec.initialize(eu.bandm.tscore.base.Modifiers.Reaction, eu.bandm.tools.message.MessageReceiver<eu.bandm.tools.message.SimpleMessage<?>>)
it is !=null. -
get_explicitDuration
public boolean get_explicitDuration()Return whether the duration has been set explicitly, when speficfying this node. -
self
Necessary to avoid "unchecked cast" warning when returning "this" instance as a result of a methode declared of type "M". Must be implemented by the subclasses with their type as the return type. -
get_size_binary
public int get_size_binary()Returns the number of children of this node. Returns two(2) iff no children currently exist. This mirrors the default division by two(2) implicitly allowed for every node in CWN. -
is_equi_binary
public boolean is_equi_binary()Returns whether the child level is divided equidistantly by two. -
durationName
- Returns:
- a single broken number (NOT a rational) as meter name, reflecting only the duration. If there are child nodes, than the LCM of their denominators is used as denominator. This makes 1/8+1/4+1/8 = 4/8 Otherwise, if numerator of the duration ==1, then the fraction is enhanced by "2", reflecting the default bi-section.
-
compoundName
- Returns:
- a list of broken numbers as a name for the meter. [a, b, c, d] is an encoding for "a/b+c/d". The algorithm steps through the children of this MTree_. As long as the length values are identical, their numerators are summed up.
-
toString
gives one-line rendering. See alsodump(PrintStream)
, which gives a multi-line indented view. -
dump
public void dump()Prints an indented visualization to System.err. -
dump
Prints an indented visualization. -
dump
Prints an indented visualization.
-