Changeset 69c39ca for src/spectral
- Timestamp:
- Oct 15, 2013, 10:54:59 PM (11 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:
- acd97d1
- Parents:
- f69e3bd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/spectral/fft.c
rf69e3bd r69c39ca 100 100 #ifdef HAVE_ACCELERATE // using ACCELERATE 101 101 int log2fftsize; 102 #if !HAVE_AUBIO_DOUBLE 102 103 FFTSetup fftSetup; 103 104 DSPSplitComplex spec; 104 105 float *in, *out; 106 #else 107 FFTSetupD fftSetup; 108 DSPDoubleSplitComplex spec; 109 double *in, *out; 110 #endif 105 111 #else // using OOURA 106 112 double *in, *out; … … 148 154 s->compspec = new_fvec(winsize); 149 155 s->log2fftsize = (uint_t)log2f(s->fft_size); 156 #if !HAVE_AUBIO_DOUBLE 150 157 s->in = AUBIO_ARRAY(float, s->fft_size); 151 158 s->out = AUBIO_ARRAY(float, s->fft_size); … … 153 160 s->spec.imagp = AUBIO_ARRAY(float, s->fft_size/2); 154 161 s->fftSetup = vDSP_create_fftsetup(s->log2fftsize, FFT_RADIX2); 162 #else 163 s->in = AUBIO_ARRAY(double, s->fft_size); 164 s->out = AUBIO_ARRAY(double, s->fft_size); 165 s->spec.realp = AUBIO_ARRAY(double, s->fft_size/2); 166 s->spec.imagp = AUBIO_ARRAY(double, s->fft_size/2); 167 s->fftSetup = vDSP_create_fftsetupD(s->log2fftsize, FFT_RADIX2); 168 #endif 155 169 #else // using OOURA 156 170 s->winsize = winsize; … … 219 233 #else /* HAVE_FFTW3 */ 220 234 #ifdef HAVE_ACCELERATE // using ACCELERATE 235 #if !HAVE_AUBIO_DOUBLE 221 236 // convert real data to even/odd format used in vDSP 222 vDSP_ctoz(( COMPLEX*)s->in, 2, &s->spec, 1, s->fft_size/2);237 vDSP_ctoz((DSPComplex*)s->in, 2, &s->spec, 1, s->fft_size/2); 223 238 // compute the FFT 224 239 vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_FORWARD); 240 #else 241 // convert real data to even/odd format used in vDSP 242 vDSP_ctozD((DSPDoubleComplex*)s->in, 2, &s->spec, 1, s->fft_size/2); 243 // compute the FFT 244 vDSP_fft_zripD(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_FORWARD); 245 #endif 225 246 // convert from vDSP complex split to [ r0, r1, ..., rN, iN-1, .., i2, i1] 226 247 compspec->data[0] = s->spec.realp[0]; … … 232 253 // apply scaling 233 254 smpl_t scale = 1./2.; 255 #if !HAVE_AUBIO_DOUBLE 234 256 vDSP_vsmul(compspec->data, 1, &scale, compspec->data, 1, s->fft_size); 257 #else 258 vDSP_vsmulD(compspec->data, 1, &scale, compspec->data, 1, s->fft_size); 259 #endif 235 260 #else // using OOURA 236 261 rdft(s->winsize, 1, s->in, s->ip, s->w); … … 275 300 s->out[2 * i + 1] = compspec->data[s->winsize - i]; 276 301 } 302 #if !HAVE_AUBIO_DOUBLE 277 303 // convert to split complex format used in vDSP 278 vDSP_ctoz(( COMPLEX*)s->out, 2, &s->spec, 1, s->fft_size/2);304 vDSP_ctoz((DSPComplex*)s->out, 2, &s->spec, 1, s->fft_size/2); 279 305 // compute the FFT 280 306 vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE); 281 307 // convert result to real output 282 vDSP_ztoc(&s->spec, 1, ( COMPLEX*)output->data, 2, s->fft_size/2);308 vDSP_ztoc(&s->spec, 1, (DSPComplex*)output->data, 2, s->fft_size/2); 283 309 // apply scaling 284 310 smpl_t scale = 1.0 / s->winsize; 285 311 vDSP_vsmul(output->data, 1, &scale, output->data, 1, s->fft_size); 312 #else 313 // convert to split complex format used in vDSP 314 vDSP_ctozD((DSPDoubleComplex*)s->out, 2, &s->spec, 1, s->fft_size/2); 315 // compute the FFT 316 vDSP_fft_zripD(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE); 317 // convert result to real output 318 vDSP_ztocD(&s->spec, 1, (DSPDoubleComplex*)output->data, 2, s->fft_size/2); 319 // apply scaling 320 smpl_t scale = 1.0 / s->winsize; 321 vDSP_vsmulD(output->data, 1, &scale, output->data, 1, s->fft_size); 322 #endif 286 323 #else // using OOURA 287 324 smpl_t scale = 2.0 / s->winsize;
Note: See TracChangeset
for help on using the changeset viewer.