fixed yin overlapping and fast version
authorPaul Brossier <piem@altern.org>
Fri, 27 May 2005 23:56:41 +0000 (23:56 +0000)
committerPaul Brossier <piem@altern.org>
Fri, 27 May 2005 23:56:41 +0000 (23:56 +0000)
src/pitchdetection.c
src/pitchyin.c

index 71dbf5b9fbd7d65ae37bda9ff1fcd70682072d85..4e5d700955bd9e71a2c1225d59ae85fee1818aaa 100644 (file)
@@ -89,18 +89,21 @@ void del_aubio_pitchdetection(aubio_pitchdetection_t * p) {
 /** \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);
index c69a43471acfc348a3de5fdec1f3f6e1692944d5..1bdf71c288a71cc1774d411f77479f711b5bbc94 100644 (file)
@@ -90,7 +90,7 @@ uint_t aubio_pitchyin_getpitch(fvec_t * yin) {
 /* 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 @@ uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){
                        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];