Package eu.bandm.music.entities
Class MSplitter.Result.WriteOut
java.lang.Object
eu.bandm.music.entities.MSplitter.Result.WriteOut
- Direct Known Subclasses:
MSplitter.Result.Dumper
- Enclosing class:
- MSplitter.Result
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
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.
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 Summary
Modifier and TypeFieldDescriptionfinal Stack<MTree.EssentialBracket>
Keeps track of n-plet-brackets currently open.(package private) Rational
Running state of the proportion to be applied to the printed symbols of the currently visited node. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
close_proportion
(Rational proportion, Rational endTime) Close an open tuplet bracket.abstract void
open_proportion
(Rational proportion, Rational startTime) Start a new tuplet bracket.void
process()
Loop through all events in this result and call the call-back methodwriteOut(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.protected void
testCloseBrackets
(Rational when) Called for each node to close essential n-plet-brackets, iff their end-of-duration is reached.protected void
testOpenBrackets
(MTree start, boolean printedNode) Called for each node to open essential n-plet-brackets, iff necessary for the following duration values.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.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.
-
Field Details
-
currentProportion
Rational currentProportionRunning state of the proportion to be applied to the printed symbols of the currently visited node. -
bracketStack
Keeps track of n-plet-brackets currently open. FIXME besser an immutable copy !?!?
-
-
Constructor Details
-
WriteOut
public WriteOut()
-
-
Method Details
-
testCloseBrackets
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 methodclose_proportion(Rational,Rational)
is called. -
testOpenBrackets
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 methodopen_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-backsopen_proportion(Rational,Rational)
andclose_proportion(Rational,Rational)
get the rational factor of the currently opened/closed bracket as an argument, while the (readable) globalcurrentProportion
holds the accumulated effective proportion (also passed as a parameter towriteOut(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 methodwriteOut(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 toopen_proportion(Rational,Rational)
andclose_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 byprocess()
. -
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 listnode
- the MTree node (for accessing "weight" etc.)symbol
- the (possibly dotted) symbol to printproportion
- the currently effective proportion (for convenience!)beams
- describes left and right beams and beamlets / flagsisSound
- whether the symbol is sound and not pause (for convenience)isFirst
- whether the symbol is the very first in the eventisLast
- whether the symbol is the very last in the event
-
open_proportion
Start a new tuplet bracket. The parameter "proportion" is the specific proportion, as defined with theMTree.EssentialBracket
class. -
close_proportion
Close an open tuplet bracket. The parameter "proportion" is the specific proportion, as defined with theMTree.EssentialBracket
class.
-