From: Paul Brossier Date: Fri, 16 Oct 2009 19:55:02 +0000 (+0200) Subject: src/tempo: use samplerate X-Git-Tag: bzr2git~115 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d25bd12025e5ae9589fd68c9d020b0947facbe24;p=aubio.git src/tempo: use samplerate --- diff --git a/plugins/puredata/aubiotempo~.c b/plugins/puredata/aubiotempo~.c index 32cd4012..dea221fa 100644 --- a/plugins/puredata/aubiotempo~.c +++ b/plugins/puredata/aubiotempo~.c @@ -82,7 +82,8 @@ static void *aubiotempo_tilde_new (t_floatarg f) x->bufsize = 1024; x->hopsize = x->bufsize / 2; - x->t = new_aubio_tempo ("complex", x->bufsize, x->hopsize, 1); + x->t = new_aubio_tempo ("complex", x->bufsize, x->hopsize, 1, + (uint_t) sys_getsr ()); aubio_tempo_set_silence(x->t,x->silence); aubio_tempo_set_threshold(x->t,x->threshold); x->output = (fvec_t *)new_fvec(2,1); diff --git a/src/tempo/tempo.c b/src/tempo/tempo.c index a106950b..af091908 100644 --- a/src/tempo/tempo.c +++ b/src/tempo/tempo.c @@ -42,6 +42,7 @@ struct _aubio_tempo_t { sint_t blockpos; /** current position in dfframe */ uint_t winlen; /** dfframe bufsize */ uint_t step; /** dfframe hopsize */ + uint_t samplerate; /** sampling rate of the signal */ }; /* execute tempo detection function on iput buffer */ @@ -99,14 +100,15 @@ uint_t aubio_tempo_set_threshold(aubio_tempo_t * o, smpl_t threshold) { /* Allocate memory for an tempo detection */ aubio_tempo_t * new_aubio_tempo (char_t * onset_mode, - uint_t buf_size, uint_t hop_size, uint_t channels) + uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate) { aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t); + o->samplerate = samplerate; o->winlen = SQR(512)/hop_size; o->step = o->winlen/4; o->blockpos = 0; o->threshold = 0.3; - o->silence = -90; + o->silence = -90.; o->blockpos = 0; o->dfframe = new_fvec(o->winlen,channels); o->fftgrain = new_cvec(buf_size, channels); diff --git a/src/tempo/tempo.h b/src/tempo/tempo.h index 39dcb350..f75d1488 100644 --- a/src/tempo/tempo.h +++ b/src/tempo/tempo.h @@ -38,7 +38,7 @@ typedef struct _aubio_tempo_t aubio_tempo_t; /** create tempo detection object */ aubio_tempo_t * new_aubio_tempo (char_t * mode, - uint_t buf_size, uint_t hop_size, uint_t channels); + uint_t buf_size, uint_t hop_size, uint_t channels, uint_t samplerate); /** execute tempo detection */ void aubio_tempo_do (aubio_tempo_t *o, fvec_t * input, fvec_t * tempo);