Changeset 9771488


Ignore:
Timestamp:
Mar 21, 2006, 7:05:23 PM (14 years ago)
Author:
Paul Brossier <piem@altern.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
d94f98b
Parents:
1d4fc4a
Message:

add interpolation to yin
add interpolation to yin

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r1d4fc4a r9771488  
    331331}
    332332
     333smpl_t vec_quadint_min(fvec_t * x,uint_t pos, uint_t span) {
     334  smpl_t step = 1./200.;
     335  /* init resold to - something (in case x[pos+-span]<0)) */
     336  smpl_t res, frac, s0, s1, s2, exactpos = (smpl_t)pos, resold = 100000.;
     337  if ((pos > span) && (pos < x->length-span)) {
     338    s0 = x->data[0][pos-span];
     339    s1 = x->data[0][pos]     ;
     340    s2 = x->data[0][pos+span];
     341    /* increase frac */
     342    for (frac = 0.; frac < 2.; frac = frac + step) {
     343      res = aubio_quadfrac(s0, s1, s2, frac);
     344      if (res < resold) {
     345        resold = res;
     346      } else {                         
     347        exactpos += (frac-step)*span - span/2.;
     348        break;
     349      }
     350    }
     351  }
     352  return exactpos;
     353}
     354
    333355smpl_t aubio_quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf) {
    334356  smpl_t tmp = s0 + (pf/2.) * (pf * ( s0 - 2.*s1 + s2 ) - 3.*s0 + 4.*s1 - s2);
  • src/mathutils.h

    r1d4fc4a r9771488  
    212212smpl_t vec_median(fvec_t * input);
    213213
    214 /** finds exact peak position by quadratic interpolation*/
     214/** finds exact maximum position by quadratic interpolation*/
    215215smpl_t vec_quadint(fvec_t * x,uint_t pos);
     216
     217/** finds exact minimum position by quadratic interpolation*/
     218smpl_t vec_quadint_min(fvec_t * x,uint_t pos, uint_t span);
    216219
    217220/** Quadratic interpolation using Lagrange polynomial.
  • src/pitchyin.c

    r1d4fc4a r9771488  
    8989
    9090/* all the above in one */
    91 uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){
     91smpl_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){
    9292        uint_t c=0,j,tau = 0;
     93        sint_t period;
    9394        smpl_t tmp = 0., tmp2 = 0.;
    9495        yin->data[c][0] = 1.;
     
    103104                tmp2 += yin->data[c][tau];
    104105                yin->data[c][tau] *= tau/tmp2;
    105                 if((yin->data[c][tau] < tol) &&
    106                                 (yin->data[c][tau-1] < yin->data[c][tau])) {
    107                         return tau-1;
     106                period = tau-3;
     107                if(tau > 4 && (yin->data[c][period] < tol) &&
     108                                (yin->data[c][period] < yin->data[c][period+1])) {
     109                        return vec_quadint_min(yin,period,1)-1;
    108110                }
    109111        }
  • src/pitchyin.h

    r1d4fc4a r9771488  
    3939uint_t aubio_pitchyin_getpitch(fvec_t *yinbuf);
    4040
    41 uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t *yinbuf, smpl_t tol);
     41smpl_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.