break;
case aubio_pitcht_yinfft:
p->buf = new_fvec (bufsize);
- p->p_object = new_aubio_pitchyinfft (bufsize);
+ p->p_object = new_aubio_pitchyinfft (samplerate, bufsize);
p->detect_cb = aubio_pitch_do_yinfft;
p->conf_cb = (aubio_pitch_get_conf_t)aubio_pitchyinfft_get_confidence;
aubio_pitchyinfft_set_tolerance (p->p_object, 0.85);
fvec_t *yinfft; /**< Yin function */
smpl_t tol; /**< Yin tolerance */
smpl_t confidence; /**< confidence */
+ uint_t short_period; /** shortest period under which to check for octave error */
};
static const smpl_t freqs[] = { 0., 20., 25., 31.5, 40., 50., 63., 80., 100.,
};
aubio_pitchyinfft_t *
-new_aubio_pitchyinfft (uint_t bufsize)
+new_aubio_pitchyinfft (uint_t samplerate, uint_t bufsize)
{
aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t);
p->winput = new_fvec (bufsize);
uint_t i = 0, j = 1;
smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0;
for (i = 0; i < p->weight->length; i++) {
- freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) 44100.;
+ freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) samplerate;
while (freq > freqs[j]) {
j += 1;
}
p->weight->data[i] = DB2LIN (p->weight->data[i]);
//p->weight->data[i] = SQRT(DB2LIN(p->weight->data[i]));
}
+ // check for octave errors above 1300 Hz
+ p->short_period = (uint_t)ROUND(samplerate / 1300.);
return p;
}
// 3 point quadratic interpolation
//return fvec_quadratic_peak_pos (yin,tau,1);
/* additional check for (unlikely) octave doubling in higher frequencies */
- if (tau > 35) {
+ if (tau > p->short_period) {
output->data[0] = fvec_quadratic_peak_pos (yin, tau);
} else {
/* should compare the minimum value of each interpolated peaks */
\param buf_size size of the input buffer to analyse
*/
-aubio_pitchyinfft_t *new_aubio_pitchyinfft (uint_t buf_size);
+aubio_pitchyinfft_t *new_aubio_pitchyinfft (uint_t samplerate, uint_t buf_size);
/** deletion of the pitch detection object
\param o pitch detection object as returned by new_aubio_pitchyinfft()
fvec_t * in = new_fvec (win_s); // input buffer
fvec_t * out = new_fvec (1); // output candidates
// create pitch object
- aubio_pitchyinfft_t *p = new_aubio_pitchyinfft(win_s);
+ aubio_pitchyinfft_t *p = new_aubio_pitchyinfft(44100, win_s);
aubio_pitchyinfft_set_tolerance (p, 0.2);
while ( n-- ) {