smpl_t alpha; /**< normalisation exponent [9] */
smpl_t cutoff; /**< low-pass filter cutoff [0.34, 1] */
smpl_t tol; /**< tolerance [0.05] */
- smpl_t tau; /**< frequency precision [44100/4096] */
+ // smpl_t tau; /**< frequency precision [44100/4096] */
uint_t win_post; /**< median filter window length */
uint_t win_pre; /**< median filter window */
uint_t ncand; /**< maximum number of candidates (combs) */
};
-smpl_t aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain) {
- uint_t i=0,j;
+void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output) {
+ uint_t i,j;
smpl_t instfreq;
fvec_t * newmag = (fvec_t *)p->newmag;
//smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta;
/* copy incoming grain to newmag */
+ for (i=0; i< fftgrain->channels; i++) {
for (j=0; j< newmag->length; j++)
- newmag->data[i][j]=fftgrain->norm[i][j];
+ newmag->data[0][j]=fftgrain->norm[i][j];
/* detect only if local energy > 10. */
//if (fvec_local_energy(newmag)>10.) {
//hfc = fvec_local_hfc(newmag); //not used
//aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand);
//return p->candidates[p->goodcandidate]->ebin;
j = (uint_t)FLOOR(p->candidates[p->goodcandidate]->ebin+.5);
- instfreq = aubio_unwrap2pi(fftgrain->phas[0][j]
- - p->theta->data[0][j] - j*p->phasediff);
+ instfreq = aubio_unwrap2pi(fftgrain->phas[i][j]
+ - p->theta->data[i][j] - j*p->phasediff);
instfreq *= p->phasefreq;
/* store phase for next run */
for (j=0; j< p->theta->length; j++) {
p->theta->data[i][j]=fftgrain->phas[i][j];
}
//return p->candidates[p->goodcandidate]->ebin;
- return FLOOR(p->candidates[p->goodcandidate]->ebin+.5) + instfreq;
+ output->data[i][0] = FLOOR(p->candidates[p->goodcandidate]->ebin+.5) + instfreq;
/*} else {
return -1.;
}*/
+ }
}
uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain,
}
}
-aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate) {
+aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels) {
aubio_pitchmcomb_t * p = AUBIO_NEW(aubio_pitchmcomb_t);
/* bug: should check if size / 8 > post+pre+1 */
uint_t i, j;
p->threshold = 0.01;
p->win_post = 8;
p->win_pre = 7;
- p->tau = samplerate/bufsize;
+ // p->tau = samplerate/bufsize;
p->alpha = 9.;
p->goodcandidate = 0;
p->phasefreq = bufsize/hopsize/TWO_PI;
//p->pickerfn = quadpick;
//p->biquad = new_biquad(0.1600,0.3200,0.1600, -0.5949, 0.2348);
/* allocate temp memory */
- p->newmag = new_fvec(spec_size,channels);
+ p->newmag = new_fvec(spec_size,1);
/* array for median */
- p->scratch = new_fvec(spec_size,channels);
+ p->scratch = new_fvec(spec_size,1);
/* array for phase */
p->theta = new_fvec(spec_size,channels);
/* array for adaptative threshold */
- p->scratch2 = new_fvec(p->win_post+p->win_pre+1,channels);
+ p->scratch2 = new_fvec(p->win_post+p->win_pre+1,1);
/* array of spectral peaks */
p->peaks = AUBIO_ARRAY(aubio_spectralpeak_t,spec_size);
for (i = 0; i < spec_size; i++) {
\param fftgrain input signal spectrum as computed by aubio_pvoc_do
*/
-smpl_t aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain);
+void aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output);
/** creation of the pitch detection object
\param bufsize size of the input buffer to analyse
\param samplerate sampling rate of the signal
*/
-aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate);
+aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels);
/** deletion of the pitch detection object
\param p pitch detection object as returned by new_aubio_pitchfcomb
/* allocate some memory */
uint_t win_s = 1024; /* window size */
uint_t hop_s = win_s/4; /* hop size */
- uint_t samplerate = 44100;
uint_t channels = 1; /* number of channel */
cvec_t * in = new_cvec (win_s, channels); /* input buffer */
- aubio_pitchmcomb_t * o = new_aubio_pitchmcomb(
- win_s, hop_s, channels, samplerate );
+ fvec_t * out = new_fvec (1, channels); /* input buffer */
+
+ aubio_pitchmcomb_t * o = new_aubio_pitchmcomb(win_s, hop_s, channels);
uint_t i = 0;
while (i < 1000) {
- aubio_pitchmcomb_do (o,in);
+ aubio_pitchmcomb_do (o,in, out);
i++;
};
del_aubio_pitchmcomb(o);
del_cvec(in);
+ del_fvec(out);
aubio_cleanup();
return 0;