shithub: aubio

Download patch

ref: 54a5d5659db6f03a7b7d9c0df7a7571f18315154
parent: 0482e7675f5580c340a188f29fc6ae7485809066
author: Paul Brossier <piem@piem.org>
date: Sat Sep 12 09:14:53 EDT 2009

examples/aubiotrack.c: compute sample accurate beat position

--- a/examples/aubiotrack.c
+++ b/examples/aubiotrack.c
@@ -23,7 +23,7 @@
 uint_t usepitch           = 0;
 fvec_t * out              = NULL;
 aubio_tempo_t * bt        = NULL;
-uint_t istactus           = 0;
+smpl_t istactus           = 0;
 
 int aubio_process(float **input, float **output, int nframes);
 int aubio_process(float **input, float **output, int nframes) {
@@ -42,8 +42,8 @@
     if (pos == overlap_size-1) {         
       /* block loop */
       aubio_tempo(bt,ibuf,out);
-      if (out->data[0][0]==1) 
-        istactus = 1;
+      if (out->data[0][0]>=1) 
+        istactus = out->data[0][0];
       else 
         istactus = 0;
       if (istactus) {
@@ -64,8 +64,9 @@
 void process_print (void);
 void process_print (void) {
         if (output_filename == NULL) {
-                if (istactus)
-                        outmsg("%f\n",(frames)*overlap_size/(float)samplerate); 
+                if (istactus) {
+                        outmsg("%f\n",((smpl_t)(frames*overlap_size)+(istactus-1.)*overlap_size)/(smpl_t)samplerate); 
+                }
                 if (isonset && verbose)
                         outmsg(" \t \t%f\n",(frames)*overlap_size/(float)samplerate);
         }