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

smpl_t vec_quadint ( fvec_t x,
uint_t  pos 
)

finds exact maximum position by quadratic interpolation

Definition at line 311 of file mathutils.c.

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

                                          {
  uint_t span = 2;
  smpl_t step = 1./200.;
  /* hack : init resold to - something (in case x[pos+-span]<0)) */
  smpl_t res, frac, s0, s1, s2, exactpos = (smpl_t)pos, resold = -1000.;
  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)*2. - 1.;
        break;
      }
    }
  }
  return exactpos;
}


Generated by  Doxygen 1.6.0   Back to index