Class MetricConsumer.WriteOut

java.lang.Object
eu.bandm.music.entities.MetricConsumer.WriteOut
Enclosing class:
MetricConsumer

public abstract class MetricConsumer.WriteOut extends Object
Basic class for writing out the result of the last MetricConsumer.getNext() call. The call-back methods must be overriden by the user. The signatures are the same as with MSplitter.Result.WriteOut. One can get the corresponding instance of the MSplitter.Result directly by MetricConsumer.getResult(), but this is seldom sensible. Only with this class the index and flag values correctly reflect the cross-measure-bar situation.
So the usage is something like
  myMetricConsumer.getNext();
  myMetricConsumer.new WriteOut(){
    &at;Override public void open_proportion(final Rational p, final Rational when){
      // user code 
    }
    &at;Override public void close_proportion(final Rational p, final Rational when){
      // user code 
    }
    &at;Override public void writeOut(final int index,
                                   final MTree node,
                                   final DottedBaseDuration duration,
                                   final Rational prop,
                                   final StemEnd beams, 
                                   final boolean isSound, 
                                   final boolean isFirst, 
                                   final boolean isLast){
      // user code 
    }
  }.process()
  
  • Field Details

  • Constructor Details

    • WriteOut

      public WriteOut()
  • Method Details

    • 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 time)
      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 time)
      Close an open tuplet bracket. The parameter "proportion" is the specific proportion, as defined with the MTree.EssentialBracket class.
    • 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.