Changeset 168337e for src/pitch/pitchmcomb.c
- Timestamp:
- Dec 4, 2009, 1:44:41 AM (14 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:
- 02a01dd
- Parents:
- fc61225
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/pitch/pitchmcomb.c
rfc61225 r168337e 104 104 aubio_pitchmcomb_do (aubio_pitchmcomb_t * p, cvec_t * fftgrain, fvec_t * output) 105 105 { 106 uint_t i,j;106 uint_t j; 107 107 smpl_t instfreq; 108 108 fvec_t *newmag = (fvec_t *) p->newmag; 109 109 //smpl_t hfc; //fe=instfreq(theta1,theta,ops); //theta1=theta; 110 110 /* copy incoming grain to newmag */ 111 for (i = 0; i < fftgrain->channels; i++) { 112 for (j = 0; j < newmag->length; j++) 113 newmag->data[0][j] = fftgrain->norm[i][j]; 114 /* detect only if local energy > 10. */ 115 //if (fvec_local_energy(newmag)>10.) { 116 //hfc = fvec_local_hfc(newmag); //not used 117 aubio_pitchmcomb_spectral_pp (p, newmag); 118 aubio_pitchmcomb_combdet (p, newmag); 119 //aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand); 120 //return p->candidates[p->goodcandidate]->ebin; 121 j = (uint_t) FLOOR (p->candidates[p->goodcandidate]->ebin + .5); 122 instfreq = aubio_unwrap2pi (fftgrain->phas[i][j] 123 - p->theta->data[i][j] - j * p->phasediff); 124 instfreq *= p->phasefreq; 125 /* store phase for next run */ 126 for (j = 0; j < p->theta->length; j++) { 127 p->theta->data[i][j] = fftgrain->phas[i][j]; 128 } 129 //return p->candidates[p->goodcandidate]->ebin; 130 output->data[i][0] = 131 FLOOR (p->candidates[p->goodcandidate]->ebin + .5) + instfreq; 132 /*} else { 133 return -1.; 134 } */ 135 } 111 for (j = 0; j < newmag->length; j++) 112 newmag->data[j] = fftgrain->norm[j]; 113 /* detect only if local energy > 10. */ 114 //if (fvec_local_energy(newmag)>10.) { 115 //hfc = fvec_local_hfc(newmag); //not used 116 aubio_pitchmcomb_spectral_pp (p, newmag); 117 aubio_pitchmcomb_combdet (p, newmag); 118 //aubio_pitchmcomb_sort_cand_freq(p->candidates,p->ncand); 119 //return p->candidates[p->goodcandidate]->ebin; 120 j = (uint_t) FLOOR (p->candidates[p->goodcandidate]->ebin + .5); 121 instfreq = aubio_unwrap2pi (fftgrain->phas[j] 122 - p->theta->data[j] - j * p->phasediff); 123 instfreq *= p->phasefreq; 124 /* store phase for next run */ 125 for (j = 0; j < p->theta->length; j++) { 126 p->theta->data[j] = fftgrain->phas[j]; 127 } 128 //return p->candidates[p->goodcandidate]->ebin; 129 output->data[0] = 130 FLOOR (p->candidates[p->goodcandidate]->ebin + .5) + instfreq; 131 /*} else { 132 return -1.; 133 } */ 136 134 } 137 135 … … 139 137 aubio_pitch_cands (aubio_pitchmcomb_t * p, cvec_t * fftgrain, smpl_t * cands) 140 138 { 141 uint_t i = 0,j;139 uint_t j; 142 140 uint_t k; 143 141 fvec_t *newmag = (fvec_t *) p->newmag; … … 147 145 /* copy incoming grain to newmag */ 148 146 for (j = 0; j < newmag->length; j++) 149 newmag->data[ i][j] = fftgrain->norm[i][j];147 newmag->data[j] = fftgrain->norm[j]; 150 148 /* detect only if local energy > 10. */ 151 149 if (fvec_local_energy (newmag) > 10.) { … … 172 170 fvec_t *mag = (fvec_t *) p->scratch; 173 171 fvec_t *tmp = (fvec_t *) p->scratch2; 174 uint_t i = 0,j;172 uint_t j; 175 173 uint_t length = mag->length; 176 174 /* copy newmag to mag (scracth) */ 177 175 for (j = 0; j < length; j++) { 178 mag->data[ i][j] = newmag->data[i][j];176 mag->data[j] = newmag->data[j]; 179 177 } 180 178 fvec_min_removal (mag); /* min removal */ … … 182 180 /* skipped *//* low pass filtering */ 183 181 /** \bug fvec_moving_thres may write out of bounds */ 184 fvec_adapt_thres (mag, tmp, p->win_post, p->win_pre , i); /* adaptative threshold */182 fvec_adapt_thres (mag, tmp, p->win_post, p->win_pre); /* adaptative threshold */ 185 183 fvec_add (mag, -p->threshold); /* fixed threshold */ 186 184 { … … 190 188 count = aubio_pitchmcomb_quadpick (peaks, mag); 191 189 for (j = 0; j < count; j++) 192 peaks[j].mag = newmag->data[ i][peaks[j].bin];190 peaks[j].mag = newmag->data[peaks[j].bin]; 193 191 /* reset non peaks */ 194 192 for (j = count; j < length; j++) … … 261 259 candidate[l]->ecomb[k] = peaks[position].ebin; 262 260 candidate[l]->ene += /* ecomb rounded to nearest int */ 263 POW (newmag->data[ 0][(uint_t) FLOOR (candidate[l]->ecomb[k] + .5)],261 POW (newmag->data[(uint_t) FLOOR (candidate[l]->ecomb[k] + .5)], 264 262 0.25); 265 263 candidate[l]->len += 1. / curlen; … … 290 288 aubio_pitchmcomb_quadpick (aubio_spectralpeak_t * spectral_peaks, fvec_t * X) 291 289 { 292 uint_t i, j, ispeak, count = 0; 293 for (i = 0; i < X->channels; i++) 294 for (j = 1; j < X->length - 1; j++) { 295 ispeak = fvec_peakpick (X, j); 296 if (ispeak) { 297 count += ispeak; 298 spectral_peaks[count - 1].bin = j; 299 spectral_peaks[count - 1].ebin = fvec_quadint (X, j, i) - 1.; 300 } 301 } 290 uint_t j, ispeak, count = 0; 291 for (j = 1; j < X->length - 1; j++) { 292 ispeak = fvec_peakpick (X, j); 293 if (ispeak) { 294 count += ispeak; 295 spectral_peaks[count - 1].bin = j; 296 spectral_peaks[count - 1].ebin = fvec_quadint (X, j) - 1.; 297 } 298 } 302 299 return count; 303 300 } … … 364 361 365 362 aubio_pitchmcomb_t * 366 new_aubio_pitchmcomb (uint_t bufsize, uint_t hopsize , uint_t channels)363 new_aubio_pitchmcomb (uint_t bufsize, uint_t hopsize) 367 364 { 368 365 aubio_pitchmcomb_t *p = AUBIO_NEW (aubio_pitchmcomb_t); … … 386 383 //p->biquad = new_biquad(0.1600,0.3200,0.1600, -0.5949, 0.2348); 387 384 /* allocate temp memory */ 388 p->newmag = new_fvec (spec_size , 1);385 p->newmag = new_fvec (spec_size); 389 386 /* array for median */ 390 p->scratch = new_fvec (spec_size , 1);387 p->scratch = new_fvec (spec_size); 391 388 /* array for phase */ 392 p->theta = new_fvec (spec_size , channels);389 p->theta = new_fvec (spec_size); 393 390 /* array for adaptative threshold */ 394 p->scratch2 = new_fvec (p->win_post + p->win_pre + 1 , 1);391 p->scratch2 = new_fvec (p->win_post + p->win_pre + 1); 395 392 /* array of spectral peaks */ 396 393 p->peaks = AUBIO_ARRAY (aubio_spectralpeak_t, spec_size);
Note: See TracChangeset
for help on using the changeset viewer.