public class MetricalLpcfgTerminal extends java.lang.Object implements MetricalLpcfgNode, java.lang.Comparable<MetricalLpcfgTerminal>, java.io.Serializable
MetricalLpcfgTerminal
object represents a terminal symbol in the
rhythmic grammar. That is, any pattern of ties, notes, and rests which make
up an entire sub-beat in a given song's metrical structure. It is made up of a
List of MetricalLpcfgQuantum
s.Modifier and Type | Field and Description |
---|---|
private int |
baseLength
The base length of this terminal, used to normalize in
getHead() . |
private MetricalLpcfgQuantum[] |
originalPattern
The pattern of quantums that make up this terminal, in unreduced form.
|
private MetricalLpcfgQuantum[] |
reducedPattern
The pattern of quantums that make up this terminal, in fully reduced form.
|
private static long |
serialVersionUID
Version 1
|
Modifier | Constructor and Description |
---|---|
|
MetricalLpcfgTerminal()
Create a new terminal with just a single rest.
|
|
MetricalLpcfgTerminal(MetricalLpcfgQuantum[] pattern)
Create a new MetricalGrammarTerminal with the given pattern and
baseLength of 1. |
|
MetricalLpcfgTerminal(MetricalLpcfgQuantum[] pattern,
int baseLength)
Create a new MetricalGrammarTerminal with the given pattern and base length.
|
private |
MetricalLpcfgTerminal(MetricalLpcfgTerminal terminal)
Create a new MetricalGrammarTerminal, a shallow copy of the given one.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(MetricalLpcfgTerminal o) |
MetricalLpcfgTerminal |
deepCopy()
Return a copy of this terminal.
|
boolean |
equals(java.lang.Object other) |
private static MetricalLpcfgQuantum[] |
generateReducedPattern(MetricalLpcfgQuantum[] pattern)
Convert the given pattern into reduced form and return it.
|
private static int |
getGCF(MetricalLpcfgQuantum[] pattern)
Get the greatest common factor of the lengths of all of the constituents in the given
pattern.
|
MetricalLpcfgHead |
getHead()
Get the head of this terminal.
|
int |
getLength()
Get the length of this node, measured in sub beats.
|
MetricalLpcfgQuantum[] |
getOriginalPattern()
Get the original unreduced pattern of this terminal.
|
MetricalLpcfgQuantum[] |
getReducedPattern()
Get the pattern of this terminal.
|
MetricalLpcfgTerminal |
getTerminal()
Get the terminal at this level of the tree.
|
int |
hashCode() |
private static void |
incrementLast(java.util.List<java.lang.Integer> list)
Utility method to increment the last value in an Integer List.
|
boolean |
isEmpty()
Get whether this terminal contains any notes or not.
|
boolean |
startsWithRest()
Get if this node starts with a REST or not.
|
java.lang.String |
toString() |
java.lang.String |
toStringPretty(int depth,
java.lang.String tab)
Get the recursive String of this terminal.
|
private static final long serialVersionUID
private final MetricalLpcfgQuantum[] reducedPattern
private final MetricalLpcfgQuantum[] originalPattern
private final int baseLength
getHead()
.public MetricalLpcfgTerminal()
public MetricalLpcfgTerminal(MetricalLpcfgQuantum[] pattern)
baseLength
of 1. This
will convert the given pattern into reduced form before saving it.pattern
- The given pattern, in non-reduced form.public MetricalLpcfgTerminal(MetricalLpcfgQuantum[] pattern, int baseLength)
pattern
- The given pattern, in non-reduced form.baseLength
- baseLength
private MetricalLpcfgTerminal(MetricalLpcfgTerminal terminal)
private static MetricalLpcfgQuantum[] generateReducedPattern(MetricalLpcfgQuantum[] pattern)
pattern
- The pattern we want to reduce.private static int getGCF(MetricalLpcfgQuantum[] pattern)
pattern
- The pattern we want to reduce.private static void incrementLast(java.util.List<java.lang.Integer> list)
list
- The Integer List whose last value we want to increment.public boolean isEmpty()
isEmpty
in interface MetricalLpcfgNode
public boolean startsWithRest()
MetricalLpcfgNode
startsWithRest
in interface MetricalLpcfgNode
public MetricalLpcfgHead getHead()
getHead
in interface MetricalLpcfgNode
public int getLength()
MetricalLpcfgNode
getLength
in interface MetricalLpcfgNode
public MetricalLpcfgQuantum[] getReducedPattern()
reducedPattern
public MetricalLpcfgQuantum[] getOriginalPattern()
originalPattern
public MetricalLpcfgTerminal getTerminal()
MetricalLpcfgNode
getTerminal
in interface MetricalLpcfgNode
public MetricalLpcfgTerminal deepCopy()
deepCopy
in interface MetricalLpcfgNode
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toStringPretty(int depth, java.lang.String tab)
toStringPretty
in interface MetricalLpcfgNode
depth
- The depth of this node.tab
- The tab String to indent tree levels.public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(MetricalLpcfgTerminal o)
compareTo
in interface java.lang.Comparable<MetricalLpcfgTerminal>