public class MetricalLpcfgMetricalModelState extends MetricalModelState implements java.lang.Comparable<MetricalLpcfgMetricalModelState>
GrammarHierarchyModelState
is used to generate hierarchy hypotheses
using a grammar.Modifier and Type | Class and Description |
---|---|
static class |
MetricalLpcfgMetricalModelState.MetricalLpcfgMatch
A
MetricalLpcfgMatch is an enum indicating which type of match a
MetricalLpcfgMetricalModelState has matched. |
Modifier and Type | Field and Description |
---|---|
private int |
anacrusisLength
The length of the anacrusis in this state, measured in quantums.
|
private int |
beatMatches
The number of times a beat match has been found.
|
private MetricalLpcfg |
grammar
The grammar object we will use for probabilities.
|
private java.util.List<java.lang.Boolean> |
hasBegun
A List of whether each given voice has begun yet.
|
private MetricalLpcfg |
localGrammar
The local grammar for this hierarchy model state.
|
private double |
logProbability
The log probability of this hypothesis.
|
private Measure |
measure
The measure type we are looking for.
|
private int |
measureNum
The measure number of the next subbeat to be shifted onto the stack.
|
private int |
nextMeasureIndex
The index of the first beat of the next measure.
|
private java.util.Queue<MidiNote> |
notesToCheck
Notes which we have yet to check for beat and sub beat matches.
|
private java.util.List<java.util.LinkedList<MidiNote>> |
notesToCheckBeats
A List of a Queue per voice of notes to check for beat matching.
|
private int |
subBeatLength
The length of the terminals which we are looking for.
|
private int |
subBeatMatches
The number of times a sub beat match has been found.
|
private java.util.List<java.util.LinkedList<MidiNote>> |
unfinishedNotes
A List of any notes which have not yet been completely added to a Tree, divided by voice.
|
private int |
wrongMatches
The number of times a mismatch has been found.
|
beatState, voiceState
Modifier | Constructor and Description |
---|---|
|
MetricalLpcfgMetricalModelState(MetricalLpcfg grammar)
Create a new state based on the given grammar.
|
private |
MetricalLpcfgMetricalModelState(MetricalLpcfgMetricalModelState state)
Create a new state which is a deep copy of the given one (when necessary).
|
private |
MetricalLpcfgMetricalModelState(MetricalLpcfgMetricalModelState state,
MetricalLpcfg grammar,
Measure measure,
int terminalLength,
int anacrusisLength)
Create a new state based on the given grammar, measure, and terminal length, and as a partial
deep copy of the given state.
|
Modifier and Type | Method and Description |
---|---|
private void |
addMatch(MetricalLpcfgMetricalModelState.MetricalLpcfgMatch matchType)
Add the given matchType to this model.
|
private void |
addNewVoices(java.util.List<MidiNote> notes)
Add new voices into our tracking list
unfinishedNotes . |
private boolean |
allNotesFinished()
Check if all of the voices within
unfinishedNotes are empty. |
private boolean |
checkConglomerateBeatMatch(java.util.LinkedList<MidiNote> voiceNotes)
Check for a conglomerate beat match.
|
java.util.TreeSet<MetricalLpcfgMetricalModelState> |
close()
Return a TreeSet of all of the possible MidiModelStates which we could tansition into
when the input closes.
|
int |
compareTo(MetricalLpcfgMetricalModelState o) |
MetricalLpcfgMetricalModelState |
deepCopy()
Create a deep copy of this HierarchyModelState.
|
private java.util.List<MetricalLpcfgMetricalModelState> |
getAllFirstStepBranches()
Get a List of all of the first step branches we could make out of this state.
|
int |
getAnacrusisLength()
Get the anacrusis length of this model.
|
MetricalLpcfg |
getLocalGrammar()
Get the local grammar of this model.
|
Measure |
getMetricalMeasure()
Gets the Measure which is contained by this state currently.
|
double |
getScore()
Get the score of this MidiModelState.
|
int |
getSubBeatLength()
Get the terminal length of this model.
|
private int |
getTactusNormalized(int tactiPerMeasure,
Beat firstBeat,
int measure,
int tactus)
Get the tactus number as a beat index given some information about the Beats.
|
java.util.TreeSet<MetricalLpcfgMetricalModelState> |
handleIncoming(java.util.List<MidiNote> notes)
Return a TreeSet of all of the possible MidiModelStates which we could tansition into
given the List of MidiNotes.
|
private boolean |
isFullyMatched()
Return whether this model has been fully matched yet.
|
private boolean |
isWrong()
Return whether this model has been designated as wrong yet.
|
private boolean |
matches(MetricalLpcfgMetricalModelState.MetricalLpcfgMatch matchType)
Check if this model matches the given match type.
|
private void |
parseStep()
Perform a single parse step.
|
private void |
removeFinishedNotes()
Remove any notes which are entirely finished from
unfinishedNotes . |
java.lang.String |
toString() |
private void |
updateMatchType()
Go through the
notesToCheck Queue for any notes that have finished and update
the current match for any that have. |
private void |
updateMatchType(int startTactus,
int noteLengthTacti)
Update the current match for a note with the given start tactus and length.
|
private void |
updateMatchType(MidiNote note)
Update the current match type for the given note.
|
getBeatState, getVoiceState, setBeatState, setVoiceState
private final int subBeatLength
private final int anacrusisLength
private final Measure measure
private final MetricalLpcfg grammar
private final MetricalLpcfg localGrammar
private double logProbability
private int measureNum
private int nextMeasureIndex
private final java.util.List<java.lang.Boolean> hasBegun
private final java.util.List<java.util.LinkedList<MidiNote>> unfinishedNotes
private final java.util.Queue<MidiNote> notesToCheck
private final java.util.List<java.util.LinkedList<MidiNote>> notesToCheckBeats
private int subBeatMatches
private int beatMatches
private int wrongMatches
public MetricalLpcfgMetricalModelState(MetricalLpcfg grammar)
measure
and subBeatLength
fields
will be null and 0 respectively, and appropriate settings for these will be returned by the first call
to handleIncoming(List)
. This allows all possible states to be generated by a single one without
having to manually create each one each time.grammar
- grammar
private MetricalLpcfgMetricalModelState(MetricalLpcfgMetricalModelState state, MetricalLpcfg grammar, Measure measure, int terminalLength, int anacrusisLength)
state
- The old state we want this new one to be a deep copy of.grammar
- grammar
measure
- measure
terminalLength
- subBeatLength
anacrusisLength
- anacrusisLength
private MetricalLpcfgMetricalModelState(MetricalLpcfgMetricalModelState state)
state
- The state whose deep copy we want.public java.util.TreeSet<MetricalLpcfgMetricalModelState> handleIncoming(java.util.List<MidiNote> notes)
MidiModelState
handleIncoming
in class MetricalModelState
notes
- A List of the MidiNotes on which we need to transition.private java.util.List<MetricalLpcfgMetricalModelState> getAllFirstStepBranches()
public java.util.TreeSet<MetricalLpcfgMetricalModelState> close()
MidiModelState
close
in class MetricalModelState
private void parseStep()
unfinishedNotes
,
add it and its probability to our model, and then rmove any finished notes.private boolean allNotesFinished()
unfinishedNotes
are empty.private void removeFinishedNotes()
unfinishedNotes
.private void addNewVoices(java.util.List<MidiNote> notes)
unfinishedNotes
.notes
- The new notes that were just added.private void updateMatchType()
notesToCheck
Queue for any notes that have finished and update
the current match for any that have.private boolean checkConglomerateBeatMatch(java.util.LinkedList<MidiNote> voiceNotes)
voiceNotes
- The unchecked notes in the voice we want to check.private int getTactusNormalized(int tactiPerMeasure, Beat firstBeat, int measure, int tactus)
tactiPerMeasure
- The number of tacti per measure of the Beats in the Beat List. A value
of 0 will return exactly the tactus number that is passed in.firstBeat
- The first Beat of the beat tracker.measure
- The measure number of the beat we want the tactus of.tactus
- The tactus number we want adjusted.private void updateMatchType(MidiNote note)
note
- The note we need to check for a match.private void updateMatchType(int startTactus, int noteLengthTacti)
startTactus
- The tactus at which this note begins, normalized to where 0
is the beginning of the full anacrusis measure, if any exists.noteLengthTacti
- The length and tacti of the note.private boolean isFullyMatched()
private boolean isWrong()
private void addMatch(MetricalLpcfgMetricalModelState.MetricalLpcfgMatch matchType)
matchType
- The match type we want to add to this model.private boolean matches(MetricalLpcfgMetricalModelState.MetricalLpcfgMatch matchType)
matchType
- The match type we want to check our model against.public int getSubBeatLength()
subBeatLength
public int getAnacrusisLength()
anacrusisLength
public MetricalLpcfg getLocalGrammar()
localGrammar
public Measure getMetricalMeasure()
MetricalModelState
getMetricalMeasure
in class MetricalModelState
public MetricalLpcfgMetricalModelState deepCopy()
MetricalModelState
deepCopy
in class MetricalModelState
public double getScore()
MidiModelState
getScore
in class MidiModelState
public int compareTo(MetricalLpcfgMetricalModelState o)
compareTo
in interface java.lang.Comparable<MetricalLpcfgMetricalModelState>
public java.lang.String toString()
toString
in class MetricalModelState