Changeset c5c0c98 for src/mathutils.c
- 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
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.