From: Paul Brossier Date: Thu, 6 Sep 2007 16:01:41 +0000 (+0200) Subject: beattracking.{h,c}: add function aubio_beattracking_get_bpm to return the observed... X-Git-Tag: bzr2git~520 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=416c0b567ac0c973c4cc1bf272d37046cc1ccdb7;p=aubio.git beattracking.{h,c}: add function aubio_beattracking_get_bpm to return the observed tempo at any moment --- 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