ref: 3de10bb04fa4475b62c9a93ec9066bc8898931b5
parent: e792ea85606ab3703e8c82ad2881f1e2c9e2c5c5
author: Paul Brossier <piem@piem.org>
date: Sat Sep 26 22:19:49 EDT 2009
src/tempo/beattracking.c: fix maxindex == winlen never reached condition, avoiding very large bpm values, add some debugging strings
--- a/src/tempo/beattracking.c
+++ b/src/tempo/beattracking.c
@@ -193,9 +193,12 @@
/* find Rayleigh period */
maxindex = vec_max_elem (bt->phout);
- if (maxindex == winlen)
- maxindex = 0;
- phase = 1. + vec_quadint (bt->phout, maxindex, 1);
+ if (maxindex >= winlen - 1) {
+ // AUBIO_WRN ("damned, no idea what this groove is\n");
+ phase = step - bt->lastbeat;
+ } else {
+ phase = vec_quadint (bt->phout, maxindex, 1);
+ }
#if 0 // debug metronome mode
phase = step - bt->lastbeat;
#endif
@@ -205,8 +208,15 @@
i = 1;
beat = bp - phase;
+ //AUBIO_DBG ("beat: %f, bp: %f, phase: %f, lastbeat: %f, step: %d, winlen: %d\n",
+ // beat, bp, phase, bt->lastbeat, step, winlen);
/* start counting the beats */
+ while (beat + bp < 0) {
+ beat += bp;
+ }
+
if (beat >= 0) {
+ //AUBIO_DBG ("beat: %d, %f, %f\n", i, bp, beat);
output->data[0][i] = beat;
i++;
}
@@ -213,6 +223,7 @@
while (beat + bp <= step) {
beat += bp;
+ //AUBIO_DBG ("beat: %d, %f, %f\n", i, bp, beat);
output->data[0][i] = beat;
i++;
}