Changeset 9c9202f


Ignore:
Timestamp:
Apr 10, 2013, 1:47:05 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:
e987c05
Parents:
483b883
Message:

src/pitch/pitchyinfft.c: adapt filter and shortest period to samplerate

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitch.c

    r483b883 r9c9202f  
    159159    case aubio_pitcht_yinfft:
    160160      p->buf = new_fvec (bufsize);
    161       p->p_object = new_aubio_pitchyinfft (bufsize);
     161      p->p_object = new_aubio_pitchyinfft (samplerate, bufsize);
    162162      p->detect_cb = aubio_pitch_do_yinfft;
    163163      p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyinfft_get_confidence;
  • src/pitch/pitchyinfft.c

    r483b883 r9c9202f  
    3838  smpl_t tol;         /**< Yin tolerance */
    3939  smpl_t confidence;  /**< confidence */
     40  uint_t short_period; /** shortest period under which to check for octave error */
    4041};
    4142
     
    5354
    5455aubio_pitchyinfft_t *
    55 new_aubio_pitchyinfft (uint_t bufsize)
     56new_aubio_pitchyinfft (uint_t samplerate, uint_t bufsize)
    5657{
    5758  aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t);
     
    6768  smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0;
    6869  for (i = 0; i < p->weight->length; i++) {
    69     freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) 44100.;
     70    freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) samplerate;
    7071    while (freq > freqs[j]) {
    7172      j += 1;
     
    9091    //p->weight->data[i] = SQRT(DB2LIN(p->weight->data[i]));
    9192  }
     93  // check for octave errors above 1300 Hz
     94  p->short_period = (uint_t)ROUND(samplerate / 1300.);
    9295  return p;
    9396}
     
    143146    //return fvec_quadratic_peak_pos (yin,tau,1);
    144147    /* additional check for (unlikely) octave doubling in higher frequencies */
    145     if (tau > 35) {
     148    if (tau > p->short_period) {
    146149      output->data[0] = fvec_quadratic_peak_pos (yin, tau);
    147150    } else {
  • src/pitch/pitchyinfft.h

    r483b883 r9c9202f  
    5959 
    6060*/
    61 aubio_pitchyinfft_t *new_aubio_pitchyinfft (uint_t buf_size);
     61aubio_pitchyinfft_t *new_aubio_pitchyinfft (uint_t samplerate, uint_t buf_size);
    6262/** deletion of the pitch detection object
    6363 
  • tests/src/pitch/test-pitchyinfft.c

    r483b883 r9c9202f  
    1414  fvec_t * out = new_fvec (1); // output candidates
    1515  // create pitch object
    16   aubio_pitchyinfft_t *p  = new_aubio_pitchyinfft(win_s);
     16  aubio_pitchyinfft_t *p  = new_aubio_pitchyinfft(44100, win_s);
    1717  aubio_pitchyinfft_set_tolerance (p, 0.2);
    1818
Note: See TracChangeset for help on using the changeset viewer.