Changeset acd97d1


Ignore:
Timestamp:
Oct 15, 2013, 10:57:38 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
735a739
Parents:
69c39ca
Message:

src/mathutils.{c,h}: remove fvec_quadint, use fvec_quadratic_peak_pos

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    r69c39ca racd97d1  
    368368}
    369369
    370 smpl_t fvec_quadint (fvec_t * x, uint_t pos) {
    371   smpl_t s0, s1, s2;
    372   uint_t x0 = (pos < 1) ? pos : pos - 1;
    373   uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
    374   if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2;
    375   if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0;
    376   s0 = x->data[x0];
    377   s1 = x->data[pos];
    378   s2 = x->data[x2];
    379   return pos + 0.5 * (s2 - s0 ) / (s2 - 2.* s1 + s0);
    380 }
    381 
    382370smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) {
    383371  smpl_t s0, s1, s2;
     372  if (pos == 0 || pos == x->length - 1) return pos;
    384373  uint_t x0 = (pos < 1) ? pos : pos - 1;
    385374  uint_t x2 = (pos + 1 < x->length) ? pos + 1 : pos;
  • src/mathutils.h

    r69c39ca racd97d1  
    232232smpl_t fvec_median (fvec_t * v);
    233233
    234 /** finds exact peak index by quadratic interpolation*/
    235 smpl_t fvec_quadint (fvec_t * x, uint_t pos);
    236 
    237234/** finds exact peak index by quadratic interpolation
    238235
  • src/onset/peakpicker.c

    r69c39ca racd97d1  
    125125  out->data[0] = (p->pickerfn) (onset_peek, 1);
    126126  if (out->data[0]) {
    127     out->data[0] = fvec_quadint (onset_peek, 1);
     127    out->data[0] = fvec_quadratic_peak_pos (onset_peek, 1);
    128128  }
    129129}
  • src/tempo/beattracking.c

    r69c39ca racd97d1  
    171171  /* find non-zero Rayleigh period */
    172172  maxindex = fvec_max_elem (bt->acfout);
    173   bt->rp = maxindex ? fvec_quadint (bt->acfout, maxindex) : 1;
     173  bt->rp = maxindex ? fvec_quadratic_peak_pos (bt->acfout, maxindex) : 1;
    174174  //rp = (maxindex==127) ? 43 : maxindex; //rayparam
    175175  bt->rp = (maxindex == bt->acfout->length - 1) ? bt->rayparam : maxindex;      //rayparam
     
    204204    phase = step - bt->lastbeat;
    205205  } else {
    206     phase = fvec_quadint (bt->phout, maxindex);
     206    phase = fvec_quadratic_peak_pos (bt->phout, maxindex);
    207207  }
    208208  /* take back one frame delay */
     
    306306    }
    307307    fvec_weight (acfout, bt->gwv);
    308     gp = fvec_quadint (acfout, fvec_max_elem (acfout));
     308    gp = fvec_quadratic_peak_pos (acfout, fvec_max_elem (acfout));
    309309    /*
    310310       while(gp<32) gp =gp*2;
     
    409409aubio_beattracking_get_bpm (aubio_beattracking_t * bt)
    410410{
    411   if (bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) {
    412     return 5168. / fvec_quadint (bt->acfout, bt->bp);
     411  if (bt->bp != 0 && bt->timesig != 0 && bt->counter == 0 && bt->flagstep == 0) {
     412    return 5168. / fvec_quadratic_peak_pos (bt->acfout, bt->bp);
    413413  } else {
    414414    return 0.;
Note: See TracChangeset for help on using the changeset viewer.