Changeset 155cc10 for src/spectral/fft.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/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/spectral/fft.c
r00d0275 r155cc10 65 65 #ifdef HAVE_FFTW3F 66 66 #if HAVE_AUBIO_DOUBLE 67 # warning"Using aubio in double precision with fftw3 in single precision"67 #error "Using aubio in double precision with fftw3 in single precision" 68 68 #endif /* HAVE_AUBIO_DOUBLE */ 69 69 #define real_t float 70 #el se/* HAVE_FFTW3F */70 #elif defined (HAVE_FFTW3) /* HAVE_FFTW3F */ 71 71 #if !HAVE_AUBIO_DOUBLE 72 # warning"Using aubio in single precision with fftw3 in double precision"72 #error "Using aubio in single precision with fftw3 in double precision" 73 73 #endif /* HAVE_AUBIO_DOUBLE */ 74 74 #define real_t double … … 115 115 #else // using OOURA 116 116 // let's use ooura instead 117 extern void rdft(int, int, smpl_t *, int *, smpl_t *);117 extern void aubio_ooura_rdft(int, int, smpl_t *, int *, smpl_t *); 118 118 119 119 #endif /* HAVE_ACCELERATE */ … … 144 144 aubio_fft_t * new_aubio_fft (uint_t winsize) { 145 145 aubio_fft_t * s = AUBIO_NEW(aubio_fft_t); 146 if ((sint_t)winsize < 1) {147 AUBIO_ERR("fft: got winsize %d, but can not be < 1\n", winsize);146 if ((sint_t)winsize < 2) { 147 AUBIO_ERR("fft: got winsize %d, but can not be < 2\n", winsize); 148 148 goto beach; 149 149 } … … 189 189 #else // using OOURA 190 190 if (aubio_is_power_of_two(winsize) != 1) { 191 AUBIO_ERR("fft: can only create with sizes power of two, "192 " requested %d\n", winsize);191 AUBIO_ERR("fft: can only create with sizes power of two, requested %d," 192 " try recompiling aubio with --enable-fftw3\n", winsize); 193 193 goto beach; 194 194 } … … 213 213 del_fvec(s->compspec); 214 214 #ifdef HAVE_FFTW3 // using FFTW3 215 pthread_mutex_lock(&aubio_fftw_mutex); 215 216 fftw_destroy_plan(s->pfw); 216 217 fftw_destroy_plan(s->pbw); 217 218 fftw_free(s->specdata); 219 pthread_mutex_unlock(&aubio_fftw_mutex); 218 220 #else /* HAVE_FFTW3 */ 219 221 #ifdef HAVE_ACCELERATE // using ACCELERATE … … 231 233 } 232 234 233 void aubio_fft_do(aubio_fft_t * s, fvec_t * input, cvec_t * spectrum) {235 void aubio_fft_do(aubio_fft_t * s, const fvec_t * input, cvec_t * spectrum) { 234 236 aubio_fft_do_complex(s, input, s->compspec); 235 237 aubio_fft_get_spectrum(s->compspec, spectrum); 236 238 } 237 239 238 void aubio_fft_rdo(aubio_fft_t * s, c vec_t * spectrum, fvec_t * output) {240 void aubio_fft_rdo(aubio_fft_t * s, const cvec_t * spectrum, fvec_t * output) { 239 241 aubio_fft_get_realimag(spectrum, s->compspec); 240 242 aubio_fft_rdo_complex(s, s->compspec, output); 241 243 } 242 244 243 void aubio_fft_do_complex(aubio_fft_t * s, fvec_t * input, fvec_t * compspec) {245 void aubio_fft_do_complex(aubio_fft_t * s, const fvec_t * input, fvec_t * compspec) { 244 246 uint_t i; 245 247 #ifndef HAVE_MEMCPY_HACKS … … 281 283 aubio_vDSP_vsmul(compspec->data, 1, &scale, compspec->data, 1, s->fft_size); 282 284 #else // using OOURA 283 rdft(s->winsize, 1, s->in, s->ip, s->w);285 aubio_ooura_rdft(s->winsize, 1, s->in, s->ip, s->w); 284 286 compspec->data[0] = s->in[0]; 285 287 compspec->data[s->winsize / 2] = s->in[1]; … … 292 294 } 293 295 294 void aubio_fft_rdo_complex(aubio_fft_t * s, fvec_t * compspec, fvec_t * output) {296 void aubio_fft_rdo_complex(aubio_fft_t * s, const fvec_t * compspec, fvec_t * output) { 295 297 uint_t i; 296 298 #ifdef HAVE_FFTW3 … … 339 341 s->out[2 * i + 1] = - compspec->data[s->winsize - i]; 340 342 } 341 rdft(s->winsize, -1, s->out, s->ip, s->w);343 aubio_ooura_rdft(s->winsize, -1, s->out, s->ip, s->w); 342 344 for (i=0; i < s->winsize; i++) { 343 345 output->data[i] = s->out[i] * scale; … … 347 349 } 348 350 349 void aubio_fft_get_spectrum( fvec_t * compspec, cvec_t * spectrum) {351 void aubio_fft_get_spectrum(const fvec_t * compspec, cvec_t * spectrum) { 350 352 aubio_fft_get_phas(compspec, spectrum); 351 353 aubio_fft_get_norm(compspec, spectrum); 352 354 } 353 355 354 void aubio_fft_get_realimag(c vec_t * spectrum, fvec_t * compspec) {356 void aubio_fft_get_realimag(const cvec_t * spectrum, fvec_t * compspec) { 355 357 aubio_fft_get_imag(spectrum, compspec); 356 358 aubio_fft_get_real(spectrum, compspec); 357 359 } 358 360 359 void aubio_fft_get_phas( fvec_t * compspec, cvec_t * spectrum) {361 void aubio_fft_get_phas(const fvec_t * compspec, cvec_t * spectrum) { 360 362 uint_t i; 361 363 if (compspec->data[0] < 0) { … … 375 377 } 376 378 377 void aubio_fft_get_norm( fvec_t * compspec, cvec_t * spectrum) {379 void aubio_fft_get_norm(const fvec_t * compspec, cvec_t * spectrum) { 378 380 uint_t i = 0; 379 381 spectrum->norm[0] = ABS(compspec->data[0]); … … 386 388 } 387 389 388 void aubio_fft_get_imag(c vec_t * spectrum, fvec_t * compspec) {390 void aubio_fft_get_imag(const cvec_t * spectrum, fvec_t * compspec) { 389 391 uint_t i; 390 392 for (i = 1; i < ( compspec->length + 1 ) / 2 /*- 1 + 1*/; i++) { … … 394 396 } 395 397 396 void aubio_fft_get_real(c vec_t * spectrum, fvec_t * compspec) {398 void aubio_fft_get_real(const cvec_t * spectrum, fvec_t * compspec) { 397 399 uint_t i; 398 400 for (i = 0; i < compspec->length / 2 + 1; i++) {
Note: See TracChangeset
for help on using the changeset viewer.