From cb0415db6f21cc0df0293b63e15f6a17b71457ef Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 6 Sep 2007 18:04:08 +0200 Subject: [PATCH] tempo.{c,h}: add aubio_tempo_get_bpm, which for now just calls aubio_beattracking_get_bpm, also update test-tempo.c --- examples/tests/test-tempo.c | 6 ++++++ src/tempo.c | 4 ++++ src/tempo.h | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/examples/tests/test-tempo.c b/examples/tests/test-tempo.c index c7a9bd0d..84e1e32d 100644 --- a/examples/tests/test-tempo.c +++ b/examples/tests/test-tempo.c @@ -9,8 +9,14 @@ int main(){ 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++; }; diff --git a/src/tempo.c b/src/tempo.c index e077898b..328a7e7e 100644 --- a/src/tempo.c +++ b/src/tempo.c @@ -123,6 +123,10 @@ aubio_tempo_t * new_aubio_tempo (aubio_onsetdetection_type type_onset, 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); diff --git a/src/tempo.h b/src/tempo.h index c2c835df..f3faf6e5 100644 --- a/src/tempo.h +++ b/src/tempo.h @@ -49,6 +49,15 @@ void aubio_tempo_set_silence(aubio_tempo_t * o, smpl_t silence); /** 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); -- 2.26.2