Changeset b050e8e
- Timestamp:
- Nov 7, 2007, 5:15:45 PM (17 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:
- 18a82b3, 70585a5
- Parents:
- c8cbf3c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitchmcomb.c
rc8cbf3c rb050e8e 97 97 for (j=0; j< newmag->length; j++) 98 98 newmag->data[i][j]=fftgrain->norm[i][j]; 99 /* detect only if local energy > 10. */ 99 /* detect only if local energy > 10. */ 100 100 //if (vec_local_energy(newmag)>10.) { 101 101 //hfc = vec_local_hfc(newmag); //not used … … 106 106 j = (uint_t)FLOOR(p->candidates[p->goodcandidate]->ebin+.5); 107 107 instfreq = aubio_unwrap2pi(fftgrain->phas[0][j] 108 108 - p->theta->data[0][j] - j*p->phasediff); 109 109 instfreq *= p->phasefreq; 110 110 /* store phase for next run */ … … 119 119 } 120 120 121 uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain, 121 uint_t aubio_pitch_cands(aubio_pitchmcomb_t * p, cvec_t * fftgrain, 122 122 smpl_t * cands) { 123 123 uint_t i=0,j; 124 124 uint_t k; 125 125 fvec_t * newmag = (fvec_t *)p->newmag; 126 aubio_spectralcandidate_t ** scands = 126 aubio_spectralcandidate_t ** scands = 127 127 (aubio_spectralcandidate_t **)(p->candidates); 128 128 //smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta; … … 130 130 for (j=0; j< newmag->length; j++) 131 131 newmag->data[i][j]=fftgrain->norm[i][j]; 132 /* detect only if local energy > 10. */ 133 if (vec_local_energy(newmag)>10.) 132 /* detect only if local energy > 10. */ 133 if (vec_local_energy(newmag)>10.) { 134 134 /* hfc = vec_local_hfc(newmag); do not use */ 135 135 aubio_pitchmcomb_spectral_pp(p, newmag); 136 136 aubio_pitchmcomb_combdet(p,newmag); 137 137 aubio_pitchmcomb_sort_cand_freq(scands,p->ncand); 138 /* store ncand comb energies in cands[1:ncand] */ 139 for (k = 0; k<p->ncand; k++) 138 /* store ncand comb energies in cands[1:ncand] */ 139 for (k = 0; k<p->ncand; k++) 140 140 cands[k] = p->candidates[k]->ene; 141 /* store ncand[end] freq in cands[end] */ 141 /* store ncand[end] freq in cands[end] */ 142 142 cands[p->ncand] = p->candidates[p->ncand-1]->ebin; 143 143 return 1; … … 156 156 /* copy newmag to mag (scracth) */ 157 157 for (j=0;j<length;j++) { 158 mag->data[i][j] = newmag->data[i][j]; 158 mag->data[i][j] = newmag->data[i][j]; 159 159 } 160 160 vec_dc_removal(mag); /* dc removal */ … … 169 169 /* return bin and ebin */ 170 170 count = aubio_pitchmcomb_quadpick(peaks,mag); 171 for (j=0;j<count;j++) 171 for (j=0;j<count;j++) 172 172 peaks[j].mag = newmag->data[i][peaks[j].bin]; 173 173 /* reset non peaks */ … … 181 181 void aubio_pitchmcomb_combdet(aubio_pitchmcomb_t * p, fvec_t * newmag) { 182 182 aubio_spectralpeak_t * peaks = (aubio_spectralpeak_t *)p->peaks; 183 aubio_spectralcandidate_t ** candidate = 183 aubio_spectralcandidate_t ** candidate = 184 184 (aubio_spectralcandidate_t **)p->candidates; 185 185 … … 224 224 for (k=0;k<curlen;k++) { 225 225 xx = 100000.; 226 /** get the candidate->ecomb the closer to peaks.ebin 226 /** get the candidate->ecomb the closer to peaks.ebin 227 227 * (to cope with the inharmonicity)*/ 228 for (d=0;d<count;d++) { 228 for (d=0;d<count;d++) { 229 229 delta2 = ABS(candidate[l]->ecomb[k]-peaks[d].ebin); 230 230 if (delta2 <= xx) { … … 233 233 } 234 234 } 235 /* for a Q factor of 17, maintaining "constant Q filtering", 235 /* for a Q factor of 17, maintaining "constant Q filtering", 236 236 * and sum energy and length over non null combs */ 237 237 if ( 17. * xx < candidate[l]->ecomb[k] ) { … … 261 261 * exact peak positions are retrieved by quadratic interpolation 262 262 * 263 * \bug peak-picking too picky, sometimes counts too many peaks ? 263 * \bug peak-picking too picky, sometimes counts too many peaks ? 264 264 */ 265 265 uint_t aubio_pitchmcomb_quadpick(aubio_spectralpeak_t * spectral_peaks, fvec_t * X){ 266 266 uint_t i, j, ispeak, count = 0; 267 267 for (i=0;i<X->channels;i++) 268 for (j=1;j<X->length-1;j++) 268 for (j=1;j<X->length-1;j++) { 269 269 ispeak = vec_peakpick(X,j); 270 270 if (ispeak) { … … 290 290 291 291 void aubio_pitchmcomb_sort_peak(aubio_spectralpeak_t * peaks, uint_t nbins) { 292 qsort(peaks, nbins, sizeof(aubio_spectralpeak_t), 292 qsort(peaks, nbins, sizeof(aubio_spectralpeak_t), 293 293 aubio_pitchmcomb_sort_peak_comp); 294 294 }
Note: See TracChangeset
for help on using the changeset viewer.