Class MSplitter.Result.WriteOut

java.lang.Object
eu.bandm.music.entities.MSplitter.Result.WriteOut
Direct Known Subclasses:
MSplitter.Result.Dumper
Enclosing class:
MSplitter.Result

public abstract class MSplitter.Result.WriteOut extends Object
This local class performs serialization of a rhythm representation, including the opening and closing of n-plet-brackets in a minimal fashion. The call-back methods writeOut(int,MTree,RationalDuration.DottedBaseDuration,Rational,StemEnd,boolean,boolean,boolean) open_proportion(Rational,Rational) and close_proportion(Rational,Rational) must be implemented by the caller, an instance must be constructed "inside" the MSplitter.Result, and then process() must be called.
Since the invariants of bracket simplification and node merging coincide, (both never span a change of duration or a change of division) we know that (1) no sibling-melt or dotting result crosses n-plet-brackets. (2) but three-syncopes and hemiolas CAN cross triplet brackets, iff allowed by parameter.
  • Field Details

    • currentProportion

      Rational currentProportion
      Running state of the proportion to be applied to the printed symbols of the currently visited node.
    • bracketStack

      public final Stack<MTree.EssentialBracket> bracketStack
      Keeps track of n-plet-brackets currently open. FIXME besser an immutable copy !?!?
  • Constructor Details

    • WriteOut

      public WriteOut()
  • Method Details

    • testCloseBrackets

      protected void testCloseBrackets(Rational when)
      Called for each node to close essential n-plet-brackets, iff their end-of-duration is reached. If such a bracket is found, the overridden payload call-back method close_proportion(Rational,Rational) is called.
    • testOpenBrackets

      protected void testOpenBrackets(MTree start, boolean printedNode)
      Called for each node to open essential n-plet-brackets, iff necessary for the following duration values. If such a bracket is found, the overridden payload call-back method open_proportion(Rational,Rational) is called. Brackets of an ancesteor are printed when the very first child/grandchild/etc. is printed. But only iff that bracket is not "vanishing". The call-backs open_proportion(Rational,Rational) and close_proportion(Rational,Rational) get the rational factor of the currently opened/closed bracket as an argument, while the (readable) global currentProportion holds the accumulated effective proportion (also passed as a parameter to writeOut(int,MTree,RationalDuration.DottedBaseDuration,Rational,StemEnd,boolean,boolean,boolean)
    • process

      public void process()
      Loop through all events in this result and call the call-back method writeOut(int,MTree,RationalDuration.DottedBaseDuration,Rational,StemEnd,boolean,boolean,boolean) for every single note symbol (/pause symbol) resulting from the preceding notational split-and-merge process. Interspered are the calls to open_proportion(Rational,Rational) and close_proportion(Rational,Rational) for proportions/n-plet-brackets in the correct nesting order.
    • x_writeOut

      protected void x_writeOut(int index, List<MTree> nodes, Rational currentProportion, boolean isSound, boolean isFirst, boolean isLast)
      A wrapper which calls the real "writeout()" for a list of nodes, which come from a cache. Only called by process().
    • writeOut

      public abstract void writeOut(int index, MTree node, RationalDuration.DottedBaseDuration symbol, Rational proportion, StemEnd beams, boolean isSound, boolean isFirst, boolean isLast)
      Write out one symbol of an event.
      Parameters:
      index - the index into the original event list
      node - the MTree node (for accessing "weight" etc.)
      symbol - the (possibly dotted) symbol to print
      proportion - the currently effective proportion (for convenience!)
      beams - describes left and right beams and beamlets / flags
      isSound - whether the symbol is sound and not pause (for convenience)
      isFirst - whether the symbol is the very first in the event
      isLast - whether the symbol is the very last in the event
    • open_proportion

      public abstract void open_proportion(Rational proportion, Rational startTime)
      Start a new tuplet bracket. The parameter "proportion" is the specific proportion, as defined with the MTree.EssentialBracket class.
    • close_proportion

      public abstract void close_proportion(Rational proportion, Rational endTime)
      Close an open tuplet bracket. The parameter "proportion" is the specific proportion, as defined with the MTree.EssentialBracket class.