Changeset 155cc10 for src/spectral/fft.c


Ignore:
Timestamp:
Mar 10, 2017, 2:26:32 PM (8 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, 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.
Message:

Merge branch 'master' into awhitening

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/spectral/fft.c

    r00d0275 r155cc10  
    6565#ifdef HAVE_FFTW3F
    6666#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"
    6868#endif /* HAVE_AUBIO_DOUBLE */
    6969#define real_t float
    70 #else /* HAVE_FFTW3F */
     70#elif defined (HAVE_FFTW3) /* HAVE_FFTW3F */
    7171#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"
    7373#endif /* HAVE_AUBIO_DOUBLE */
    7474#define real_t double
     
    115115#else                         // using OOURA
    116116// let's use ooura instead
    117 extern void rdft(int, int, smpl_t *, int *, smpl_t *);
     117extern void aubio_ooura_rdft(int, int, smpl_t *, int *, smpl_t *);
    118118
    119119#endif /* HAVE_ACCELERATE */
     
    144144aubio_fft_t * new_aubio_fft (uint_t winsize) {
    145145  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);
    148148    goto beach;
    149149  }
     
    189189#else                         // using OOURA
    190190  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);
    193193    goto beach;
    194194  }
     
    213213  del_fvec(s->compspec);
    214214#ifdef HAVE_FFTW3             // using FFTW3
     215  pthread_mutex_lock(&aubio_fftw_mutex);
    215216  fftw_destroy_plan(s->pfw);
    216217  fftw_destroy_plan(s->pbw);
    217218  fftw_free(s->specdata);
     219  pthread_mutex_unlock(&aubio_fftw_mutex);
    218220#else /* HAVE_FFTW3 */
    219221#ifdef HAVE_ACCELERATE        // using ACCELERATE
     
    231233}
    232234
    233 void aubio_fft_do(aubio_fft_t * s, fvec_t * input, cvec_t * spectrum) {
     235void aubio_fft_do(aubio_fft_t * s, const fvec_t * input, cvec_t * spectrum) {
    234236  aubio_fft_do_complex(s, input, s->compspec);
    235237  aubio_fft_get_spectrum(s->compspec, spectrum);
    236238}
    237239
    238 void aubio_fft_rdo(aubio_fft_t * s, cvec_t * spectrum, fvec_t * output) {
     240void aubio_fft_rdo(aubio_fft_t * s, const cvec_t * spectrum, fvec_t * output) {
    239241  aubio_fft_get_realimag(spectrum, s->compspec);
    240242  aubio_fft_rdo_complex(s, s->compspec, output);
    241243}
    242244
    243 void aubio_fft_do_complex(aubio_fft_t * s, fvec_t * input, fvec_t * compspec) {
     245void aubio_fft_do_complex(aubio_fft_t * s, const fvec_t * input, fvec_t * compspec) {
    244246  uint_t i;
    245247#ifndef HAVE_MEMCPY_HACKS
     
    281283  aubio_vDSP_vsmul(compspec->data, 1, &scale, compspec->data, 1, s->fft_size);
    282284#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);
    284286  compspec->data[0] = s->in[0];
    285287  compspec->data[s->winsize / 2] = s->in[1];
     
    292294}
    293295
    294 void aubio_fft_rdo_complex(aubio_fft_t * s, fvec_t * compspec, fvec_t * output) {
     296void aubio_fft_rdo_complex(aubio_fft_t * s, const fvec_t * compspec, fvec_t * output) {
    295297  uint_t i;
    296298#ifdef HAVE_FFTW3
     
    339341    s->out[2 * i + 1] = - compspec->data[s->winsize - i];
    340342  }
    341   rdft(s->winsize, -1, s->out, s->ip, s->w);
     343  aubio_ooura_rdft(s->winsize, -1, s->out, s->ip, s->w);
    342344  for (i=0; i < s->winsize; i++) {
    343345    output->data[i] = s->out[i] * scale;
     
    347349}
    348350
    349 void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum) {
     351void aubio_fft_get_spectrum(const fvec_t * compspec, cvec_t * spectrum) {
    350352  aubio_fft_get_phas(compspec, spectrum);
    351353  aubio_fft_get_norm(compspec, spectrum);
    352354}
    353355
    354 void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec) {
     356void aubio_fft_get_realimag(const cvec_t * spectrum, fvec_t * compspec) {
    355357  aubio_fft_get_imag(spectrum, compspec);
    356358  aubio_fft_get_real(spectrum, compspec);
    357359}
    358360
    359 void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum) {
     361void aubio_fft_get_phas(const fvec_t * compspec, cvec_t * spectrum) {
    360362  uint_t i;
    361363  if (compspec->data[0] < 0) {
     
    375377}
    376378
    377 void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum) {
     379void aubio_fft_get_norm(const fvec_t * compspec, cvec_t * spectrum) {
    378380  uint_t i = 0;
    379381  spectrum->norm[0] = ABS(compspec->data[0]);
     
    386388}
    387389
    388 void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec) {
     390void aubio_fft_get_imag(const cvec_t * spectrum, fvec_t * compspec) {
    389391  uint_t i;
    390392  for (i = 1; i < ( compspec->length + 1 ) / 2 /*- 1 + 1*/; i++) {
     
    394396}
    395397
    396 void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec) {
     398void aubio_fft_get_real(const cvec_t * spectrum, fvec_t * compspec) {
    397399  uint_t i;
    398400  for (i = 0; i < compspec->length / 2 + 1; i++) {
Note: See TracChangeset for help on using the changeset viewer.