From 416c0b567ac0c973c4cc1bf272d37046cc1ccdb7 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 6 Sep 2007 18:01:41 +0200 Subject: [PATCH] beattracking.{h,c}: add function aubio_beattracking_get_bpm to return the observed tempo at any moment --- src/beattracking.c | 8 ++++++++ src/beattracking.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/beattracking.c b/src/beattracking.c index d902e272..6d30ee07 100644 --- a/src/beattracking.c +++ b/src/beattracking.c @@ -452,3 +452,11 @@ void aubio_beattracking_checkstate(aubio_beattracking_t * bt) { bt->rp2 = rp2; } + +smpl_t aubio_beattracking_get_bpm(aubio_beattracking_t * bt) { + if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) { + return 5168. / (smpl_t)bt->gp; + } else { + return 0.; + } +} diff --git a/src/beattracking.h b/src/beattracking.h index 05309c82..78da1fcd 100644 --- a/src/beattracking.h +++ b/src/beattracking.h @@ -59,6 +59,15 @@ aubio_beattracking_t * new_aubio_beattracking(uint_t winlen, uint_t channels); */ void aubio_beattracking_do(aubio_beattracking_t * bt, fvec_t * dfframes, fvec_t * out); +/** get current tempo in bpm + + \param bt beat tracking object + + Returns the currently observed tempo, in beats per minutes, or 0 if no + consistent value is found. + +*/ +smpl_t aubio_beattracking_get_bpm(aubio_beattracking_t * bt); /** delete beat tracking object \param p beat tracking object -- 2.26.2