Index: examples/aubiotrack.c
===================================================================
--- examples/aubiotrack.c	(revision 97b8c3d3dcad65ae6bf73d01166802374c2fc965)
+++ examples/aubiotrack.c	(revision 0ce9acc35b494f0c95b383c075fe422836928257)
@@ -27,7 +27,5 @@
 aubio_beattracking_t * bt = NULL;
 uint_t winlen             = 512;
-uint_t step               = 128;
-uint_t laglen             = 128;
-uint_t rayparam           = 43;
+uint_t step               = 0;
 uint_t istactus           = 0;
 
@@ -84,4 +82,6 @@
               if (pos2 == btoutput[i]) {
                       //printf("pos2: %d\n", pos2);
+                      //printf("tempo:\t%3.5f bpm \n", 
+                      //60.*44100./overlap_size/abs(btoutput[2]-btoutput[1]));
                       /* test for silence */
                       if (aubio_silence_detection(ibuf, threshold2)==1) {
@@ -123,7 +123,10 @@
   /* override default settings */
   examples_common_init(argc,argv);
+  winlen = SQR(512)/overlap_size;
 
   dfframe = new_fvec(winlen,channels);
+  step = winlen/4;
   out = new_fvec(step,channels);
+
   /* test input : impulses starting from 15, at intervals of 50 samples */
   //for(i=0;i<16;i++){ 
@@ -131,6 +134,5 @@
   //}
 
-  bt = new_aubio_beattracking(winlen,step, laglen,
-                  rayparam, channels);
+  bt = new_aubio_beattracking(winlen,channels);
 
   examples_common_process(aubio_process,process_print);
Index: examples/utils.c
===================================================================
--- examples/utils.c	(revision 97b8c3d3dcad65ae6bf73d01166802374c2fc965)
+++ examples/utils.c	(revision 0ce9acc35b494f0c95b383c075fe422836928257)
@@ -98,5 +98,5 @@
 
 int parse_args (int argc, char **argv) {
-        const char *options = "hvjo:i:O:t:s:a";
+        const char *options = "hvjo:i:O:t:s:H:a";
         int next_option;
         struct option long_options[] =
@@ -111,4 +111,5 @@
                 {"silence"  , 0, NULL, 's'},
                 {"averaging", 0, NULL, 'a'},
+                {"hopsize",   0, NULL, 'H'},
                 {NULL       , 0, NULL, 0}
         };
@@ -169,4 +170,7 @@
                                 averaging = 1;
                                 break; 
+                        case 'H':
+                                overlap_size = atoi(optarg);
+                                break;
                         case '?': 	/* unknown options */
                                 usage(stderr, 1);
Index: src/beattracking.c
===================================================================
--- src/beattracking.c	(revision 97b8c3d3dcad65ae6bf73d01166802374c2fc965)
+++ src/beattracking.c	(revision 0ce9acc35b494f0c95b383c075fe422836928257)
@@ -23,36 +23,30 @@
 #include "beattracking.h"
 
+// 60*samplerate/winlen
+
 /* maximum length for rp */
-static uint_t MAXRP = 512;
 static smpl_t constthresh = 3.901; //empirically derived!
-static smpl_t stepthresh = 2.*3.901;
 
 uint_t fvec_gettimesig(smpl_t * acf, uint_t acflen, uint_t gp);
 void aubio_beattracking_checkstate(aubio_beattracking_t * bt);
-smpl_t fvec_getperiod(smpl_t * acf, uint_t timesig, uint_t rp);
+smpl_t fvec_getperiod(aubio_beattracking_t * bt, uint_t timesig, uint_t rp);
 
 /* could move to struct */
-uint_t gp=0, bp = 0, rp1 = 0, rp2 = 0, bp2 = 0;
-smpl_t g_mu =0.;
-smpl_t g_var = 3.901;
-uint_t flagconst = 0;
-uint_t flagstep  = 0;
+uint_t gp         = 0, bp  = 0, rp1 = 0, rp2 = 0, bp2 = 0;
+smpl_t g_mu       = 0.;
+smpl_t g_var      = 3.901;
+uint_t flagconst  = 0;
+uint_t flagstep   = 0;
 // needs to be a signed ?
-sint_t counter = 0;
-uint_t maxindex  = 0;
-uint_t timesig   = 0;
-uint_t rp        = 1;
-uint_t lastbeat  = 0;
+sint_t counter    = 0;
+uint_t maxindex   = 0;
+uint_t timesig    = 0;
+uint_t rp         = 1;
+uint_t lastbeat   = 0;
 //number of harmonics in shift invariant comb filterbank
-uint_t numelem   = 4;
-smpl_t myperiod = 0.;
-
-
-// FIXME
+uint_t numelem    = 4;
+smpl_t myperiod   = 0.;
+
 uint_t maxnumelem = 4;
-uint_t len = 512;
-smpl_t inds[4]; //vector for max index outputs for each harmonic
-smpl_t local_acf[512]; //vector to store harmonics of filterbank of acf
-
 
 struct _aubio_beattracking_t {
@@ -67,17 +61,20 @@
         //uint_t timesig;  /* time signature of input, set to zero until context dependent model activated */
         uint_t step;
+        fvec_t * locacf; /* vector to store harmonics of filterbank of acf */
+        fvec_t * inds;      /* vector for max index outputs for each harmonic */
+        uint_t rayparam; /* Rayleigh parameter */
 };
 
 aubio_beattracking_t * new_aubio_beattracking(uint_t winlen,
-                uint_t step,
-                uint_t laglen,
-                uint_t rayparam,
                 uint_t channels) {
 
         aubio_beattracking_t * p = AUBIO_NEW(aubio_beattracking_t);
-
         uint_t i        = 0;
+        smpl_t rayparam = 48./512. * winlen;
         smpl_t dfwvnorm = EXP((LOG(2.0)/rayparam)*(winlen+2));
-
+        uint_t laglen   = winlen/4;
+        uint_t step     = winlen/4; /* 1.5 seconds */
+
+        p->rayparam = rayparam;
         p->step    = step;
         p->rwv     = new_fvec(laglen,channels);
@@ -88,6 +85,10 @@
         p->acfout  = new_fvec(laglen,channels);
         p->phwv    = new_fvec(2*laglen,channels);
-        p->phout   = new_fvec(MAXRP,channels);
+        p->phout   = new_fvec(winlen,channels);
+
         //p->timesig = 0;
+
+        p->inds    = new_fvec(maxnumelem,channels);
+        p->locacf  = new_fvec(winlen,channels); 
 
         /* exponential weighting, dfwv = 0.5 when i =  43 */
@@ -115,4 +116,6 @@
         del_fvec(p->phwv);
         del_fvec(p->phout);
+        del_fvec(p->locacf);
+        del_fvec(p->inds);
         AUBIO_FREE(p);
 }
@@ -158,12 +161,10 @@
         /* get acfout - assume Rayleigh weightvector only */
         /* if timesig is unknown, use metrically unbiased version of filterbank */
-        //if(!timesig)  
-        //        AUBIO_DBG("using unbiased filterbank, timesig: %d\n", timesig);
-        //else          
-        //        AUBIO_DBG("using biased filterbank, timesig: %d\n", timesig);
         if(!timesig)  
                 numelem = 4;
+        //        AUBIO_DBG("using unbiased filterbank, timesig: %d\n", timesig);
         else
                 numelem = timesig;
+        //        AUBIO_DBG("using biased filterbank, timesig: %d\n", timesig);
 
         /* first and last output values are left intentionally as zero */
@@ -183,11 +184,11 @@
         maxindex = vec_max_elem(bt->acfout);
         rp = maxindex ? maxindex : 1;
-        rp = (maxindex==127) ? 43 : maxindex; //rayparam
+        //rp = (maxindex==127) ? 43 : maxindex; //rayparam
+        rp = (maxindex==bt->acfout->length-1) ? bt->rayparam : maxindex; //rayparam
 
         // get float period
-        myperiod = fvec_getperiod(acf,timesig,rp);
+        myperiod = fvec_getperiod(bt,timesig,rp);
 	//AUBIO_DBG("\nrp =  %d myperiod = %f\n",rp,myperiod);
 	//AUBIO_DBG("accurate tempo is %f bpm\n",5168./myperiod);
-	
 
         /* activate biased filterbank */
@@ -196,8 +197,7 @@
 
         /* initialize output */
-        for(i=0;i<MAXRP;i++)     {phout[i] = 0.;} 
-
-        /* deliberate integer operation */
-        /* could be set to 3 max eventually */
+        for(i=0;i<bt->phout->length;i++)     {phout[i] = 0.;} 
+
+        /* deliberate integer operation, could be set to 3 max eventually */
         kmax = winlen/bp;
 
@@ -239,7 +239,6 @@
 
         lastbeat = beat;
-
+        /* store the number of beat found in this frame as the first element */
         output->data[0][0] = i;
-
 }
 
@@ -262,5 +261,5 @@
 }
 
-smpl_t fvec_getperiod(smpl_t * acf, uint_t timesig, uint_t rp){
+smpl_t fvec_getperiod(aubio_beattracking_t * bt, uint_t timesig, uint_t rp){
       	/*function to make a more accurate beat period measurement.*/
 
@@ -268,7 +267,5 @@
 	smpl_t maxval = 0.;
 	
-
-
-	int a,b;
+	sint_t a,b;
 	uint_t i,j;	
 	uint_t acfmi = rp; //acfout max index
@@ -281,15 +278,16 @@
 
 	for (i=0;i<numelem;i++) // initialize
-	inds[i] = 0.;
-
-	for (i=0;i<len;i++) // initialize
-	local_acf[i] = 0.;
+	bt->inds->data[0][i] = 0.;
+
+	for (i=0;i<bt->locacf->length;i++) // initialize
+                bt->locacf->data[0][i] = 0.;
 	
-	// get appropriate acf elements from acf and store in local_acf
-	for (a=1;a<=4;a++){
-	     	for(b=(1-a);b<a;b++){		
-               		local_acf[a*(acfmi)+b-1] = acf[a*(acfmi)+b-1];		               	           	      
-               	            }
-			}
+	// get appropriate acf elements from acf and store in locacf
+        for (a=1;a<=4;a++){
+                for(b=(1-a);b<a;b++){		
+                        bt->locacf->data[0][a*(acfmi)+b-1] = 
+                                bt->acf->data[0][a*(acfmi)+b-1];		               	           	      
+                }
+        }
 
 	for(i=0;i<numelem;i++){
@@ -299,18 +297,18 @@
 	
 		for (j=0;j<(acfmi*(i+1)+(i)); j++){
-			if(local_acf[j]>maxval){
-				maxval = local_acf[j];
-				maxind = j;
-				}
-				local_acf[maxind] = 0.;
+                        if(bt->locacf->data[0][j]>maxval){
+                                maxval = bt->locacf->data[0][j];
+                                maxind = j;
+                        }
+                        //bt->locacf->data[0][maxind] = 0.;
+                        bt->locacf->data[0][j] = 0.;
 		}
-		//printf("\n\n");
 		//AUBIO_DBG("\n maxind is  %d\n",maxind);
-		inds[i] = maxind;
+		bt->inds->data[0][i] = maxind;
 
 	}
 
 	for (i=0;i<numelem;i++){
-		period += inds[i]/(i+1.);}
+		period += bt->inds->data[0][i]/(i+1.);}
 
 	period = period/numelem;
@@ -357,7 +355,7 @@
 
         //now look for step change - i.e. a difference between gp and rp that 
-        // is greater than stepthresh - always true in first case, since gp = 0
+        // is greater than 2*constthresh - always true in first case, since gp = 0
         if(counter == 0){
-                if(ABS(gp - rp) > stepthresh) {
+                if(ABS(gp - rp) > 2.*constthresh) {
                         flagstep = 1; // have observed  step change.
                         counter  = 3; // setup 3 frame counter
@@ -421,9 +419,11 @@
         /* if tempo is > 206 bpm, half it */
         while (bp < 25) {
-                AUBIO_DBG("warning, halving the tempo from %f\n", 5168./bp);
+        //while (bp < fact/206.) {
+                AUBIO_DBG("warning, doubling the beat period from %d\n", bp);
+                //AUBIO_DBG("warning, halving the tempo from %f\n", 60.*samplerate/hopsize/bp);
                 bp = bp*2;
         }
         
-        AUBIO_DBG("tempo:\t%3.5f bpm | ", 5168./bp);
+        //AUBIO_DBG("tempo:\t%3.5f bpm | ", 5168./bp);
 
         /* smoothing */
@@ -431,5 +431,5 @@
         //AUBIO_DBG("tempo:\t%3.5f bpm smoothed | bp2 %d | bp %d | ", 5168./bp, bp2, bp);
         //bp2 = bp;
-        AUBIO_DBG("time signature: %d \n", timesig);
-
-}
+        //AUBIO_DBG("time signature: %d \n", timesig);
+
+}
Index: src/beattracking.h
===================================================================
--- src/beattracking.h	(revision 97b8c3d3dcad65ae6bf73d01166802374c2fc965)
+++ src/beattracking.h	(revision 0ce9acc35b494f0c95b383c075fe422836928257)
@@ -37,7 +37,4 @@
  * \param channel number (not functionnal) [1] */
 aubio_beattracking_t * new_aubio_beattracking(uint_t winlen,
-                uint_t step,
-                uint_t laglen,
-                uint_t rayparam,
                 uint_t channels);
 /**
