Ignore:
Timestamp:
Oct 1, 2017, 11:44:42 AM (7 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
Children:
16c12a1
Parents:
5b194f0 (diff), 3e48568 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'yin_confidence' of https://github.com/emuell/aubio into emuell-yin_confidence

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/pitch/pitchyinfast.c

    r5b194f0 r2a4ce6d  
    3939  fvec_t *yin;
    4040  smpl_t tol;
    41   smpl_t confidence;
     41  uint_t peak_pos;
    4242  fvec_t *tmpdata;
    4343  fvec_t *sqdiff;
     
    6060  o->fft = new_aubio_fft (bufsize);
    6161  o->tol = 0.15;
     62  o->peak_pos = 0;
    6263  return o;
    6364}
     
    8687  uint_t W = o->yin->length; // B / 2
    8788  fvec_t tmp_slice, kernel_ptr;
    88   smpl_t *yin_data = yin->data;
    8989  uint_t tau;
    9090  sint_t period;
     
    143143    // compute square difference r_t(tau) = sqdiff - 2 * r_t_tau[W-1:-1]
    144144    for (tau = 0; tau < W; tau++) {
    145       yin_data[tau] = o->sqdiff->data[tau] - 2. * rt_of_tau->data[tau+W];
     145      yin->data[tau] = o->sqdiff->data[tau] - 2. * rt_of_tau->data[tau+W];
    146146    }
    147147  }
    148148
    149149  // now build yin and look for first minimum
    150   fvec_set_all(out, 0.);
    151   yin_data[0] = 1.;
     150  fvec_zeros(out);
     151  yin->data[0] = 1.;
    152152  for (tau = 1; tau < length; tau++) {
    153     tmp2 += yin_data[tau];
     153    tmp2 += yin->data[tau];
    154154    if (tmp2 != 0) {
    155155      yin->data[tau] *= tau / tmp2;
     
    158158    }
    159159    period = tau - 3;
    160     if (tau > 4 && (yin_data[period] < tol) &&
    161         (yin_data[period] < yin_data[period + 1])) {
    162       out->data[0] = fvec_quadratic_peak_pos (yin, period);
    163       goto beach;
     160    if (tau > 4 && (yin->data[period] < tol) &&
     161        (yin->data[period] < yin->data[period + 1])) {
     162      o->peak_pos = (uint_t)period;
     163      out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos);
     164      return;
    164165    }
    165166  }
    166   out->data[0] = fvec_quadratic_peak_pos (yin, fvec_min_elem (yin) );
    167 beach:
    168   return;
     167  // use global minimum
     168  o->peak_pos = (uint_t)fvec_min_elem (yin);
     169  out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos);
    169170}
    170171
    171172smpl_t
    172173aubio_pitchyinfast_get_confidence (aubio_pitchyinfast_t * o) {
    173   o->confidence = 1. - fvec_min (o->yin);
    174   return o->confidence;
     174  return 1. - o->yin->data[o->peak_pos];
    175175}
    176176
Note: See TracChangeset for help on using the changeset viewer.