shithub: aubio

Download patch

ref: ffa8607e07c2c9e6fd993551ee8d4994796601ff
parent: fda4fd765dc87b33f01668840986790b3097ec0c
author: Paul Brossier <piem@piem.org>
date: Mon Nov 25 18:26:48 EST 2013

src/tempo/beattracking.c: fix rayleigh period clamping

--- a/src/tempo/beattracking.c
+++ b/src/tempo/beattracking.c
@@ -170,9 +170,11 @@
 
   /* find non-zero Rayleigh period */
   maxindex = fvec_max_elem (bt->acfout);
-  bt->rp = maxindex ? fvec_quadratic_peak_pos (bt->acfout, maxindex) : 1;
-  //rp = (maxindex==127) ? 43 : maxindex; //rayparam
-  bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex;      //rayparam
+  if (maxindex > 0 && maxindex < bt->acfout->length - 1) {
+    bt->rp = fvec_quadratic_peak_pos (bt->acfout, maxindex);
+  } else {
+    bt->rp = bt->rayparam;
+  }
 
   /* activate biased filterbank */
   aubio_beattracking_checkstate (bt);