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 be MTree or MTreeSpec.
All Implemented Interfaces:
MetrumIndication
Direct Known Subclasses:
MTree, MTreeSpec

public abstract class MTree_<M extends MTree_<M>> extends Object implements MetrumIndication
Abstract superclass for 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 Details

    • subs

      List<M extends MTree_<M>> subs
      List of child nodes.
    • alternative

      @Opt M extends MTree_<M> alternative
      An alternative to this node. Has same duration, start, end, but different internal structure by a different list of child nodes.
    • duration

      @Opt @Opt Rational 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 by MTreeSpec.initialize(eu.bandm.tscore.base.Modifiers.Reaction,MessageReceiver). It will be calculated by the constraints imposed by parents and siblings, etc.
    • explicitDuration

      boolean explicitDuration
      Whether the duration of this node has been given explicitly with its specification.
    • equidist

      boolean equidist
      Whether all child nodes of this node have equal durations.
  • Constructor Details

    • MTree_

      public MTree_()
  • Method Details

    • constantRationalMeasureDuration

      public Rational 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 interface MetrumIndication
    • get_size

      public int get_size()
      Returns:
      number of child nodes.
    • get_subs

      public List<M> get_subs()
      Returns:
      unmodifiable list of child nodes.
    • get_alternative

      @Opt public M get_alternative()
      Return the (first) alternative node.
    • get_duration

      public Rational get_duration()
      Get the duration value. Between parsing and initializing an MTreeSpec this field can be ==null But for each MTree and each MTreeSpec after MTreeSpec.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

      protected abstract M 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

      public List<Integer> 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

      public List<Integer> 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

      public String toString()
      gives one-line rendering. See also dump(PrintStream), which gives a multi-line indented view.
      Overrides:
      toString in class Object
    • dump

      public void dump()
      Prints an indented visualization to System.err.
    • dump

      public void dump(PrintStream p)
      Prints an indented visualization.
    • dump

      public void dump(PrintWriter p)
      Prints an indented visualization.