public class MetricTree extends Object implements MetrumIndication
initialize()
or #initialize(Reaction)
must be called which checks and distributes the missing
duration values. The result must be conflict-free and total.
Modifier and Type | Class and Description |
---|---|
static class |
MetricTree.EssentialBracket
Realizes an n-tuplet-bracket which is necessary for the notation of
some continuous sequence of nodes, because a new prime factor is introduced
in the denominators of their durations.
|
static class |
MetricTree.Origin |
static class |
MetricTree.QualifiedRational
Realizes duration X boolean = sound_notPause.
|
class |
MetricTree.Visitor
User must redefine action(), openProportion(), closeProportion().
|
Modifier and Type | Field and Description |
---|---|
(package private) MetricTree |
alternative |
(package private) MetricTree.EssentialBracket |
bracketStart |
(package private) Rational |
duration |
(package private) Rational |
end |
(package private) boolean |
equidist |
(package private) boolean |
explicitDuration |
(package private) boolean |
initialized |
(package private) MetricTree.Origin |
origin
Kind of origin, either explictly by user, or by different automatic augmentations.
|
protected static Function<List<MetricTree>,MetricTree> |
packAlt |
protected static Function<List<MetricTree>,MetricTree> |
packConcat |
protected static Function3<Integer,Integer,MetricTree,MetricTree> |
packDivTree |
protected static Function2<Integer,MetricTree,MetricTree> |
packMul |
protected static Function<Integer,MetricTree> |
packSimple |
(package private) MetricTree |
parent |
protected static Translet.Parser<MetricTree> |
parser_alt |
protected static Translet.Parser<MetricTree> |
parser_concat |
static Translet.Parser<MetricTree> |
parser_summand |
protected static Translet.Recursive<MetricTree> |
parser_summand_recursive |
static Translet.Parser<MetricTree> |
parser_timed |
(package private) int |
position
Position in the parents' list, starting from zero(0).
|
(package private) Rational |
start |
(package private) List<MetricTree> |
subs |
Constructor and Description |
---|
MetricTree(int num,
int den,
MetricTree... args)
Create one node with arg nodes as sub-nodes, and an explicit duration.
|
MetricTree(List<MetricTree> args)
Create one node with arg nodes as sub-nodes.
|
MetricTree(MetricTree... args)
Create one node with arg nodes as sub-nodes.
|
MetricTree(Rational rat,
List<MetricTree> args)
Create one node with arg nodes as sub-nodes, and an explicit duration.
|
MetricTree(Rational rat,
MetricTree... args)
Create one node with arg nodes as sub-nodes, and an explicit duration.
|
Modifier and Type | Method and Description |
---|---|
MetricTree |
addAlternative(MetricTree alt) |
static String |
arrayToString(Object[] array) |
protected void |
calcStartEnd(Rational start)
|
protected void |
collectBrackets()
Make potential n-plet-brackets, merge brackets over more than one child
into one(1), iff appropriate.
|
Rational |
constantRationalMeasureDuration()
Returns the length of a measure.
|
protected MetricTree |
deepCopy()
Converts into individuum and fills context dependend fields (pos, parent).
|
(package private) void |
divide_by_odd_or_2(int num)
Adds a number of equidistant sub-trees.
|
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.
|
MetricTree |
get_alternative() |
Rational |
get_duration() |
Rational |
get_end() |
boolean |
get_explicitDuration() |
boolean |
get_initialized() |
MetricTree.Origin |
get_origin()
Whether this has been created explicitly, or by implicit division, or ..
|
MetricTree |
get_parent() |
int |
get_position()
Position in the parents' list, starting from zero(0).
|
int |
get_size_binary()
Returns the number of children of this node.
|
int |
get_size() |
Rational |
get_start() |
List<MetricTree> |
get_subs_binary()
Returns the list of children of this node.
|
List<MetricTree> |
get_subs() |
MetricTree |
getFollowing()
Returns the highest node which starts at the timepoint when this ends.
|
MetricTree |
getFollowingSibling()
Returns the node which is child of the same parent, and one position further,
iff it exists, otherwise null.
|
MetricTree |
getPrecedingSibling()
Returns the node which is child of the same parent, and one position earlier,
iff it exists, otherwise null.
|
MetricTree |
initialize()
Calls
#initialize(Reaction) with Modifiers.Reaction.silentlyAllow . |
MetricTree |
initialize(Modifiers.Reaction redundantDuration)
Delivers an initialized, ready to use NEW COPY of the given MetricTree.
|
boolean |
is_equi_binary()
Returns whether the cild level is divided equidistantly by two.
|
boolean |
isFollowingSiblingOf(MetricTree predec)
Returns whether this node is child of the same parent and one position further.
|
static void |
main(String[] args)
Perform some tests via
test_i(MetricTree) and test_p(String) . |
protected void |
makeBracket(PrimeFactors factors,
int startPos,
int endPos)
Make an instance of EssentialBracket and link it to the child node of "this"
at the given start position (if !=1).
|
static MetricTree |
parseAndInitialize(String s)
Create one node by parsing.
|
static Translet.Parser<MetricTree> |
parser()
Frontend for constructing a MetricTree, supporting durations at arbitrarily
distributed points, as long as a consistent completion is possible, exactly as
with the constructor calls.
|
String |
posString()
Return a position indidication, i.e.
|
protected void |
propagateDown_alt(Rational altdur,
Modifiers.Reaction redundantDuration)
The duration of some alternative of the node is fixed
(explicitly when constructing, or by upward propagation;
in altdur != null).
|
protected void |
propagateDown(Modifiers.Reaction redundantDuration)
The duration of the node is fixed (by construction or by downward propagation or
by some alternative.) Either all children do not have a duration, then the
duration is distributed equally among them, or only one child does not have a
duration and gets the rest.
|
protected void |
propagateUp(Modifiers.Reaction redundantDuration)
Visit depth-first and sum-up the durations of children, as long as possible and
necessary.
|
protected void |
reduceBrackets(PrimeFactors factors)
Remove a factor from a previously (bottom up) constructed bracket,
because it is now realized by a bracket on the next higher level.
|
protected MetricTree |
shallowCopy()
Makes new "empty" node as boilerplate for deep copy and for
synthesizing new alternatives.
|
protected static void |
test_i(MetricTree mt)
Test the initialization (ie.
|
protected static void |
test_p(String s)
Test parsing and initialization for the text representation of a MetricTree.
|
String |
toString()
gives one-line rendering.
|
MetricTree.Origin origin
int position
List<MetricTree> subs
MetricTree parent
MetricTree alternative
Rational duration
Rational start
Rational end
boolean explicitDuration
boolean initialized
boolean equidist
MetricTree.EssentialBracket bracketStart
protected static Function<List<MetricTree>,MetricTree> packConcat
protected static Function<List<MetricTree>,MetricTree> packAlt
protected static Function2<Integer,MetricTree,MetricTree> packMul
protected static Function<Integer,MetricTree> packSimple
protected static Function3<Integer,Integer,MetricTree,MetricTree> packDivTree
protected static final Translet.Recursive<MetricTree> parser_summand_recursive
protected static final Translet.Parser<MetricTree> parser_concat
protected static final Translet.Parser<MetricTree> parser_alt
public static Translet.Parser<MetricTree> parser_timed
public static Translet.Parser<MetricTree> parser_summand
public MetricTree(List<MetricTree> args)
public MetricTree(MetricTree... args)
public MetricTree(Rational rat, List<MetricTree> args)
public MetricTree(int num, int den, MetricTree... args)
public MetricTree(Rational rat, MetricTree... args)
public static MetricTree parseAndInitialize(String s)
public MetricTree addAlternative(MetricTree alt)
public Rational constantRationalMeasureDuration()
constantRationalMeasureDuration
in interface MetrumIndication
public String posString()
public String toString()
dump(PrintStream)
, which gives a
multi-line indented view.public int get_position()
public int get_size()
public MetricTree.Origin get_origin()
public List<MetricTree> get_subs()
public MetricTree get_parent()
public MetricTree get_alternative()
public boolean get_initialized()
public Rational get_start()
public Rational get_end()
public Rational get_duration()
public boolean get_explicitDuration()
public boolean isFollowingSiblingOf(MetricTree predec)
public MetricTree getFollowingSibling()
alternative
, which have a different structure, but
the same duration.public MetricTree getPrecedingSibling()
alternative
, which have a different structure, but
the same duration.public MetricTree getFollowing()
alternative
, which have a different structure, but
the same duration. public List<MetricTree> get_subs_binary()
void divide_by_odd_or_2(int num)
public int get_size_binary()
public boolean is_equi_binary()
public MetricTree initialize(Modifiers.Reaction redundantDuration)
duration
fields are set.
The durations of the children of such a node are calculated by equidistant
division.
The duration of a node where all childern have a duration is by summing them up.
After all durations have been set, the start positions are defined by summing up
the preceding siblings.
The user is free to define durations at very different positions of a fresh
MetricTree, before calling the method. This may result in inconsistencies,
which are signalled as exceptions.
Esp. when tuplets shall be combined, durations must be inserted explicitly.
new MetricTree(new MetricTree (3,4, new MetricTree(), new MetricTree(), new MetricTree()), new MetricTree (2,4, new MetricTree(), new MetricTree(), new MetricTree()) ):... defines a measure with three(3) quarter notes (1/4) in its first part, and three(3) quarter triplets(1/6) in its second part.
p=dp p=dp / \ \ / \ / x=? =? =? x=? y=py x=? / \ \ c=dc d=dd e=de
redundantDuration
- how to react when the duration of a particular node is
defined by more than one(>1) sources to the same value.public MetricTree initialize()
#initialize(Reaction)
with Modifiers.Reaction.silentlyAllow
.protected MetricTree deepCopy()
initialize()
and by "new MetricSplitter()".protected MetricTree shallowCopy()
deepCopy()
and by "MetricSplitter.processSpontanuous()"
(followed by #divide_by_odd(int)
).protected void calcStartEnd(Rational start)
protected void propagateUp(Modifiers.Reaction redundantDuration)
#propagateDown(Reaction)
for the sub-tree.protected void propagateDown_alt(Rational altdur, Modifiers.Reaction redundantDuration)
protected void propagateDown(Modifiers.Reaction redundantDuration)
protected void collectBrackets()
1/3 // = triplet-half / \ 1/4 1/12 // divided into quarter and triplet eights
protected void makeBracket(PrimeFactors factors, int startPos, int endPos)
#reduceBracket(EssentialBracket,PrimeFactors)
.protected void reduceBrackets(PrimeFactors factors)
public static Translet.Parser<MetricTree> parser()
3/4(3) 1/1(3*2) 2*2*3 //will fail to initialize due to missing duration information 1/1(2*2*3) 2*2*3*1/12 1/8(3) 1/8(2*3) 1/1(3*1/8+3) (1/8+1/8)+1/2(1+2) NEW: 2*2+(1/4|3*1/12) // eighth-triplets 2*(1/2|3*1/6) // quarter-triplets 2*2*(1/4|3*1/12|5*1/20) 2 * 2 * (1/4 | 3*1/12 | 5*1/20)
public void dump()
public void dump(PrintStream p)
public void dump(PrintWriter p)
protected static void test_i(MetricTree mt)
protected static void test_p(String s)
public static void main(String[] args)
test_i(MetricTree)
and test_p(String)
.