Changeset cf7c76a


Ignore:
Timestamp:
Apr 11, 2005, 6:31:48 PM (19 years ago)
Author:
Paul Brossier <piem@altern.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
84941cb
Parents:
a0fd4e4
Message:

update pitchyin.[ch] and pitchdetection.c

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/pitchdetection.c

    ra0fd4e4 rcf7c76a  
    104104                                }
    105105                        }
    106                         /* get the autocorr and pitch */
    107                         aubio_pitchyin_diff(p->buf,p->yin);
    108                         aubio_pitchyin_getcum(p->yin);
    109                         pitch = aubio_pitchyin_getpitch(p->yin);
     106                        pitch = aubio_pitchyin_getpitchfast(p->buf,p->yin, 0.5);
    110107                        if (pitch>0) {
    111108                                pitch = p->srate/(pitch+0.);
     
    113110                                pitch = 0.;
    114111                        }
    115                         //fprintf(stderr,"%f\n",pitch);
    116112                        break;
    117113                case mcomb:
  • src/pitchyin.c

    ra0fd4e4 rcf7c76a  
    8383                tau++;
    8484        } while (tau<yin->length);
    85         //AUBIO_DBG("No pitch found");
     85        AUBIO_DBG("No pitch found");
    8686        return 0;
    8787}
     
    8989
    9090/* all the above in one */
    91 uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin){
    92         uint_t c,j,tau = 0;
     91uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){
     92        uint_t c=0,j,tau = 0;
    9393        smpl_t tmp = 0, tmp2;
    94         for (c=0;c<input->channels;c++)
     94        for (tau=0;tau<yin->length;tau++)
    9595        {
    96                 for (tau=0;tau<yin->length;tau++)
     96                yin->data[c][tau] = 0.;
     97        }
     98        for (tau=1;tau<yin->length;tau++)
     99        {
     100                for (j=0;j<yin->length;j++)
    97101                {
    98                         yin->data[c][tau] = 0.;
    99                 }
    100                 for (tau=1;tau<yin->length;tau++)
    101                 {
    102                         for (j=0;j<yin->length;j++)
    103                         {
    104                                 tmp = input->data[c][j] - input->data[c][j+tau];
    105                                 yin->data[c][tau] += SQR(tmp);
    106                         }
    107                 }
    108                 tmp2 = 0.;
    109                 yin->data[c][0] = 1.;
    110                 for (tau=1;tau<yin->length;tau++)
    111                 {
    112                         tmp += yin->data[c][tau];
    113                         yin->data[c][tau] *= tau/tmp;
     102                        tmp = input->data[c][j] - input->data[c][j+tau];
     103                        yin->data[c][tau] += SQR(tmp);
    114104                }
    115105        }
     106        tmp2 = 0.;
     107        yin->data[c][0] = 1.;
     108        for (tau=1;tau<yin->length;tau++)
     109        {
     110                tmp += yin->data[c][tau];
     111                yin->data[c][tau] *= tau/tmp;
     112        }
    116113        /* should merge the following with above */
     114        tau = 1;
    117115        do
    118116        {
    119                 if(yin->data[c][tau] < 0.1) {
     117                if(yin->data[c][tau] < tol) {
    120118                        while (yin->data[c][tau+1] < yin->data[c][tau]) {
    121119                                tau++;
  • src/pitchyin.h

    ra0fd4e4 rcf7c76a  
    3939uint_t aubio_pitchyin_getpitch(fvec_t *yinbuf);
    4040
    41 uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t *yinbuf);
     41uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t *yinbuf, smpl_t tol);
    4242
    4343#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.