Changeset 5284e0d


Ignore:
Timestamp:
Mar 11, 2013, 1:15:47 AM (11 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:
426e6f7
Parents:
8c4560e
Message:

src/pitch: start adding confidence

Location:
src/pitch
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitch.c

    r8c4560e r5284e0d  
    6262  (smpl_t value, uint_t srate, uint_t bufsize);
    6363
     64typedef smpl_t (*aubio_conf_cb_t) (void * p);
     65
    6466void aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf);
    6567
    66 void aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
    67 void aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
    68 void aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
    69 void aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
    70 void aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
     68static void aubio_pitch_do_mcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
     69static void aubio_pitch_do_yin (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
     70static void aubio_pitch_do_schmitt (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
     71static void aubio_pitch_do_fcomb (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
     72static void aubio_pitch_do_yinfft (aubio_pitch_t * p, fvec_t * ibuf, fvec_t * obuf);
    7173
    7274/** generic pitch detection structure */
     
    8284  aubio_pitchyinfft_t *yinfft;    /**< yinfft object */
    8385  aubio_pitchyin_t *yin;    /**< yinfft object */
     86  void *pitch;
    8487  aubio_filter_t *filter;         /**< filter */
    8588  aubio_pvoc_t *pv;               /**< phase vocoder for mcomb */
     
    8891  aubio_pitch_func_t callback; /**< pointer to current pitch detection method */
    8992  aubio_pitch_conv_t freqconv; /**< pointer to current pitch conversion method */
     93  aubio_conf_cb_t confidence_callback; /**< pointer to the current confidence callback */
    9094};
    9195
     
    140144  aubio_pitch_set_unit (p, "default");
    141145  p->bufsize = bufsize;
     146  p->confidence_callback = NULL;
    142147  switch (p->type) {
    143148    case aubio_pitcht_yin:
     
    145150      p->yin = new_aubio_pitchyin (bufsize);
    146151      p->callback = aubio_pitch_do_yin;
     152      p->confidence_callback = (aubio_conf_cb_t)aubio_pitchyin_get_confidence;
     153      p->pitch = (void*)p->yin;
    147154      aubio_pitchyin_set_tolerance (p->yin, 0.15);
    148155      break;
     
    168175      p->yinfft = new_aubio_pitchyinfft (bufsize);
    169176      p->callback = aubio_pitch_do_yinfft;
     177      p->confidence_callback = (aubio_conf_cb_t)aubio_pitchyinfft_get_confidence;
     178      p->pitch = (void*)p->yin;
    170179      aubio_pitchyinfft_set_tolerance (p->yinfft, 0.85);
    171180      break;
     
    345354  out->data[0] = pitch;
    346355}
     356
     357/* confidence callbacks */
     358smpl_t
     359aubio_pitch_get_confidence (aubio_pitch_t * p)
     360{
     361  if (p->confidence_callback) {
     362    return p->confidence_callback ((void*)(p->pitch));
     363  }
     364  return 0.;
     365}
  • src/pitch/pitchyin.c

    r8c4560e r5284e0d  
    3737  fvec_t *yin;
    3838  smpl_t tol;
     39  smpl_t confidence;
    3940};
    4041
     
    159160}
    160161
     162smpl_t
     163aubio_pitchyin_get_confidence (aubio_pitchyin_t * o) {
     164  o->confidence = 1. - fvec_min (o->yin);
     165  return o->confidence;
     166}
     167
    161168uint_t
    162169aubio_pitchyin_set_tolerance (aubio_pitchyin_t * o, smpl_t tol)
  • src/pitch/pitchyin.h

    r8c4560e r5284e0d  
    8585smpl_t aubio_pitchyin_get_tolerance (aubio_pitchyin_t * o);
    8686
     87/** get current confidence of YIN algorithm
     88
     89  \param o YIN pitch detection object
     90  \return confidence parameter
     91
     92*/
     93smpl_t aubio_pitchyin_get_confidence (aubio_pitchyin_t * o);
     94
    8795#ifdef __cplusplus
    8896}
  • src/pitch/pitchyinfft.c

    r8c4560e r5284e0d  
    3838  fvec_t *yinfft;     /**< Yin function */
    3939  smpl_t tol;         /**< Yin tolerance */
     40  smpl_t confidence;  /**< confidence */
    4041};
    4142
     
    166167}
    167168
     169smpl_t
     170aubio_pitchyinfft_get_confidence (aubio_pitchyinfft_t * o) {
     171  o->confidence = 1. - fvec_min (o->yinfft);
     172  return o->confidence;
     173}
     174
    168175uint_t
    169176aubio_pitchyinfft_set_tolerance (aubio_pitchyinfft_t * p, smpl_t tol)
  • src/pitch/pitchyinfft.h

    r8c4560e r5284e0d  
    8484uint_t aubio_pitchyinfft_set_tolerance (aubio_pitchyinfft_t * o, smpl_t tol);
    8585
     86/** get current confidence of YIN algorithm
     87
     88  \param o YIN pitch detection object
     89  \return confidence parameter
     90
     91*/
     92smpl_t aubio_pitchyinfft_get_confidence (aubio_pitchyinfft_t * o);
     93
    8694#ifdef __cplusplus
    8795}
Note: See TracChangeset for help on using the changeset viewer.