Changeset c5c0c98
- Timestamp:
- Sep 12, 2009, 12:08:54 AM (15 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:
- fbe2cd2
- Parents:
- 68a3fc9
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mathutils.c
r68a3fc9 rc5c0c98 286 286 } 287 287 288 smpl_t vec_quadint(fvec_t * x,uint_t pos) { 289 uint_t span = 2; 290 smpl_t step = 1./200.; 291 /* hack : init resold to - something (in case x[pos+-span]<0)) */ 292 smpl_t res, frac, s0, s1, s2, exactpos = (smpl_t)pos, resold = -1000.; 293 if ((pos > span) && (pos < x->length-span)) { 294 s0 = x->data[0][pos-span]; 295 s1 = x->data[0][pos] ; 296 s2 = x->data[0][pos+span]; 297 /* increase frac */ 298 for (frac = 0.; frac < 2.; frac = frac + step) { 299 res = aubio_quadfrac(s0, s1, s2, frac); 300 if (res > resold) 301 resold = res; 302 else { 303 exactpos += (frac-step)*2. - 1.; 304 break; 305 } 306 } 307 } 308 return exactpos; 309 } 310 311 smpl_t vec_quadint_min(fvec_t * x,uint_t pos, uint_t span) { 312 smpl_t step = 1./200.; 313 /* init resold to - something (in case x[pos+-span]<0)) */ 314 smpl_t res, frac, s0, s1, s2, exactpos = (smpl_t)pos, resold = 100000.; 315 if ((pos > span) && (pos < x->length-span)) { 316 s0 = x->data[0][pos-span]; 317 s1 = x->data[0][pos] ; 318 s2 = x->data[0][pos+span]; 319 /* increase frac */ 320 for (frac = 0.; frac < 2.; frac = frac + step) { 321 res = aubio_quadfrac(s0, s1, s2, frac); 322 if (res < resold) { 323 resold = res; 324 } else { 325 exactpos += (frac-step)*span - span/2.; 326 break; 327 } 328 } 329 } 330 return exactpos; 288 smpl_t vec_quadint(fvec_t * x,uint_t pos, uint_t span) { 289 smpl_t s0, s1, s2; 290 uint_t x0 = (pos < span) ? pos : pos - span; 291 uint_t x2 = (pos + span < x->length) ? pos + span : pos; 292 if (x0 == pos) return (x->data[0][pos] <= x->data[0][x2]) ? pos : x2; 293 if (x2 == pos) return (x->data[0][pos] <= x->data[0][x0]) ? pos : x0; 294 s0 = x->data[0][x0]; 295 s1 = x->data[0][pos] ; 296 s2 = x->data[0][x2]; 297 return pos + 0.5 * (s2 - s0 ) / (s2 - 2.* s1 + s0); 331 298 } 332 299 -
src/mathutils.h
r68a3fc9 rc5c0c98 162 162 smpl_t vec_median(fvec_t * input); 163 163 164 /** finds exact maximum position by quadratic interpolation*/ 165 smpl_t vec_quadint(fvec_t * x,uint_t pos); 166 167 /** finds exact minimum position by quadratic interpolation*/ 168 smpl_t vec_quadint_min(fvec_t * x,uint_t pos, uint_t span); 164 /** finds exact peak index by quadratic interpolation*/ 165 smpl_t vec_quadint(fvec_t * x, uint_t pos, uint_t span); 169 166 170 167 /** Quadratic interpolation using Lagrange polynomial. -
src/pitch/pitchmcomb.c
r68a3fc9 rc5c0c98 273 273 count += ispeak; 274 274 spectral_peaks[count-1].bin = j; 275 spectral_peaks[count-1].ebin = vec_quadint(X, j) - 1.;275 spectral_peaks[count-1].ebin = vec_quadint(X, j, 1) - 1.; 276 276 } 277 277 } -
src/pitch/pitchyin.c
r68a3fc9 rc5c0c98 107 107 if(tau > 4 && (yin->data[c][period] < tol) && 108 108 (yin->data[c][period] < yin->data[c][period+1])) { 109 return vec_quadint _min(yin,period,1);109 return vec_quadint(yin,period,1); 110 110 } 111 111 } 112 return vec_quadint _min(yin,vec_min_elem(yin),1);112 return vec_quadint(yin,vec_min_elem(yin),1); 113 113 //return 0; 114 114 } -
src/pitch/pitchyinfft.c
r68a3fc9 rc5c0c98 129 129 /* additional check for (unlikely) octave doubling in higher frequencies */ 130 130 if (tau>35) { 131 return vec_quadint _min(yin,tau,1);131 return vec_quadint(yin,tau,1); 132 132 } else { 133 133 /* should compare the minimum value of each interpolated peaks */ 134 134 halfperiod = FLOOR(tau/2+.5); 135 135 if (yin->data[0][halfperiod] < tol) 136 return vec_quadint _min(yin,halfperiod,1);136 return vec_quadint(yin,halfperiod,1); 137 137 else 138 return vec_quadint _min(yin,tau,1);138 return vec_quadint(yin,tau,1); 139 139 } 140 140 } else
Note: See TracChangeset
for help on using the changeset viewer.