Logo Search packages:      
Sourcecode: aubio version File versions  Download package

smpl_t vec_quadint_min ( fvec_t x,
uint_t  pos,
uint_t  span 
)

finds exact minimum position by quadratic interpolation

Definition at line 334 of file mathutils.c.

References _fvec_t::data, and _fvec_t::length.

                                                           {
  smpl_t step = 1./200.;
  /* init resold to - something (in case x[pos+-span]<0)) */
  smpl_t res, frac, s0, s1, s2, exactpos = (smpl_t)pos, resold = 100000.;
  if ((pos > span) && (pos < x->length-span)) {
    s0 = x->data[0][pos-span];
    s1 = x->data[0][pos]     ;
    s2 = x->data[0][pos+span];
    /* increase frac */
    for (frac = 0.; frac < 2.; frac = frac + step) {
      res = aubio_quadfrac(s0, s1, s2, frac);
      if (res < resold) {
        resold = res;
      } else {                      
        exactpos += (frac-step)*span - span/2.;
        break;
      }
    }
  }
  return exactpos;
}


Generated by  Doxygen 1.6.0   Back to index