shithub: aubio

Download patch

ref: 5f5edc116c0b9efc08b2c47be149e76cf9a7b35a
parent: 43b7c6dc6d851acdb2af688418c146d8b635b415
author: Paul Brossier <piem@piem.org>
date: Mon Nov 2 18:02:58 EST 2015

src/tempo/beattracking.{c,h}: add _get_period and _get_period_s

--- a/src/tempo/beattracking.c
+++ b/src/tempo/beattracking.c
@@ -409,10 +409,22 @@
 }
 
 smpl_t
+aubio_beattracking_get_period (aubio_beattracking_t * bt)
+{
+  return bt->hop_size * bt->bp;
+}
+
+smpl_t
+aubio_beattracking_get_period_s (aubio_beattracking_t * bt)
+{
+  return aubio_beattracking_get_period(bt) / (smpl_t) bt->samplerate;
+}
+
+smpl_t
 aubio_beattracking_get_bpm (aubio_beattracking_t * bt)
 {
   if (bt->bp != 0) {
-    return 60. * bt->samplerate/ bt->bp / bt->hop_size;
+    return 60. / aubio_beattracking_get_period_s(bt);
   } else {
     return 0.;
   }
--- a/src/tempo/beattracking.h
+++ b/src/tempo/beattracking.h
@@ -67,6 +67,26 @@
 void aubio_beattracking_do (aubio_beattracking_t * bt, fvec_t * dfframes,
     fvec_t * out);
 
+/** get current beat period in samples
+
+  \param bt beat tracking object
+
+  Returns the currently observed period, in samples, or 0 if no consistent
+  value is found.
+
+*/
+smpl_t aubio_beattracking_get_period (aubio_beattracking_t * bt);
+
+/** get current beat period in seconds
+
+  \param bt beat tracking object
+
+  Returns the currently observed period, in seconds, or 0 if no consistent
+  value is found.
+
+*/
+smpl_t aubio_beattracking_get_period_s (aubio_beattracking_t * bt);
+
 /** get current tempo in bpm
 
   \param bt beat tracking object