Changeset d94f98b
- Timestamp:
- Mar 21, 2006, 11:26:28 PM (19 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- e4f7779
- Parents:
- 9771488
- Location:
- src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitchmcomb.c
r9771488 rd94f98b 64 64 fvec_t * scratch; /**< vec to store modified mag */ 65 65 fvec_t * scratch2; /**< vec to compute moving median */ 66 fvec_t * theta; /**< vec to store phase */ 67 smpl_t phasediff; 68 smpl_t phasefreq; 66 69 /** threshfn: name or handle of fn for computing adaptive threshold [median] */ 67 70 /** aubio_thresholdfn_t thresholdfn; */ … … 88 91 smpl_t aubio_pitchmcomb_detect(aubio_pitchmcomb_t * p, cvec_t * fftgrain) { 89 92 uint_t i=0,j; 93 smpl_t instfreq; 90 94 fvec_t * newmag = (fvec_t *)p->newmag; 91 95 //smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta; … … 99 103 aubio_pitchmcomb_combdet(p,newmag); 100 104 //aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand); 101 // print picked candidate 102 //AUBIO_DBG("%f\n",p->candidates[p->goodcandidate]->ebin); 103 //AUBIO_DBG("%f\n",p->candidates[p->goodcandidate]->ebin); 104 return p->candidates[p->goodcandidate]->ebin; 105 //return p->candidates[p->goodcandidate]->ebin; 106 j = (uint_t)FLOOR(p->candidates[p->goodcandidate]->ebin+.5); 107 instfreq = aubio_unwrap2pi(fftgrain->phas[0][j] 108 - p->theta->data[0][j] - j*p->phasediff); 109 instfreq *= p->phasefreq; 110 /* store phase for next run */ 111 for (j=0; j< p->theta->length; j++) { 112 p->theta->data[i][j]=fftgrain->phas[i][j]; 113 } 114 return FLOOR(p->candidates[p->goodcandidate]->ebin+.5) + instfreq; 105 115 /*} else { 106 116 return -1.; … … 193 203 /* get the biggest peak in the spectrum */ 194 204 root_peak = aubio_pitchmcomb_get_root_peak(peaks,count); 195 if (peaks[root_peak].ebin > aubio_miditofreq(80.)/p->tau) N = 3;196 if (peaks[root_peak].ebin > aubio_miditofreq(85.)/p->tau) N = 2;197 if (peaks[root_peak].ebin > aubio_miditofreq(90.)/p->tau) N = 1;198 205 /* now calculate the energy of each of the 5 combs */ 199 206 for (l=0;l<M;l++) { … … 227 234 candidate[l]->ecomb[k]=peaks[position].ebin; 228 235 candidate[l]->ene += /* ecomb rounded to nearest int */ 229 SQR(newmag->data[0][(uint_t)FLOOR(candidate[l]->ecomb[k]-.5)]);236 POW(newmag->data[0][(uint_t)FLOOR(candidate[l]->ecomb[k]+.5)],0.25); 230 237 candidate[l]->len += 1./curlen; 231 238 } else … … 233 240 } 234 241 /* punishment */ 235 if (candidate[l]->len<0.6) 236 candidate[l]->ene=0.; 237 /* remember best candidate energy */ 238 if (tmpene <= candidate[l]->ene) { 242 /*if (candidate[l]->len<0.6) 243 candidate[l]->ene=0.; */ 244 /* remember best candidate energy (in polyphonic, could check for 245 * tmpene*1.1 < candidate->ene to reduce jumps towards low frequencies) */ 246 if (tmpene < candidate[l]->ene) { 239 247 tmpl = l; 240 248 tmpene = candidate[l]->ene; … … 311 319 } 312 320 313 aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t size, uint_t channels, uint_t samplerate) {321 aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate) { 314 322 aubio_pitchmcomb_t * p = AUBIO_NEW(aubio_pitchmcomb_t); 315 323 /** \bug should check if size / 8 > post+pre+1 */ … … 323 331 p->win_post = 8; 324 332 p->win_pre = 7; 325 p->tau = samplerate/ size;333 p->tau = samplerate/bufsize; 326 334 p->alpha = 9.; 327 335 p->goodcandidate = 0; 328 spec_size = size/p->spec_partition; 336 p->phasefreq = bufsize/hopsize/TWO_PI; 337 p->phasediff = TWO_PI*hopsize/bufsize; 338 spec_size = bufsize/p->spec_partition; 329 339 //p->pickerfn = quadpick; 330 340 //p->biquad = new_biquad(0.1600,0.3200,0.1600, -0.5949, 0.2348); … … 333 343 /* array for median */ 334 344 p->scratch = new_fvec(spec_size,channels); 345 /* array for phase */ 346 p->theta = new_fvec(spec_size,channels); 335 347 /* array for adaptative threshold */ 336 348 p->scratch2 = new_fvec(p->win_post+p->win_pre+1,channels); -
src/pitchmcomb.h
r9771488 rd94f98b 35 35 smpl_t aubio_pitchmcomb_detect(aubio_pitchmcomb_t * p, cvec_t * fftgrain); 36 36 uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands); 37 aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t size, uint_t channels, uint_t samplerate);37 aubio_pitchmcomb_t * new_aubio_pitchmcomb(uint_t bufsize, uint_t hopsize, uint_t channels, uint_t samplerate); 38 38 void del_aubio_pitchmcomb(aubio_pitchmcomb_t *p); 39 39
Note: See TracChangeset
for help on using the changeset viewer.