inline void adjust_all(Param *params) { double f = params[0].value; if (f < 20) f = 20; if (f > fs/6*OVERSAMPLING) f = fs/6*OVERSAMPLING; double wc = M_PI*f/fs/OVERSAMPLING; double drive = DB2LIN(params[1].value); double feedback = params[2].value*N; filter.setup(wc, drive, feedback); }
aubio_pitchyinfft_t * new_aubio_pitchyinfft (uint_t samplerate, uint_t bufsize) { uint_t i = 0, j = 1; smpl_t freq = 0, a0 = 0, a1 = 0, f0 = 0, f1 = 0; aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t); p->winput = new_fvec (bufsize); p->fft = new_aubio_fft (bufsize); p->fftout = new_fvec (bufsize); p->sqrmag = new_fvec (bufsize); p->yinfft = new_fvec (bufsize / 2 + 1); p->tol = 0.85; p->win = new_aubio_window ("hanningz", bufsize); p->weight = new_fvec (bufsize / 2 + 1); for (i = 0; i < p->weight->length; i++) { freq = (smpl_t) i / (smpl_t) bufsize *(smpl_t) samplerate; while (freq > freqs[j]) { j += 1; } a0 = weight[j - 1]; f0 = freqs[j - 1]; a1 = weight[j]; f1 = freqs[j]; if (f0 == f1) { // just in case p->weight->data[i] = a0; } else if (f0 == 0) { // y = ax+b p->weight->data[i] = (a1 - a0) / f1 * freq + a0; } else { p->weight->data[i] = (a1 - a0) / (f1 - f0) * freq + (a0 - (a1 - a0) / (f1 / f0 - 1.)); } while (freq > freqs[j]) { j += 1; } //AUBIO_DBG("%f\n",p->weight->data[i]); 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; }
aubio_pitchyinfft_t * new_aubio_pitchyinfft (uint_t bufsize) { aubio_pitchyinfft_t *p = AUBIO_NEW (aubio_pitchyinfft_t); p->winput = new_fvec (bufsize); p->fft = new_aubio_fft (bufsize); p->fftout = new_cvec (bufsize); p->sqrmag = new_fvec (bufsize); p->res = new_cvec (bufsize); p->yinfft = new_fvec (bufsize / 2 + 1); p->tol = 0.85; p->win = new_aubio_window ("hanningz", bufsize); p->weight = new_fvec (bufsize / 2 + 1); 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.; while (freq > freqs[j]) { j += 1; } a0 = weight[j - 1]; f0 = freqs[j - 1]; a1 = weight[j]; f1 = freqs[j]; if (f0 == f1) { // just in case p->weight->data[i] = a0; } else if (f0 == 0) { // y = ax+b p->weight->data[i] = (a1 - a0) / f1 * freq + a0; } else { p->weight->data[i] = (a1 - a0) / (f1 - f0) * freq + (a0 - (a1 - a0) / (f1 / f0 - 1.)); } while (freq > freqs[j]) { j += 1; } //AUBIO_DBG("%f\n",p->weight->data[i]); p->weight->data[i] = DB2LIN (p->weight->data[i]); //p->weight->data[i] = SQRT(DB2LIN(p->weight->data[i])); } return p; }