/** \bug ugly, should replace with function pointers or so */
smpl_t aubio_pitchdetection(aubio_pitchdetection_t *p, fvec_t * ibuf) {
smpl_t pitch = 0.;
- uint_t i,j = 0;
+ uint_t i,j = 0, overlap_size = 0;
switch(p->type) {
case aubio_yin:
+ overlap_size = p->buf->length-ibuf->length;
/* do sliding window blocking */
for (i=0;i<p->buf->channels;i++){
- for (j=0;j<p->buf->length-ibuf->length;j++){
- p->buf->data[i][j] = p->buf->data[i][j+ibuf->length];
+ for (j=0;j<overlap_size;j++){
+ p->buf->data[i][j] =
+ p->buf->data[i][j+ibuf->length];
}
}
for (i=0;i<ibuf->channels;i++){
for (j=0;j<ibuf->length;j++){
- p->buf->data[i][j] = ibuf->data[i][j];
+ p->buf->data[i][j+overlap_size] =
+ ibuf->data[i][j];
}
}
pitch = aubio_pitchyin_getpitchfast(p->buf,p->yin, 0.5);
/* all the above in one */
uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){
uint_t c=0,j,tau = 0;
- smpl_t tmp = 0, tmp2;
+ smpl_t tmp = 0;
for (tau=0;tau<yin->length;tau++)
{
yin->data[c][tau] = 0.;
yin->data[c][tau] += SQR(tmp);
}
}
- tmp2 = 0.;
yin->data[c][0] = 1.;
+ tmp = 0.;
for (tau=1;tau<yin->length;tau++)
{
tmp += yin->data[c][tau];