smoothBpm method
Implementation
void smoothBpm() {
//bpmCorrectedIndices = new List<>();
//correctionCount = 0;
//reduce zeros and jumps
for (int i = 1; i < bpmListSmooth!.length; i++) {
if (bpmListSmooth![i] == 0) {
correctionCount = correctionCount! + 1;
bpmListSmooth![i] = getNextNonZeroBpm(i, bpmListSmooth);
}
}
//Log.i("Correction count", correctionCount + "");
for (int i = 1; i < bpmListSmooth!.length; i++) {
int startData = bpmListSmooth![i - 1];
int stopData = bpmListSmooth![i];
if (startData < 60 ||
stopData < 60 ||
startData > 210 ||
stopData > 210 ||
(startData - stopData).abs() > 35) {
//correctionCount++;
if(stopData-startData>60) {
bpmListSmooth![--i] =((startData+stopData)/2).truncate() ;
} else {
bpmListSmooth![i] = getNextValidBpm(i, bpmListSmooth!);
}
//bpmCorrectedIndices.add(i);
//Log.i("Correction", i + "");
}
}
//Log.i("Correction count", correctionCount + "");
int window = FACTOR * 4;
for (int i = window; i < bpmListSmooth!.length - window - 1; i++) {
bpmListSmooth![i] = getWindowAvreage(bpmListSmooth!, i, window);
}
double tiny = 0.33;
int start = bpmListSmooth!.length - 60;
start = start<0?0:start;
for (int i = start; i < bpmListSmooth!.length - 1; i++) {
bpmListSmooth![i + 1] =
(tiny * bpmListSmooth![i] + (1.0 - tiny) * bpmListSmooth![i + 1])
.truncate();
}
/*window = (int) FACTOR * 2;
for (int i = window; i < bpmListSmooth.length - window - 1; i++) {
bpmListSmooth.set(i, getWindowAvreage(i, window));
}*/
}