shithub: aubio

Download patch

ref: cb0415db6f21cc0df0293b63e15f6a17b71457ef
parent: 6fadb0d573fb7a34f852f0b6ba13e4fe6a40f402
author: Paul Brossier <piem@piem.org>
date: Thu Sep 6 14:04:08 EDT 2007

tempo.{c,h}: add aubio_tempo_get_bpm, which for now just calls aubio_beattracking_get_bpm, also update test-tempo.c

--- a/examples/tests/test-tempo.c
+++ b/examples/tests/test-tempo.c
@@ -9,8 +9,14 @@
         aubio_tempo_t * o  = new_aubio_tempo(aubio_onset_complex, win_s, win_s/4, channels);
         uint_t i = 0;
 
+        smpl_t curtempo;
+
         while (i < 1000) {
           aubio_tempo(o,in,out);
+          curtempo = aubio_tempo_get_bpm(o);
+          if (curtempo != 0.) {
+            fprintf(stdout,"%f\n",curtempo);
+          }
           i++;
         };
 
--- a/src/tempo.c
+++ b/src/tempo.c
@@ -123,6 +123,10 @@
   return o;
 }
 
+smpl_t aubio_tempo_get_bpm(aubio_tempo_t *o) {
+  return aubio_beattracking_get_bpm(o->bt);
+}
+
 void del_aubio_tempo (aubio_tempo_t *o)
 {
   del_aubio_onsetdetection(o->od);
--- a/src/tempo.h
+++ b/src/tempo.h
@@ -49,6 +49,15 @@
 /** set tempo detection peak picking threshold  */
 void aubio_tempo_set_threshold(aubio_tempo_t * o, smpl_t threshold);
 
+/** get current tempo
+
+  \param bt beat tracking object
+
+  Returns the currently observed tempo, or 0 if no consistent value is found
+
+*/
+smpl_t aubio_tempo_get_bpm(aubio_tempo_t * bt);
+
 /** delete tempo detection object */
 void del_aubio_tempo(aubio_tempo_t * o);