aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s) { aubio_pvoc_t * pv = AUBIO_NEW(aubio_pvoc_t); /* if (win_s < 2*hop_s) { AUBIO_WRN("Hop size bigger than half the window size!\n"); } */ if (hop_s < 1) { AUBIO_ERR("Hop size is smaller than 1!\n"); AUBIO_ERR("Resetting hop size to half the window size.\n"); hop_s = win_s / 2; } pv->fft = new_aubio_fft (win_s); /* remember old */ pv->data = new_fvec (win_s); pv->synth = new_fvec (win_s); /* new input output */ pv->dataold = new_fvec (win_s-hop_s); pv->synthold = new_fvec (win_s-hop_s); pv->w = new_aubio_window ("hanningz", win_s); pv->hop_s = hop_s; pv->win_s = win_s; return pv; }
aubio_pitchfcomb_t * new_aubio_pitchfcomb (uint_t bufsize, uint_t hopsize) { aubio_pitchfcomb_t *p = AUBIO_NEW (aubio_pitchfcomb_t); p->fftSize = bufsize; p->stepSize = hopsize; p->winput = new_fvec (bufsize); p->fftOut = new_cvec (bufsize); p->fftLastPhase = new_fvec (bufsize); p->fft = new_aubio_fft (bufsize); p->win = new_aubio_window ("hanning", bufsize); return p; }
aubio_pitchspecacf_t * new_aubio_pitchspecacf (uint_t bufsize) { aubio_pitchspecacf_t *p = AUBIO_NEW (aubio_pitchspecacf_t); p->win = new_aubio_window ("hanningz", bufsize); p->winput = new_fvec (bufsize); p->fft = new_aubio_fft (bufsize); p->fftout = new_fvec (bufsize); p->sqrmag = new_fvec (bufsize); p->acf = new_fvec (bufsize / 2 + 1); p->tol = 1.; p->confidence = 0.; return p; }
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; }
aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s) { aubio_pvoc_t * pv = AUBIO_NEW(aubio_pvoc_t); /* if (win_s < 2*hop_s) { AUBIO_WRN("Hop size bigger than half the window size!\n"); } */ if (hop_s < 1) { AUBIO_ERR("got hop_size %d, but can not be < 1\n", hop_s); goto beach; } else if (win_s < 1) { AUBIO_ERR("got buffer_size %d, but can not be < 2\n", win_s); goto beach; } else if (win_s < hop_s + 1) { AUBIO_ERR("hop size (%d) is larger than or equal to win size (%d)\n", win_s, hop_s); goto beach; } pv->fft = new_aubio_fft (win_s); /* remember old */ pv->data = new_fvec (win_s); pv->synth = new_fvec (win_s); /* new input output */ pv->dataold = new_fvec (win_s-hop_s); pv->synthold = new_fvec (win_s-hop_s); pv->w = new_aubio_window ("hanningz", win_s); pv->hop_s = hop_s; pv->win_s = win_s; return pv; beach: AUBIO_FREE (pv); return NULL; }