Ignore:
Timestamp:
Oct 8, 2009, 8:49:10 PM (15 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
7a6cbbe
Parents:
2ba3440
Message:

src/pitch/pitchyinfft.{c,h}: add get/set for tolerance, clean and update prototypes, make multichannel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitchyinfft.c

    r2ba3440 r22d33e2  
    3434  aubio_fft_t * fft;  /**< fft object to compute square difference function */
    3535  fvec_t * yinfft;    /**< Yin function */
     36  smpl_t tol;         /**< Yin tolerance */
    3637};
    3738
     
    5556  p->res    = new_cvec(bufsize,1);
    5657  p->yinfft = new_fvec(bufsize/2+1,1);
     58  p->tol    = 0.85;
    5759  p->win    = new_aubio_window(bufsize, aubio_win_hanningz);
    5860  p->weight      = new_fvec(bufsize/2+1,1);
     
    8890}
    8991
    90 smpl_t aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, smpl_t tol) {
    91   uint_t tau, l = 0;
     92void aubio_pitchyinfft_do (aubio_pitchyinfft_t * p, fvec_t * input, fvec_t * output) {
     93  uint_t i, tau, l;
    9294  uint_t halfperiod;
    93   smpl_t tmp = 0, sum = 0;
     95  smpl_t tmp, sum;
    9496  cvec_t * res = (cvec_t *)p->res;
    9597  fvec_t * yin = (fvec_t *)p->yinfft;
     98  for (i=0; i < input->channels; i++){
     99  l = 0; tmp = 0.; sum = 0.;
    96100  for (l=0; l < input->length; l++){
    97     p->winput->data[0][l] = p->win->data[0][l] * input->data[0][l];
     101    p->winput->data[0][l] = p->win->data[0][l] * input->data[i][l];
    98102  }
    99103  aubio_fft_do(p->fft,p->winput,p->fftout);
     
    121125  }
    122126  tau = fvec_min_elem(yin);
    123   if (yin->data[0][tau] < tol) {
     127  if (yin->data[0][tau] < p->tol) {
    124128    /* no interpolation */
    125129    //return tau;
     
    128132    /* additional check for (unlikely) octave doubling in higher frequencies */
    129133    if (tau>35) {
    130       return fvec_quadint(yin,tau,1);
     134      output->data[i][0] = fvec_quadint(yin,tau,1);
    131135    } else {
    132136      /* should compare the minimum value of each interpolated peaks */
    133137      halfperiod = FLOOR(tau/2+.5);
    134       if (yin->data[0][halfperiod] < tol)
    135         return fvec_quadint(yin,halfperiod,1);
     138      if (yin->data[0][halfperiod] < p->tol)
     139        output->data[i][0] = fvec_quadint(yin,halfperiod,1);
    136140      else
    137         return fvec_quadint(yin,tau,1);
     141        output->data[i][0] = fvec_quadint(yin,tau,1);
    138142    }
    139   } else
    140     return 0.;
     143  } else {
     144    output->data[i][0] = 0.;
     145  }
     146  }
    141147}
    142148
     
    152158  AUBIO_FREE(p);
    153159}
     160
     161uint_t aubio_pitchyinfft_set_tolerance (aubio_pitchyinfft_t * p, smpl_t tol) {
     162  p->tol = tol;
     163  return 0;
     164}
     165
     166smpl_t aubio_pitchyinfft_get_tolerance (aubio_pitchyinfft_t * p) {
     167  return p->tol;
     168}
Note: See TracChangeset for help on using the changeset viewer.