Changeset 155cc10 for src/mathutils.c
- Timestamp:
- Mar 10, 2017, 2:26:32 PM (8 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/applefworks, fix/ffmpeg5, master, sampler
- Children:
- ee8a57c
- Parents:
- 00d0275 (diff), 67b6618 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mathutils.c
r00d0275 r155cc10 25 25 #include "mathutils.h" 26 26 #include "musicutils.h" 27 #include "config.h"28 27 29 28 /** Window types */ … … 254 253 fvec_shift (fvec_t * s) 255 254 { 255 uint_t half = s->length / 2, start = half, j; 256 // if length is odd, middle element is moved to the end 257 if (2 * half < s->length) start ++; 256 258 #ifndef HAVE_ATLAS 257 uint_t j; 258 for (j = 0; j < s->length / 2; j++) { 259 ELEM_SWAP (s->data[j], s->data[j + s->length / 2]); 260 } 261 #else 262 uint_t half = s->length / 2; 263 aubio_cblas_swap(half, s->data, 1, s->data + half, 1); 264 #endif 265 } 266 267 smpl_t 268 aubio_level_lin (fvec_t * f) 259 for (j = 0; j < half; j++) { 260 ELEM_SWAP (s->data[j], s->data[j + start]); 261 } 262 #else 263 aubio_cblas_swap(half, s->data, 1, s->data + start, 1); 264 #endif 265 if (start != half) { 266 for (j = 0; j < half; j++) { 267 ELEM_SWAP (s->data[j + start - 1], s->data[j + start]); 268 } 269 } 270 } 271 272 void 273 fvec_ishift (fvec_t * s) 274 { 275 uint_t half = s->length / 2, start = half, j; 276 // if length is odd, middle element is moved to the beginning 277 if (2 * half < s->length) start ++; 278 #ifndef HAVE_ATLAS 279 for (j = 0; j < half; j++) { 280 ELEM_SWAP (s->data[j], s->data[j + start]); 281 } 282 #else 283 aubio_cblas_swap(half, s->data, 1, s->data + start, 1); 284 #endif 285 if (start != half) { 286 for (j = 0; j < half; j++) { 287 ELEM_SWAP (s->data[half], s->data[j]); 288 } 289 } 290 } 291 292 smpl_t 293 aubio_level_lin (const fvec_t * f) 269 294 { 270 295 smpl_t energy = 0.; … … 415 440 } 416 441 417 smpl_t fvec_quadratic_peak_pos ( fvec_t * x, uint_t pos) {442 smpl_t fvec_quadratic_peak_pos (const fvec_t * x, uint_t pos) { 418 443 smpl_t s0, s1, s2; uint_t x0, x2; 444 smpl_t half = .5, two = 2.; 419 445 if (pos == 0 || pos == x->length - 1) return pos; 420 446 x0 = (pos < 1) ? pos : pos - 1; … … 425 451 s1 = x->data[pos]; 426 452 s2 = x->data[x2]; 427 return pos + 0.5 * (s0 - s2 ) / (s0 - 2.* s1 + s2);453 return pos + half * (s0 - s2 ) / (s0 - two * s1 + s2); 428 454 } 429 455 … … 439 465 } 440 466 441 uint_t fvec_peakpick( fvec_t * onset, uint_t pos) {467 uint_t fvec_peakpick(const fvec_t * onset, uint_t pos) { 442 468 uint_t tmp=0; 443 469 tmp = (onset->data[pos] > onset->data[pos-1] … … 526 552 527 553 smpl_t 528 aubio_db_spl ( fvec_t * o)554 aubio_db_spl (const fvec_t * o) 529 555 { 530 556 return 10. * LOG10 (aubio_level_lin (o)); … … 532 558 533 559 uint_t 534 aubio_silence_detection ( fvec_t * o, smpl_t threshold)560 aubio_silence_detection (const fvec_t * o, smpl_t threshold) 535 561 { 536 562 return (aubio_db_spl (o) < threshold); … … 538 564 539 565 smpl_t 540 aubio_level_detection ( fvec_t * o, smpl_t threshold)566 aubio_level_detection (const fvec_t * o, smpl_t threshold) 541 567 { 542 568 smpl_t db_spl = aubio_db_spl (o); … … 572 598 573 599 void 574 aubio_autocorr ( fvec_t * input, fvec_t * output)600 aubio_autocorr (const fvec_t * input, fvec_t * output) 575 601 { 576 602 uint_t i, j, length = input->length;
Note: See TracChangeset
for help on using the changeset viewer.