Changeset 39c4721 for src/spectral/fft.c
- Timestamp:
- Sep 5, 2015, 2:08:59 AM (9 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:
- 6bb268b, cc81763
- Parents:
- b5d32cb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/spectral/fft.c
rb5d32cb r39c4721 83 83 #include <Accelerate/Accelerate.h> 84 84 85 #if !HAVE_AUBIO_DOUBLE 86 #define aubio_vDSP_ctoz vDSP_ctoz 87 #define aubio_vDSP_fft_zrip vDSP_fft_zrip 88 #define aubio_vDSP_ztoc vDSP_ztoc 89 #define aubio_vDSP_zvmags vDSP_zvmags 90 #define aubio_vDSP_zvphas vDSP_zvphas 91 #define aubio_vDSP_vsadd vDSP_vsadd 92 #define aubio_vDSP_vsmul vDSP_vsmul 93 #define aubio_vDSP_create_fftsetup vDSP_create_fftsetup 94 #define aubio_vDSP_destroy_fftsetup vDSP_destroy_fftsetup 95 #define aubio_DSPComplex DSPComplex 96 #define aubio_DSPSplitComplex DSPSplitComplex 97 #define aubio_FFTSetup FFTSetup 98 #define aubio_vvsqrt vvsqrtf 99 #else 100 #define aubio_vDSP_ctoz vDSP_ctozD 101 #define aubio_vDSP_fft_zrip vDSP_fft_zripD 102 #define aubio_vDSP_ztoc vDSP_ztocD 103 #define aubio_vDSP_zvmags vDSP_zvmagsD 104 #define aubio_vDSP_zvphas vDSP_zvphasD 105 #define aubio_vDSP_vsadd vDSP_vsaddD 106 #define aubio_vDSP_vsmul vDSP_vsmulD 107 #define aubio_vDSP_create_fftsetup vDSP_create_fftsetupD 108 #define aubio_vDSP_destroy_fftsetup vDSP_destroy_fftsetupD 109 #define aubio_DSPComplex DSPDoubleComplex 110 #define aubio_DSPSplitComplex DSPDoubleSplitComplex 111 #define aubio_FFTSetup FFTSetupD 112 #define aubio_vvsqrt vvsqrt 113 #endif /* HAVE_AUBIO_DOUBLE */ 114 85 115 #else // using OOURA 86 116 // let's use ooura instead … … 100 130 #ifdef HAVE_ACCELERATE // using ACCELERATE 101 131 int log2fftsize; 102 #if !HAVE_AUBIO_DOUBLE 103 FFTSetup fftSetup; 104 DSPSplitComplex spec; 105 float *in, *out; 106 #else 107 FFTSetupD fftSetup; 108 DSPDoubleSplitComplex spec; 109 double *in, *out; 110 #endif 132 aubio_FFTSetup fftSetup; 133 aubio_DSPSplitComplex spec; 134 smpl_t *in, *out; 111 135 #else // using OOURA 112 136 smpl_t *in, *out; … … 158 182 s->compspec = new_fvec(winsize); 159 183 s->log2fftsize = (uint_t)log2f(s->fft_size); 160 #if !HAVE_AUBIO_DOUBLE 161 s->in = AUBIO_ARRAY(float, s->fft_size); 162 s->out = AUBIO_ARRAY(float, s->fft_size); 163 s->spec.realp = AUBIO_ARRAY(float, s->fft_size/2); 164 s->spec.imagp = AUBIO_ARRAY(float, s->fft_size/2); 165 s->fftSetup = vDSP_create_fftsetup(s->log2fftsize, FFT_RADIX2); 166 #else 167 s->in = AUBIO_ARRAY(double, s->fft_size); 168 s->out = AUBIO_ARRAY(double, s->fft_size); 169 s->spec.realp = AUBIO_ARRAY(double, s->fft_size/2); 170 s->spec.imagp = AUBIO_ARRAY(double, s->fft_size/2); 171 s->fftSetup = vDSP_create_fftsetupD(s->log2fftsize, FFT_RADIX2); 172 #endif 184 s->in = AUBIO_ARRAY(smpl_t, s->fft_size); 185 s->out = AUBIO_ARRAY(smpl_t, s->fft_size); 186 s->spec.realp = AUBIO_ARRAY(smpl_t, s->fft_size/2); 187 s->spec.imagp = AUBIO_ARRAY(smpl_t, s->fft_size/2); 188 s->fftSetup = aubio_vDSP_create_fftsetup(s->log2fftsize, FFT_RADIX2); 173 189 #else // using OOURA 174 190 if (aubio_is_power_of_two(winsize) != 1) { … … 204 220 AUBIO_FREE(s->spec.realp); 205 221 AUBIO_FREE(s->spec.imagp); 206 #if !HAVE_AUBIO_DOUBLE 207 vDSP_destroy_fftsetup(s->fftSetup); 208 #else 209 vDSP_destroy_fftsetupD(s->fftSetup); 210 #endif 222 aubio_vDSP_destroy_fftsetup(s->fftSetup); 211 223 #else // using OOURA 212 224 AUBIO_FREE(s->w); … … 254 266 #else /* HAVE_FFTW3 */ 255 267 #ifdef HAVE_ACCELERATE // using ACCELERATE 256 #if !HAVE_AUBIO_DOUBLE257 268 // convert real data to even/odd format used in vDSP 258 vDSP_ctoz((DSPComplex*)s->in, 2, &s->spec, 1, s->fft_size/2);269 aubio_vDSP_ctoz((aubio_DSPComplex*)s->in, 2, &s->spec, 1, s->fft_size/2); 259 270 // compute the FFT 260 vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_FORWARD); 261 #else 262 // convert real data to even/odd format used in vDSP 263 vDSP_ctozD((DSPDoubleComplex*)s->in, 2, &s->spec, 1, s->fft_size/2); 264 // compute the FFT 265 vDSP_fft_zripD(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_FORWARD); 266 #endif 271 aubio_vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_FORWARD); 267 272 // convert from vDSP complex split to [ r0, r1, ..., rN, iN-1, .., i2, i1] 268 273 compspec->data[0] = s->spec.realp[0]; … … 274 279 // apply scaling 275 280 smpl_t scale = 1./2.; 276 #if !HAVE_AUBIO_DOUBLE 277 vDSP_vsmul(compspec->data, 1, &scale, compspec->data, 1, s->fft_size); 278 #else 279 vDSP_vsmulD(compspec->data, 1, &scale, compspec->data, 1, s->fft_size); 280 #endif 281 aubio_vDSP_vsmul(compspec->data, 1, &scale, compspec->data, 1, s->fft_size); 281 282 #else // using OOURA 282 283 rdft(s->winsize, 1, s->in, s->ip, s->w); … … 321 322 s->out[2 * i + 1] = compspec->data[s->winsize - i]; 322 323 } 323 #if !HAVE_AUBIO_DOUBLE324 324 // convert to split complex format used in vDSP 325 vDSP_ctoz((DSPComplex*)s->out, 2, &s->spec, 1, s->fft_size/2);325 aubio_vDSP_ctoz((aubio_DSPComplex*)s->out, 2, &s->spec, 1, s->fft_size/2); 326 326 // compute the FFT 327 vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE);327 aubio_vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE); 328 328 // convert result to real output 329 vDSP_ztoc(&s->spec, 1, (DSPComplex*)output->data, 2, s->fft_size/2);329 aubio_vDSP_ztoc(&s->spec, 1, (aubio_DSPComplex*)output->data, 2, s->fft_size/2); 330 330 // apply scaling 331 331 smpl_t scale = 1.0 / s->winsize; 332 vDSP_vsmul(output->data, 1, &scale, output->data, 1, s->fft_size); 333 #else 334 // convert to split complex format used in vDSP 335 vDSP_ctozD((DSPDoubleComplex*)s->out, 2, &s->spec, 1, s->fft_size/2); 336 // compute the FFT 337 vDSP_fft_zripD(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE); 338 // convert result to real output 339 vDSP_ztocD(&s->spec, 1, (DSPDoubleComplex*)output->data, 2, s->fft_size/2); 340 // apply scaling 341 smpl_t scale = 1.0 / s->winsize; 342 vDSP_vsmulD(output->data, 1, &scale, output->data, 1, s->fft_size); 343 #endif 332 aubio_vDSP_vsmul(output->data, 1, &scale, output->data, 1, s->fft_size); 344 333 #else // using OOURA 345 334 smpl_t scale = 2.0 / s->winsize;
Note: See TracChangeset
for help on using the changeset viewer.