Changeset 9771488 for src/mathutils.c


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

File:
1 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);
Note: See TracChangeset for help on using the changeset viewer.