Changeset 9771488
- Timestamp:
- Mar 21, 2006, 7:05:23 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:
- d94f98b
- Parents:
- 1d4fc4a
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mathutils.c
r1d4fc4a r9771488 331 331 } 332 332 333 smpl_t vec_quadint_min(fvec_t * x,uint_t pos, uint_t span) { 334 smpl_t step = 1./200.; 335 /* init resold to - something (in case x[pos+-span]<0)) */ 336 smpl_t res, frac, s0, s1, s2, exactpos = (smpl_t)pos, resold = 100000.; 337 if ((pos > span) && (pos < x->length-span)) { 338 s0 = x->data[0][pos-span]; 339 s1 = x->data[0][pos] ; 340 s2 = x->data[0][pos+span]; 341 /* increase frac */ 342 for (frac = 0.; frac < 2.; frac = frac + step) { 343 res = aubio_quadfrac(s0, s1, s2, frac); 344 if (res < resold) { 345 resold = res; 346 } else { 347 exactpos += (frac-step)*span - span/2.; 348 break; 349 } 350 } 351 } 352 return exactpos; 353 } 354 333 355 smpl_t aubio_quadfrac(smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf) { 334 356 smpl_t tmp = s0 + (pf/2.) * (pf * ( s0 - 2.*s1 + s2 ) - 3.*s0 + 4.*s1 - s2); -
src/mathutils.h
r1d4fc4a r9771488 212 212 smpl_t vec_median(fvec_t * input); 213 213 214 /** finds exact peakposition by quadratic interpolation*/214 /** finds exact maximum position by quadratic interpolation*/ 215 215 smpl_t vec_quadint(fvec_t * x,uint_t pos); 216 217 /** finds exact minimum position by quadratic interpolation*/ 218 smpl_t vec_quadint_min(fvec_t * x,uint_t pos, uint_t span); 216 219 217 220 /** Quadratic interpolation using Lagrange polynomial. -
src/pitchyin.c
r1d4fc4a r9771488 89 89 90 90 /* all the above in one */ 91 uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){91 smpl_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){ 92 92 uint_t c=0,j,tau = 0; 93 sint_t period; 93 94 smpl_t tmp = 0., tmp2 = 0.; 94 95 yin->data[c][0] = 1.; … … 103 104 tmp2 += yin->data[c][tau]; 104 105 yin->data[c][tau] *= tau/tmp2; 105 if((yin->data[c][tau] < tol) && 106 (yin->data[c][tau-1] < yin->data[c][tau])) { 107 return tau-1; 106 period = tau-3; 107 if(tau > 4 && (yin->data[c][period] < tol) && 108 (yin->data[c][period] < yin->data[c][period+1])) { 109 return vec_quadint_min(yin,period,1)-1; 108 110 } 109 111 } -
src/pitchyin.h
r1d4fc4a r9771488 39 39 uint_t aubio_pitchyin_getpitch(fvec_t *yinbuf); 40 40 41 uint_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t *yinbuf, smpl_t tol);41 smpl_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t *yinbuf, smpl_t tol); 42 42 43 43 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.