- //AUBIO_DBG ("beat: %f, bp: %f, phase: %f, lastbeat: %f, step: %d, winlen: %d\n",
- // beat, bp, phase, bt->lastbeat, step, winlen);
+
+ // AUBIO_DBG ("bp: %f, phase: %f, lastbeat: %f, step: %d, winlen: %d\n",
+ // bp, phase, bt->lastbeat, step, winlen);
+
+ /* the next beat will be earlier than 60% of the tempo period
+ skip this one */
+ if ( ( step - bt->lastbeat - phase ) < -0.40 * bp ) {
+#if AUBIO_BEAT_WARNINGS
+ AUBIO_WRN ("back off-beat error, skipping this beat\n");
+#endif /* AUBIO_BEAT_WARNINGS */
+ beat += bp;
+ }
+