ref: f8714ee0615e25a50d77668df664535665a46bf7
parent: 0c205827fcc0aced3d69dca93168f23a050a372d
author: Paul Brossier <piem@altern.org>
date: Fri May 27 19:56:41 EDT 2005
fixed yin overlapping and fast version
--- a/src/pitchdetection.c
+++ b/src/pitchdetection.c
@@ -89,18 +89,21 @@
/** \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);
--- a/src/pitchyin.c
+++ b/src/pitchyin.c
@@ -90,7 +90,7 @@
/* 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.;
@@ -103,8 +103,8 @@
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];