double[][] tempBeatRVArray =
new double[(int) phrase.getEndTime() * beatsPerBar][];
int beatCount = 0;
int absoluteNotesProcessed = 0;
double absoluteCumulativeRV = 0;
Note note;
while (absoluteNotesProcessed < phrase.size()) {
int originalNotesProcessed = absoluteNotesProcessed;
double originalCumulativeRV = absoluteCumulativeRV;
int notesProcessed = absoluteNotesProcessed;
double cumulativeRV = absoluteCumulativeRV;
double[] tempRVArray = new double[phrase.size()];
int count = 0;
note = phrase.getNote(notesProcessed++);
double rhythmValue = note.getRhythmValue();
tempRVArray[count++] = rhythmValue;
if (note.getPitch() == Note.REST) {
tempRVArray[count - 1] *= -1;
}
cumulativeRV += rhythmValue;
while (cumulativeRV != Math.ceil(cumulativeRV)) {
note = phrase.getNote(notesProcessed++);
rhythmValue = note.getRhythmValue();
tempRVArray[count++] = rhythmValue;
if (note.getPitch() == Note.REST) {
tempRVArray[count - 1] *= -1;
}
cumulativeRV += rhythmValue;
}
double[] RVArray = new double[count];
System.arraycopy(tempRVArray, 0, RVArray, 0, count);
tempBeatRVArray[beatCount++] = RVArray;
absoluteNotesProcessed = notesProcessed;
absoluteCumulativeRV = cumulativeRV;
while (cumulativeRV < originalCumulativeRV + (double) beatsPerBar
&& notesProcessed < phrase.size()) {
note = phrase.getNote(notesProcessed++);
rhythmValue = note.getRhythmValue();
tempRVArray[count++] = rhythmValue;
if (note.getPitch() == Note.REST) {
tempRVArray[count - 1] *= -1;
}
cumulativeRV += rhythmValue;
while (cumulativeRV != Math.ceil(cumulativeRV)) {
note = phrase.getNote(notesProcessed++);
rhythmValue = note.getRhythmValue();
tempRVArray[count++] = rhythmValue;
if (note.getPitch() == Note.REST) {
tempRVArray[count - 1] *= -1;
}
cumulativeRV += rhythmValue;
}