Changeset 14e300e for src/spectral
- Timestamp:
- Oct 1, 2017, 6:11:46 PM (7 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
- Children:
- b701179
- Parents:
- ce54752
- Location:
- src/spectral
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/spectral/fft.c
rce54752 r14e300e 118 118 #define aubio_IppComplex Ipp32fc 119 119 #define aubio_FFTSpec FFTSpec_R_32f 120 #define aubio_ippsPhas ippsPhase_32fc121 120 #define aubio_ippsMalloc_complex ippsMalloc_32fc 122 121 #define aubio_ippsFFTInit_R ippsFFTInit_R_32f … … 124 123 #define aubio_ippsFFTInv_CCSToR ippsFFTInv_CCSToR_32f 125 124 #define aubio_ippsFFTFwd_RToCCS ippsFFTFwd_RToCCS_32f 125 #define aubio_ippsAtan2 ippsAtan2_32f_A21 126 126 #else /* HAVE_AUBIO_DOUBLE */ 127 127 #define aubio_IppFloat Ipp64f 128 128 #define aubio_IppComplex Ipp64fc 129 129 #define aubio_FFTSpec FFTSpec_R_64f 130 #define aubio_ippsPhas ippsPhase_64fc131 130 #define aubio_ippsMalloc_complex ippsMalloc_64fc 132 131 #define aubio_ippsFFTInit_R ippsFFTInit_R_64f … … 134 133 #define aubio_ippsFFTInv_CCSToR ippsFFTInv_CCSToR_64f 135 134 #define aubio_ippsFFTFwd_RToCCS ippsFFTFwd_RToCCS_64f 135 #define aubio_ippsAtan2 ippsAtan2_64f_A50 136 136 #endif 137 137 … … 159 159 160 160 #elif defined HAVE_INTEL_IPP // using Intel IPP 161 // mark FFT impl as Intel IPP162 #define INTEL_IPP_FFT 1163 161 smpl_t *in, *out; 164 162 Ipp8u* memSpec; … … 316 314 void aubio_fft_do(aubio_fft_t * s, const fvec_t * input, cvec_t * spectrum) { 317 315 aubio_fft_do_complex(s, input, s->compspec); 318 aubio_fft_get_spectrum(s , s->compspec, spectrum);316 aubio_fft_get_spectrum(s->compspec, spectrum); 319 317 } 320 318 321 319 void aubio_fft_rdo(aubio_fft_t * s, const cvec_t * spectrum, fvec_t * output) { 322 aubio_fft_get_realimag(s , spectrum, s->compspec);320 aubio_fft_get_realimag(spectrum, s->compspec); 323 321 aubio_fft_rdo_complex(s, s->compspec, output); 324 322 } … … 459 457 } 460 458 461 void aubio_fft_get_spectrum(aubio_fft_t *s, const fvec_t * compspec, cvec_t * spectrum) { 462 aubio_fft_get_phas(s, compspec, spectrum); 463 aubio_fft_get_norm(s, compspec, spectrum); 464 } 465 466 void aubio_fft_get_realimag(aubio_fft_t *s, const cvec_t * spectrum, fvec_t * compspec) { 467 aubio_fft_get_imag(s, spectrum, compspec); 468 aubio_fft_get_real(s, spectrum, compspec); 469 } 470 471 void aubio_fft_get_phas(aubio_fft_t *s, const fvec_t * compspec, cvec_t * spectrum) { 472 473 #ifdef INTEL_IPP_FFT // using Intel IPP FFT 474 uint_t i; 475 476 // convert from real imag [ r0, 0, ..., rN, iN-1, .., i2, i1, iN-1] to complex format 477 s->complexOut[0].re = compspec->data[0]; 478 s->complexOut[0].im = 0; 479 s->complexOut[s->fft_size / 2].re = compspec->data[s->fft_size / 2]; 480 s->complexOut[s->fft_size / 2].im = 0.0; 481 for (i = 1; i < spectrum->length - 1; i++) { 482 s->complexOut[i].re = compspec->data[i]; 483 s->complexOut[i].im = compspec->data[compspec->length - i]; 484 } 485 486 IppStatus status = aubio_ippsPhas(s->complexOut, spectrum->phas, spectrum->length); 487 if (status != ippStsNoErr) { 488 AUBIO_ERR("fft: failed to extract phase from fft. IPP error: %d\n", status); 489 } 490 491 #else // NOT using Intel IPP 459 void aubio_fft_get_spectrum(const fvec_t * compspec, cvec_t * spectrum) { 460 aubio_fft_get_phas(compspec, spectrum); 461 aubio_fft_get_norm(compspec, spectrum); 462 } 463 464 void aubio_fft_get_realimag(const cvec_t * spectrum, fvec_t * compspec) { 465 aubio_fft_get_imag(spectrum, compspec); 466 aubio_fft_get_real(spectrum, compspec); 467 } 468 469 void aubio_fft_get_phas(const fvec_t * compspec, cvec_t * spectrum) { 492 470 uint_t i; 493 471 if (compspec->data[0] < 0) { … … 496 474 spectrum->phas[0] = 0.; 497 475 } 476 #if defined(HAVE_INTEL_IPP) 477 // convert from real imag [ r0, r1, ..., rN, iN-1, ..., i2, i1, i0] 478 // to [ r0, r1, ..., rN, i0, i1, i2, ..., iN-1] 479 for (i = 1; i < spectrum->length / 2; i++) { 480 ELEM_SWAP(compspec->data[compspec->length - i], 481 compspec->data[spectrum->length + i - 1]); 482 } 483 aubio_ippsAtan2(compspec->data + spectrum->length, 484 compspec->data + 1, spectrum->phas + 1, spectrum->length - 1); 485 // revert the imaginary part back again 486 for (i = 1; i < spectrum->length / 2; i++) { 487 ELEM_SWAP(compspec->data[spectrum->length + i - 1], 488 compspec->data[compspec->length - i]); 489 } 490 #else 498 491 for (i=1; i < spectrum->length - 1; i++) { 499 492 spectrum->phas[i] = ATAN2(compspec->data[compspec->length-i], 500 493 compspec->data[i]); 501 494 } 495 #endif 502 496 if (compspec->data[compspec->length/2] < 0) { 503 497 spectrum->phas[spectrum->length - 1] = PI; … … 505 499 spectrum->phas[spectrum->length - 1] = 0.; 506 500 } 507 #endif 508 } 509 510 void aubio_fft_get_norm(aubio_fft_t *s, const fvec_t * compspec, cvec_t * spectrum) { 501 } 502 503 void aubio_fft_get_norm(const fvec_t * compspec, cvec_t * spectrum) { 511 504 uint_t i = 0; 512 505 spectrum->norm[0] = ABS(compspec->data[0]); … … 519 512 } 520 513 521 void aubio_fft_get_imag( aubio_fft_t *s,const cvec_t * spectrum, fvec_t * compspec) {514 void aubio_fft_get_imag(const cvec_t * spectrum, fvec_t * compspec) { 522 515 uint_t i; 523 516 for (i = 1; i < ( compspec->length + 1 ) / 2 /*- 1 + 1*/; i++) { … … 527 520 } 528 521 529 void aubio_fft_get_real( aubio_fft_t *s,const cvec_t * spectrum, fvec_t * compspec) {522 void aubio_fft_get_real(const cvec_t * spectrum, fvec_t * compspec) { 530 523 uint_t i; 531 524 for (i = 0; i < compspec->length / 2 + 1; i++) { -
src/spectral/fft.h
rce54752 r14e300e 99 99 100 100 */ 101 void aubio_fft_get_spectrum( aubio_fft_t *s,const fvec_t * compspec, cvec_t * spectrum);101 void aubio_fft_get_spectrum(const fvec_t * compspec, cvec_t * spectrum); 102 102 /** convert real/imag spectrum to norm/phas spectrum 103 103 … … 106 106 107 107 */ 108 void aubio_fft_get_realimag( aubio_fft_t *s,const cvec_t * spectrum, fvec_t * compspec);108 void aubio_fft_get_realimag(const cvec_t * spectrum, fvec_t * compspec); 109 109 110 110 /** compute phas spectrum from real/imag parts … … 114 114 115 115 */ 116 void aubio_fft_get_phas( aubio_fft_t *s,const fvec_t * compspec, cvec_t * spectrum);116 void aubio_fft_get_phas(const fvec_t * compspec, cvec_t * spectrum); 117 117 /** compute imaginary part from the norm/phas cvec 118 118 … … 121 121 122 122 */ 123 void aubio_fft_get_imag( aubio_fft_t *s,const cvec_t * spectrum, fvec_t * compspec);123 void aubio_fft_get_imag(const cvec_t * spectrum, fvec_t * compspec); 124 124 125 125 /** compute norm component from real/imag parts … … 129 129 130 130 */ 131 void aubio_fft_get_norm( aubio_fft_t *s,const fvec_t * compspec, cvec_t * spectrum);131 void aubio_fft_get_norm(const fvec_t * compspec, cvec_t * spectrum); 132 132 /** compute real part from norm/phas components 133 133 … … 136 136 137 137 */ 138 void aubio_fft_get_real( aubio_fft_t *s,const cvec_t * spectrum, fvec_t * compspec);138 void aubio_fft_get_real(const cvec_t * spectrum, fvec_t * compspec); 139 139 140 140 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.