Changeset 69c39ca for src/spectral


Ignore:
Timestamp:
Oct 15, 2013, 10:54:59 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
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
Message:

src/spectral/fft.c: add vDSP for HAVE_AUBIO_DOUBLE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/fft.c

    rf69e3bd r69c39ca  
    100100#ifdef HAVE_ACCELERATE        // using ACCELERATE
    101101  int log2fftsize;
     102#if !HAVE_AUBIO_DOUBLE
    102103  FFTSetup fftSetup;
    103104  DSPSplitComplex spec;
    104105  float *in, *out;
     106#else
     107  FFTSetupD fftSetup;
     108  DSPDoubleSplitComplex spec;
     109  double *in, *out;
     110#endif
    105111#else                         // using OOURA
    106112  double *in, *out;
     
    148154  s->compspec = new_fvec(winsize);
    149155  s->log2fftsize = (uint_t)log2f(s->fft_size);
     156#if !HAVE_AUBIO_DOUBLE
    150157  s->in = AUBIO_ARRAY(float, s->fft_size);
    151158  s->out = AUBIO_ARRAY(float, s->fft_size);
     
    153160  s->spec.imagp = AUBIO_ARRAY(float, s->fft_size/2);
    154161  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
    155169#else                         // using OOURA
    156170  s->winsize = winsize;
     
    219233#else /* HAVE_FFTW3 */
    220234#ifdef HAVE_ACCELERATE        // using ACCELERATE
     235#if !HAVE_AUBIO_DOUBLE
    221236  // 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);
    223238  // compute the FFT
    224239  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
    225246  // convert from vDSP complex split to [ r0, r1, ..., rN, iN-1, .., i2, i1]
    226247  compspec->data[0] = s->spec.realp[0];
     
    232253  // apply scaling
    233254  smpl_t scale = 1./2.;
     255#if !HAVE_AUBIO_DOUBLE
    234256  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
    235260#else                         // using OOURA
    236261  rdft(s->winsize, 1, s->in, s->ip, s->w);
     
    275300    s->out[2 * i + 1] = compspec->data[s->winsize - i];
    276301  }
     302#if !HAVE_AUBIO_DOUBLE
    277303  // 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);
    279305  // compute the FFT
    280306  vDSP_fft_zrip(s->fftSetup, &s->spec, 1, s->log2fftsize, FFT_INVERSE);
    281307  // 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);
    283309  // apply scaling
    284310  smpl_t scale = 1.0 / s->winsize;
    285311  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
    286323#else                         // using OOURA
    287324  smpl_t scale = 2.0 / s->winsize;
Note: See TracChangeset for help on using the changeset viewer.