Changeset bfbfafa for src


Ignore:
Timestamp:
Oct 3, 2017, 10:31:12 PM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master
Children:
2e5c52e
Parents:
7b7a58e (diff), 25db68c (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 dct

Location:
src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/aubio_priv.h

    r7b7a58e rbfbfafa  
    9494#define aubio_vDSP_minvi      vDSP_minvi
    9595#define aubio_vDSP_dotpr      vDSP_dotpr
     96#define aubio_vDSP_vclr       vDSP_vclr
    9697#else /* HAVE_AUBIO_DOUBLE */
    9798#define aubio_vDSP_mmov       vDSP_mmovD
     
    105106#define aubio_vDSP_minvi      vDSP_minviD
    106107#define aubio_vDSP_dotpr      vDSP_dotprD
     108#define aubio_vDSP_vclr       vDSP_vclrD
    107109#endif /* HAVE_AUBIO_DOUBLE */
    108110#endif /* HAVE_ACCELERATE */
     
    122124#endif /* HAVE_ATLAS */
    123125
    124 #if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS)
     126#if defined HAVE_INTEL_IPP
     127#include <ippcore.h>
     128#include <ippvm.h>
     129#include <ipps.h>
     130#ifndef HAVE_AUBIO_DOUBLE
     131#define aubio_ippsSet         ippsSet_32f
     132#define aubio_ippsZero        ippsZero_32f
     133#define aubio_ippsCopy        ippsCopy_32f
     134#define aubio_ippsMul         ippsMul_32f
     135#define aubio_ippsMulC        ippsMulC_32f
     136#define aubio_ippsAddC        ippsAddC_32f
     137#define aubio_ippsLn          ippsLn_32f_A21
     138#define aubio_ippsMean(a,b,c) ippsMean_32f(a, b, c, ippAlgHintFast)
     139#define aubio_ippsSum(a,b,c)  ippsSum_32f(a, b, c, ippAlgHintFast)
     140#define aubio_ippsMax         ippsMax_32f
     141#define aubio_ippsMin         ippsMin_32f
     142#else /* HAVE_AUBIO_DOUBLE */
     143#define aubio_ippsSet         ippsSet_64f
     144#define aubio_ippsZero        ippsZero_64f
     145#define aubio_ippsCopy        ippsCopy_64f
     146#define aubio_ippsMul         ippsMul_64f
     147#define aubio_ippsMulC        ippsMulC_64f
     148#define aubio_ippsAddC        ippsAddC_64f
     149#define aubio_ippsLn          ippsLn_64f_A26
     150#define aubio_ippsMean        ippsMean_64f
     151#define aubio_ippsSum         ippsSum_64f
     152#define aubio_ippsMax         ippsMax_64f
     153#define aubio_ippsMin         ippsMin_64f
     154#endif /* HAVE_AUBIO_DOUBLE */
     155#endif
     156
     157#if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS) && !defined(HAVE_INTEL_IPP)
    125158#define HAVE_NOOPT 1
    126159#else
  • src/cvec.c

    r7b7a58e rbfbfafa  
    8686    return;
    8787  }
    88 #ifdef HAVE_MEMCPY_HACKS
     88#if defined(HAVE_INTEL_IPP)
     89  aubio_ippsCopy(s->phas, t->phas, (int)s->length);
     90  aubio_ippsCopy(s->norm, t->norm, (int)s->length);
     91#elif defined(HAVE_MEMCPY_HACKS)
    8992  memcpy(t->norm, s->norm, t->length * sizeof(smpl_t));
    9093  memcpy(t->phas, s->phas, t->length * sizeof(smpl_t));
    91 #else /* HAVE_MEMCPY_HACKS */
     94#else
    9295  uint_t j;
    9396  for (j=0; j< t->length; j++) {
     
    9598    t->phas[j] = s->phas[j];
    9699  }
    97 #endif /* HAVE_MEMCPY_HACKS */
     100#endif
    98101}
    99102
    100 void cvec_norm_set_all (cvec_t *s, smpl_t val) {
     103void cvec_norm_set_all(cvec_t *s, smpl_t val) {
     104#if defined(HAVE_INTEL_IPP)
     105  aubio_ippsSet(val, s->norm, (int)s->length);
     106#else
    101107  uint_t j;
    102108  for (j=0; j< s->length; j++) {
    103109    s->norm[j] = val;
    104110  }
     111#endif
    105112}
    106113
    107114void cvec_norm_zeros(cvec_t *s) {
    108 #ifdef HAVE_MEMCPY_HACKS
     115#if defined(HAVE_INTEL_IPP)
     116  aubio_ippsZero(s->norm, (int)s->length);
     117#elif defined(HAVE_MEMCPY_HACKS)
    109118  memset(s->norm, 0, s->length * sizeof(smpl_t));
    110 #else /* HAVE_MEMCPY_HACKS */
     119#else
    111120  cvec_norm_set_all (s, 0.);
    112 #endif /* HAVE_MEMCPY_HACKS */
     121#endif
    113122}
    114123
     
    118127
    119128void cvec_phas_set_all (cvec_t *s, smpl_t val) {
     129#if defined(HAVE_INTEL_IPP)
     130  aubio_ippsSet(val, s->phas, (int)s->length);
     131#else
    120132  uint_t j;
    121133  for (j=0; j< s->length; j++) {
    122134    s->phas[j] = val;
    123135  }
     136#endif
    124137}
    125138
    126139void cvec_phas_zeros(cvec_t *s) {
    127 #ifdef HAVE_MEMCPY_HACKS
     140#if defined(HAVE_INTEL_IPP)
     141  aubio_ippsZero(s->phas, (int)s->length);
     142#elif defined(HAVE_MEMCPY_HACKS)
    128143  memset(s->phas, 0, s->length * sizeof(smpl_t));
    129144#else
     
    142157
    143158void cvec_logmag(cvec_t *s, smpl_t lambda) {
     159#if defined(HAVE_INTEL_IPP)
     160  aubio_ippsMulC(s->norm, lambda, s->norm, (int)s->length);
     161  aubio_ippsAddC(s->norm, 1.0, s->norm, (int)s->length);
     162  aubio_ippsLn(s->norm, s->norm, (int)s->length);
     163#else
    144164  uint_t j;
    145165  for (j=0; j< s->length; j++) {
    146166    s->norm[j] = LOG(lambda * s->norm[j] + 1);
    147167  }
     168#endif
    148169}
  • src/fvec.c

    r7b7a58e rbfbfafa  
    6161
    6262void fvec_set_all (fvec_t *s, smpl_t val) {
    63 #if !defined(HAVE_ACCELERATE) && !defined(HAVE_ATLAS)
    64   uint_t j;
    65   for (j=0; j< s->length; j++) {
    66     s->data[j] = val;
    67   }
     63#if defined(HAVE_INTEL_IPP)
     64  aubio_ippsSet(val, s->data, (int)s->length);
    6865#elif defined(HAVE_ATLAS)
    6966  aubio_catlas_set(s->length, val, s->data, 1);
    7067#elif defined(HAVE_ACCELERATE)
    7168  aubio_vDSP_vfill(&val, s->data, 1, s->length);
     69#else
     70  uint_t j;
     71  for ( j = 0; j< s->length; j++ )
     72  {
     73    s->data[j] = val;
     74  }
    7275#endif
    7376}
    7477
    7578void fvec_zeros(fvec_t *s) {
    76 #if !defined(HAVE_MEMCPY_HACKS) && !defined(HAVE_ACCELERATE)
    77   fvec_set_all (s, 0.);
    78 #else
    79 #if defined(HAVE_MEMCPY_HACKS)
     79#if defined(HAVE_INTEL_IPP)
     80  aubio_ippsZero(s->data, (int)s->length);
     81#elif defined(HAVE_ACCELERATE)
     82  aubio_vDSP_vclr(s->data, 1, s->length);
     83#elif defined(HAVE_MEMCPY_HACKS)
    8084  memset(s->data, 0, s->length * sizeof(smpl_t));
    8185#else
    82   aubio_vDSP_vclr(s->data, 1, s->length);
    83 #endif
     86  fvec_set_all(s, 0.);
    8487#endif
    8588}
     
    97100
    98101void fvec_weight(fvec_t *s, const fvec_t *weight) {
    99 #ifndef HAVE_ACCELERATE
     102  uint_t length = MIN(s->length, weight->length);
     103#if defined(HAVE_INTEL_IPP)
     104  aubio_ippsMul(s->data, weight->data, s->data, (int)length);
     105#elif defined(HAVE_ACCELERATE)
     106  aubio_vDSP_vmul( s->data, 1, weight->data, 1, s->data, 1, length );
     107#else
    100108  uint_t j;
    101   uint_t length = MIN(s->length, weight->length);
    102   for (j=0; j< length; j++) {
     109  for (j = 0; j < length; j++) {
    103110    s->data[j] *= weight->data[j];
    104111  }
    105 #else
    106   aubio_vDSP_vmul(s->data, 1, weight->data, 1, s->data, 1, s->length);
    107112#endif /* HAVE_ACCELERATE */
    108113}
    109114
    110115void fvec_weighted_copy(const fvec_t *in, const fvec_t *weight, fvec_t *out) {
    111 #ifndef HAVE_ACCELERATE
     116  uint_t length = MIN(in->length, MIN(out->length, weight->length));
     117#if defined(HAVE_INTEL_IPP)
     118  aubio_ippsMul(in->data, weight->data, out->data, (int)length);
     119#elif defined(HAVE_ACCELERATE)
     120  aubio_vDSP_vmul(in->data, 1, weight->data, 1, out->data, 1, length);
     121#else
    112122  uint_t j;
    113   uint_t length = MIN(out->length, weight->length);
    114   for (j=0; j< length; j++) {
     123  for (j = 0; j < length; j++) {
    115124    out->data[j] = in->data[j] * weight->data[j];
    116125  }
    117 #else
    118   aubio_vDSP_vmul(in->data, 1, weight->data, 1, out->data, 1, out->length);
    119 #endif /* HAVE_ACCELERATE */
     126#endif
    120127}
    121128
     
    126133    return;
    127134  }
    128 #ifdef HAVE_NOOPT
    129   uint_t j;
    130   for (j=0; j< t->length; j++) {
    131     t->data[j] = s->data[j];
    132   }
    133 #elif defined(HAVE_MEMCPY_HACKS)
    134   memcpy(t->data, s->data, t->length * sizeof(smpl_t));
     135#if defined(HAVE_INTEL_IPP)
     136  aubio_ippsCopy(s->data, t->data, (int)s->length);
    135137#elif defined(HAVE_ATLAS)
    136138  aubio_cblas_copy(s->length, s->data, 1, t->data, 1);
    137139#elif defined(HAVE_ACCELERATE)
    138140  aubio_vDSP_mmov(s->data, t->data, 1, s->length, 1, 1);
     141#elif defined(HAVE_MEMCPY_HACKS)
     142  memcpy(t->data, s->data, t->length * sizeof(smpl_t));
     143#else
     144  uint_t j;
     145  for (j = 0; j < t->length; j++) {
     146    t->data[j] = s->data[j];
     147  }
    139148#endif
    140149}
  • src/mathutils.c

    r7b7a58e rbfbfafa  
    160160{
    161161  smpl_t tmp = 0.0;
    162 #ifndef HAVE_ACCELERATE
     162#if defined(HAVE_INTEL_IPP)
     163  aubio_ippsMean(s->data, (int)s->length, &tmp);
     164  return tmp;
     165#elif defined(HAVE_ACCELERATE)
     166  aubio_vDSP_meanv(s->data, 1, &tmp, s->length);
     167  return tmp;
     168#else
    163169  uint_t j;
    164170  for (j = 0; j < s->length; j++) {
    165171    tmp += s->data[j];
    166172  }
    167   return tmp / (smpl_t) (s->length);
    168 #else
    169   aubio_vDSP_meanv(s->data, 1, &tmp, s->length);
    170   return tmp;
    171 #endif /* HAVE_ACCELERATE */
     173  return tmp / (smpl_t)(s->length);
     174#endif
    172175}
    173176
     
    176179{
    177180  smpl_t tmp = 0.0;
    178 #ifndef HAVE_ACCELERATE
     181#if defined(HAVE_INTEL_IPP)
     182  aubio_ippsSum(s->data, (int)s->length, &tmp);
     183#elif defined(HAVE_ACCELERATE)
     184  aubio_vDSP_sve(s->data, 1, &tmp, s->length);
     185#else
    179186  uint_t j;
    180187  for (j = 0; j < s->length; j++) {
    181188    tmp += s->data[j];
    182189  }
    183 #else
    184   aubio_vDSP_sve(s->data, 1, &tmp, s->length);
    185 #endif /* HAVE_ACCELERATE */
     190#endif
    186191  return tmp;
    187192}
     
    190195fvec_max (fvec_t * s)
    191196{
    192 #ifndef HAVE_ACCELERATE
    193   uint_t j;
    194   smpl_t tmp = 0.0;
    195   for (j = 0; j < s->length; j++) {
     197#if defined(HAVE_INTEL_IPP)
     198  smpl_t tmp = 0.;
     199  aubio_ippsMax( s->data, (int)s->length, &tmp);
     200#elif defined(HAVE_ACCELERATE)
     201  smpl_t tmp = 0.;
     202  aubio_vDSP_maxv( s->data, 1, &tmp, s->length );
     203#else
     204  uint_t j;
     205  smpl_t tmp = s->data[0];
     206  for (j = 1; j < s->length; j++) {
    196207    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
    197208  }
    198 #else
     209#endif
     210  return tmp;
     211}
     212
     213smpl_t
     214fvec_min (fvec_t * s)
     215{
     216#if defined(HAVE_INTEL_IPP)
    199217  smpl_t tmp = 0.;
    200   aubio_vDSP_maxv(s->data, 1, &tmp, s->length);
    201 #endif
    202   return tmp;
    203 }
    204 
    205 smpl_t
    206 fvec_min (fvec_t * s)
    207 {
    208 #ifndef HAVE_ACCELERATE
    209   uint_t j;
    210   smpl_t tmp = s->data[0];
    211   for (j = 0; j < s->length; j++) {
    212     tmp = (tmp < s->data[j]) ? tmp : s->data[j];
    213   }
    214 #else
     218  aubio_ippsMin(s->data, (int)s->length, &tmp);
     219#elif defined(HAVE_ACCELERATE)
    215220  smpl_t tmp = 0.;
    216221  aubio_vDSP_minv(s->data, 1, &tmp, s->length);
     222#else
     223  uint_t j;
     224  smpl_t tmp = s->data[0];
     225  for (j = 1; j < s->length; j++) {
     226    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
     227  }
    217228#endif
    218229  return tmp;
     
    575586}
    576587
     588uint_t
     589aubio_power_of_two_order (uint_t a)
     590{
     591  int order = 0;
     592  int temp = aubio_next_power_of_two(a);
     593  while (temp >>= 1) {
     594    ++order;
     595  }
     596  return order;
     597}
     598
    577599smpl_t
    578600aubio_db_spl (const fvec_t * o)
  • src/mathutils.h

    r7b7a58e rbfbfafa  
    313313uint_t aubio_next_power_of_two(uint_t a);
    314314
     315/** return the log2 factor of the given power of 2 value a */
     316uint_t aubio_power_of_two_order(uint_t a);
     317
    315318/** compute normalised autocorrelation function
    316319
  • src/pitch/pitchyin.c

    r7b7a58e rbfbfafa  
    3737  fvec_t *yin;
    3838  smpl_t tol;
    39   smpl_t confidence;
     39  uint_t peak_pos;
    4040};
    4141
     
    6868  o->yin = new_fvec (bufsize / 2);
    6969  o->tol = 0.15;
     70  o->peak_pos = 0;
    7071  return o;
    7172}
     
    157158    if (tau > 4 && (yin_data[period] < tol) &&
    158159        (yin_data[period] < yin_data[period + 1])) {
    159       out->data[0] = fvec_quadratic_peak_pos (yin, period);
    160       goto beach;
     160      o->peak_pos = (uint_t)period;
     161      out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos);
     162      return;
    161163    }
    162164  }
    163   out->data[0] = fvec_quadratic_peak_pos (yin, fvec_min_elem (yin));
    164 beach:
    165   return;
     165  o->peak_pos = (uint_t)fvec_min_elem (yin);
     166  out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos);
    166167}
    167168
    168169smpl_t
    169170aubio_pitchyin_get_confidence (aubio_pitchyin_t * o) {
    170   o->confidence = 1. - fvec_min (o->yin);
    171   return o->confidence;
     171  return 1. - o->yin->data[o->peak_pos];
    172172}
    173173
  • src/pitch/pitchyinfast.c

    r7b7a58e rbfbfafa  
    3939  fvec_t *yin;
    4040  smpl_t tol;
    41   smpl_t confidence;
     41  uint_t peak_pos;
    4242  fvec_t *tmpdata;
    4343  fvec_t *sqdiff;
     
    6060  o->fft = new_aubio_fft (bufsize);
    6161  o->tol = 0.15;
     62  o->peak_pos = 0;
    6263  return o;
    6364}
     
    8687  uint_t W = o->yin->length; // B / 2
    8788  fvec_t tmp_slice, kernel_ptr;
    88   smpl_t *yin_data = yin->data;
    8989  uint_t tau;
    9090  sint_t period;
     
    143143    // compute square difference r_t(tau) = sqdiff - 2 * r_t_tau[W-1:-1]
    144144    for (tau = 0; tau < W; tau++) {
    145       yin_data[tau] = o->sqdiff->data[tau] - 2. * rt_of_tau->data[tau+W];
     145      yin->data[tau] = o->sqdiff->data[tau] - 2. * rt_of_tau->data[tau+W];
    146146    }
    147147  }
    148148
    149149  // now build yin and look for first minimum
    150   fvec_set_all(out, 0.);
    151   yin_data[0] = 1.;
     150  fvec_zeros(out);
     151  yin->data[0] = 1.;
    152152  for (tau = 1; tau < length; tau++) {
    153     tmp2 += yin_data[tau];
     153    tmp2 += yin->data[tau];
    154154    if (tmp2 != 0) {
    155155      yin->data[tau] *= tau / tmp2;
     
    158158    }
    159159    period = tau - 3;
    160     if (tau > 4 && (yin_data[period] < tol) &&
    161         (yin_data[period] < yin_data[period + 1])) {
    162       out->data[0] = fvec_quadratic_peak_pos (yin, period);
    163       goto beach;
     160    if (tau > 4 && (yin->data[period] < tol) &&
     161        (yin->data[period] < yin->data[period + 1])) {
     162      o->peak_pos = (uint_t)period;
     163      out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos);
     164      return;
    164165    }
    165166  }
    166   out->data[0] = fvec_quadratic_peak_pos (yin, fvec_min_elem (yin) );
    167 beach:
    168   return;
     167  // use global minimum
     168  o->peak_pos = (uint_t)fvec_min_elem (yin);
     169  out->data[0] = fvec_quadratic_peak_pos (yin, o->peak_pos);
    169170}
    170171
    171172smpl_t
    172173aubio_pitchyinfast_get_confidence (aubio_pitchyinfast_t * o) {
    173   o->confidence = 1. - fvec_min (o->yin);
    174   return o->confidence;
     174  return 1. - o->yin->data[o->peak_pos];
    175175}
    176176
  • src/pitch/pitchyinfft.c

    r7b7a58e rbfbfafa  
    3737  fvec_t *yinfft;     /**< Yin function */
    3838  smpl_t tol;         /**< Yin tolerance */
    39   smpl_t confidence;  /**< confidence */
     39  uint_t peak_pos;    /**< currently selected peak pos*/
    4040  uint_t short_period; /** shortest period under which to check for octave error */
    4141};
     
    6868  p->yinfft = new_fvec (bufsize / 2 + 1);
    6969  p->tol = 0.85;
     70  p->peak_pos = 0;
    7071  p->win = new_aubio_window ("hanningz", bufsize);
    7172  p->weight = new_fvec (bufsize / 2 + 1);
     
    162163      halfperiod = FLOOR (tau / 2 + .5);
    163164      if (yin->data[halfperiod] < p->tol)
    164         output->data[0] = fvec_quadratic_peak_pos (yin, halfperiod);
     165        p->peak_pos = halfperiod;
    165166      else
    166         output->data[0] = fvec_quadratic_peak_pos (yin, tau);
     167        p->peak_pos = tau;
     168      output->data[0] = fvec_quadratic_peak_pos (yin, p->peak_pos);
    167169    }
    168170  } else {
     171    p->peak_pos = 0;
    169172    output->data[0] = 0.;
    170173  }
     
    186189smpl_t
    187190aubio_pitchyinfft_get_confidence (aubio_pitchyinfft_t * o) {
    188   o->confidence = 1. - fvec_min (o->yinfft);
    189   return o->confidence;
     191  return 1. - o->yinfft->data[o->peak_pos];
    190192}
    191193
  • src/spectral/fft.c

    r7b7a58e rbfbfafa  
    7878pthread_mutex_t aubio_fftw_mutex = PTHREAD_MUTEX_INITIALIZER;
    7979
    80 #else
    81 #ifdef HAVE_ACCELERATE        // using ACCELERATE
     80#elif defined HAVE_ACCELERATE        // using ACCELERATE
    8281// https://developer.apple.com/library/mac/#documentation/Accelerate/Reference/vDSPRef/Reference/reference.html
    8382#include <Accelerate/Accelerate.h>
     
    113112#endif /* HAVE_AUBIO_DOUBLE */
    114113
    115 #else                         // using OOURA
     114#elif defined HAVE_INTEL_IPP // using INTEL IPP
     115
     116#if !HAVE_AUBIO_DOUBLE
     117#define aubio_IppFloat                 Ipp32f
     118#define aubio_IppComplex               Ipp32fc
     119#define aubio_FFTSpec                  FFTSpec_R_32f
     120#define aubio_ippsMalloc_complex       ippsMalloc_32fc
     121#define aubio_ippsFFTInit_R            ippsFFTInit_R_32f
     122#define aubio_ippsFFTGetSize_R         ippsFFTGetSize_R_32f
     123#define aubio_ippsFFTInv_CCSToR        ippsFFTInv_CCSToR_32f
     124#define aubio_ippsFFTFwd_RToCCS        ippsFFTFwd_RToCCS_32f
     125#define aubio_ippsAtan2                ippsAtan2_32f_A21
     126#else /* HAVE_AUBIO_DOUBLE */
     127#define aubio_IppFloat                 Ipp64f
     128#define aubio_IppComplex               Ipp64fc
     129#define aubio_FFTSpec                  FFTSpec_R_64f
     130#define aubio_ippsMalloc_complex       ippsMalloc_64fc
     131#define aubio_ippsFFTInit_R            ippsFFTInit_R_64f
     132#define aubio_ippsFFTGetSize_R         ippsFFTGetSize_R_64f
     133#define aubio_ippsFFTInv_CCSToR        ippsFFTInv_CCSToR_64f
     134#define aubio_ippsFFTFwd_RToCCS        ippsFFTFwd_RToCCS_64f
     135#define aubio_ippsAtan2                ippsAtan2_64f_A50
     136#endif
     137
     138
     139#else // using OOURA
    116140// let's use ooura instead
    117141extern void aubio_ooura_rdft(int, int, smpl_t *, int *, smpl_t *);
    118142
    119 #endif /* HAVE_ACCELERATE */
    120 #endif /* HAVE_FFTW3 */
     143#endif
    121144
    122145struct _aubio_fft_t {
    123146  uint_t winsize;
    124147  uint_t fft_size;
     148
    125149#ifdef HAVE_FFTW3             // using FFTW3
    126150  real_t *in, *out;
    127151  fftw_plan pfw, pbw;
    128   fft_data_t * specdata;      /* complex spectral data */
    129 #else
    130 #ifdef HAVE_ACCELERATE        // using ACCELERATE
     152  fft_data_t * specdata; /* complex spectral data */
     153
     154#elif defined HAVE_ACCELERATE  // using ACCELERATE
    131155  int log2fftsize;
    132156  aubio_FFTSetup fftSetup;
    133157  aubio_DSPSplitComplex spec;
    134158  smpl_t *in, *out;
     159
     160#elif defined HAVE_INTEL_IPP  // using Intel IPP
     161  smpl_t *in, *out;
     162  Ipp8u* memSpec;
     163  Ipp8u* memInit;
     164  Ipp8u* memBuffer;
     165  struct aubio_FFTSpec* fftSpec;
     166  aubio_IppComplex* complexOut;
    135167#else                         // using OOURA
    136168  smpl_t *in, *out;
    137169  smpl_t *w;
    138170  int *ip;
    139 #endif /* HAVE_ACCELERATE */
    140 #endif /* HAVE_FFTW3 */
     171#endif /* using OOURA */
     172
    141173  fvec_t * compspec;
    142174};
     
    148180    goto beach;
    149181  }
     182
    150183#ifdef HAVE_FFTW3
    151184  uint_t i;
     
    176209    s->specdata[i] = 0.;
    177210  }
    178 #else
    179 #ifdef HAVE_ACCELERATE        // using ACCELERATE
     211
     212#elif defined HAVE_ACCELERATE  // using ACCELERATE
    180213  s->winsize = winsize;
    181214  s->fft_size = winsize;
    182215  s->compspec = new_fvec(winsize);
    183   s->log2fftsize = (uint_t)log2f(s->fft_size);
     216  s->log2fftsize = aubio_power_of_two_order(s->fft_size);
    184217  s->in = AUBIO_ARRAY(smpl_t, s->fft_size);
    185218  s->out = AUBIO_ARRAY(smpl_t, s->fft_size);
     
    187220  s->spec.imagp = AUBIO_ARRAY(smpl_t, s->fft_size/2);
    188221  s->fftSetup = aubio_vDSP_create_fftsetup(s->log2fftsize, FFT_RADIX2);
     222
     223#elif defined HAVE_INTEL_IPP  // using Intel IPP
     224  const IppHintAlgorithm qualityHint = ippAlgHintAccurate; // OR ippAlgHintFast;
     225  const int flags = IPP_FFT_NODIV_BY_ANY; // we're scaling manually afterwards
     226  int order = aubio_power_of_two_order(winsize);
     227  int sizeSpec, sizeInit, sizeBuffer;
     228  IppStatus status;
     229
     230  if (winsize <= 4 || aubio_is_power_of_two(winsize) != 1)
     231  {
     232    AUBIO_ERR("intel IPP fft: can only create with sizes > 4 and power of two, requested %d,"
     233      " try recompiling aubio with --enable-fftw3\n", winsize);
     234    goto beach;
     235  }
     236
     237  status = aubio_ippsFFTGetSize_R(order, flags, qualityHint,
     238      &sizeSpec, &sizeInit, &sizeBuffer);
     239  if (status != ippStsNoErr) {
     240    AUBIO_ERR("fft: failed to initialize fft. IPP error: %d\n", status);
     241    goto beach;
     242  }
     243  s->fft_size = s->winsize = winsize;
     244  s->compspec = new_fvec(winsize);
     245  s->in = AUBIO_ARRAY(smpl_t, s->winsize);
     246  s->out = AUBIO_ARRAY(smpl_t, s->winsize);
     247  s->memSpec = ippsMalloc_8u(sizeSpec);
     248  s->memBuffer = ippsMalloc_8u(sizeBuffer);
     249  if (sizeInit > 0 ) {
     250    s->memInit = ippsMalloc_8u(sizeInit);
     251  }
     252  s->complexOut = aubio_ippsMalloc_complex(s->fft_size / 2 + 1);
     253  status = aubio_ippsFFTInit_R(
     254    &s->fftSpec, order, flags, qualityHint, s->memSpec, s->memInit);
     255  if (status != ippStsNoErr) {
     256    AUBIO_ERR("fft: failed to initialize. IPP error: %d\n", status);
     257    goto beach;
     258  }
     259
    189260#else                         // using OOURA
    190261  if (aubio_is_power_of_two(winsize) != 1) {
     
    201272  s->w     = AUBIO_ARRAY(smpl_t, s->fft_size);
    202273  s->ip[0] = 0;
    203 #endif /* HAVE_ACCELERATE */
    204 #endif /* HAVE_FFTW3 */
     274#endif /* using OOURA */
     275
    205276  return s;
     277
    206278beach:
    207279  AUBIO_FREE(s);
     
    211283void del_aubio_fft(aubio_fft_t * s) {
    212284  /* destroy data */
    213   del_fvec(s->compspec);
    214285#ifdef HAVE_FFTW3             // using FFTW3
    215286  pthread_mutex_lock(&aubio_fftw_mutex);
     
    218289  fftw_free(s->specdata);
    219290  pthread_mutex_unlock(&aubio_fftw_mutex);
    220 #else /* HAVE_FFTW3 */
    221 #ifdef HAVE_ACCELERATE        // using ACCELERATE
     291
     292#elif defined HAVE_ACCELERATE // using ACCELERATE
    222293  AUBIO_FREE(s->spec.realp);
    223294  AUBIO_FREE(s->spec.imagp);
    224295  aubio_vDSP_destroy_fftsetup(s->fftSetup);
     296
     297#elif defined HAVE_INTEL_IPP  // using Intel IPP
     298  ippFree(s->memSpec);
     299  ippFree(s->memInit);
     300  ippFree(s->memBuffer);
     301  ippFree(s->complexOut);
     302
    225303#else                         // using OOURA
    226304  AUBIO_FREE(s->w);
    227305  AUBIO_FREE(s->ip);
    228 #endif /* HAVE_ACCELERATE */
    229 #endif /* HAVE_FFTW3 */
     306#endif
     307
     308  del_fvec(s->compspec);
     309  AUBIO_FREE(s->in);
    230310  AUBIO_FREE(s->out);
    231   AUBIO_FREE(s->in);
    232311  AUBIO_FREE(s);
    233312}
     
    252331  memcpy(s->in, input->data, s->winsize * sizeof(smpl_t));
    253332#endif /* HAVE_MEMCPY_HACKS */
     333
    254334#ifdef HAVE_FFTW3             // using FFTW3
    255335  fftw_execute(s->pfw);
     
    266346  }
    267347#endif /* HAVE_COMPLEX_H */
    268 #else /* HAVE_FFTW3 */
    269 #ifdef HAVE_ACCELERATE        // using ACCELERATE
     348
     349#elif defined HAVE_ACCELERATE // using ACCELERATE
    270350  // convert real data to even/odd format used in vDSP
    271351  aubio_vDSP_ctoz((aubio_DSPComplex*)s->in, 2, &s->spec, 1, s->fft_size/2);
     
    282362  smpl_t scale = 1./2.;
    283363  aubio_vDSP_vsmul(compspec->data, 1, &scale, compspec->data, 1, s->fft_size);
     364
     365#elif defined HAVE_INTEL_IPP  // using Intel IPP
     366
     367  // apply fft
     368  aubio_ippsFFTFwd_RToCCS(s->in, (aubio_IppFloat*)s->complexOut, s->fftSpec, s->memBuffer);
     369  // convert complex buffer to [ r0, r1, ..., rN, iN-1, .., i2, i1]
     370  compspec->data[0] = s->complexOut[0].re;
     371  compspec->data[s->fft_size / 2] = s->complexOut[s->fft_size / 2].re;
     372  for (i = 1; i < s->fft_size / 2; i++) {
     373    compspec->data[i] = s->complexOut[i].re;
     374    compspec->data[s->fft_size - i] = s->complexOut[i].im;
     375  }
     376
    284377#else                         // using OOURA
    285378  aubio_ooura_rdft(s->winsize, 1, s->in, s->ip, s->w);
     
    290383    compspec->data[s->winsize - i] = - s->in[2 * i + 1];
    291384  }
    292 #endif /* HAVE_ACCELERATE */
    293 #endif /* HAVE_FFTW3 */
     385#endif /* using OOURA */
    294386}
    295387
     
    314406    output->data[i] = s->out[i]*renorm;
    315407  }
    316 #else /* HAVE_FFTW3 */
    317 #ifdef HAVE_ACCELERATE        // using ACCELERATE
     408
     409#elif defined HAVE_ACCELERATE // using ACCELERATE
    318410  // convert from real imag  [ r0, r1, ..., rN, iN-1, .., i2, i1]
    319411  // to vDSP packed format   [ r0, rN, r1, i1, ..., rN-1, iN-1 ]
     
    333425  smpl_t scale = 1.0 / s->winsize;
    334426  aubio_vDSP_vsmul(output->data, 1, &scale, output->data, 1, s->fft_size);
     427
     428#elif defined HAVE_INTEL_IPP  // using Intel IPP
     429
     430  // convert from real imag  [ r0, 0, ..., rN, iN-1, .., i2, i1, iN-1] to complex format
     431  s->complexOut[0].re = compspec->data[0];
     432  s->complexOut[0].im = 0;
     433  s->complexOut[s->fft_size / 2].re = compspec->data[s->fft_size / 2];
     434  s->complexOut[s->fft_size / 2].im = 0.0;
     435  for (i = 1; i < s->fft_size / 2; i++) {
     436    s->complexOut[i].re = compspec->data[i];
     437    s->complexOut[i].im = compspec->data[s->fft_size - i];
     438  }
     439  // apply fft
     440  aubio_ippsFFTInv_CCSToR((const aubio_IppFloat *)s->complexOut, output->data, s->fftSpec, s->memBuffer);
     441  // apply scaling
     442  aubio_ippsMulC(output->data, 1.0 / s->winsize, output->data, s->fft_size);
     443
    335444#else                         // using OOURA
    336445  smpl_t scale = 2.0 / s->winsize;
     
    345454    output->data[i] = s->out[i] * scale;
    346455  }
    347 #endif /* HAVE_ACCELERATE */
    348 #endif /* HAVE_FFTW3 */
     456#endif
    349457}
    350458
     
    366474    spectrum->phas[0] = 0.;
    367475  }
     476#if defined(HAVE_INTEL_IPP)
     477  // convert from real imag  [ r0, r1, ..., rN, iN-1, ..., i2, i1, i0]
     478  //                     to  [ r0, r1, ..., rN, i0, i1, i2, ..., iN-1]
     479  for (i = 1; i < spectrum->length / 2; i++) {
     480    ELEM_SWAP(compspec->data[compspec->length - i],
     481        compspec->data[spectrum->length + i - 1]);
     482  }
     483  aubio_ippsAtan2(compspec->data + spectrum->length,
     484      compspec->data + 1, spectrum->phas + 1, spectrum->length - 1);
     485  // revert the imaginary part back again
     486  for (i = 1; i < spectrum->length / 2; i++) {
     487    ELEM_SWAP(compspec->data[spectrum->length + i - 1],
     488        compspec->data[compspec->length - i]);
     489  }
     490#else
    368491  for (i=1; i < spectrum->length - 1; i++) {
    369492    spectrum->phas[i] = ATAN2(compspec->data[compspec->length-i],
    370493        compspec->data[i]);
    371494  }
     495#endif
    372496  if (compspec->data[compspec->length/2] < 0) {
    373497    spectrum->phas[spectrum->length - 1] = PI;
  • src/wscript_build

    r7b7a58e rbfbfafa  
    44uselib += ['M']
    55uselib += ['FFTW3', 'FFTW3F']
     6uselib += ['INTEL_IPP']
    67uselib += ['SAMPLERATE']
    78uselib += ['SNDFILE']
     
    2526    build_features = ['cstlib', 'cshlib']
    2627elif ctx.env['DEST_OS'] in ['win32', 'win64']:
    27     build_features = ['cstlib', 'cshlib']
     28    build_features = ['cstlib', 'cshlib gensyms']
    2829elif ctx.env['DEST_OS'] in ['emscripten']:
    2930    build_features = ['cstlib','cshlib']
     
    3738# also install static lib
    3839from waflib.Tools.c import cstlib
    39 from waflib.Tools.fc import fcstlib
    40 fcstlib.inst_to = cstlib.inst_to = '${LIBDIR}'
     40cstlib.inst_to = '${LIBDIR}'
    4141
    4242for target in build_features:
     
    4444            use = uselib + ['lib_objects'],
    4545            target = 'aubio',
     46            export_symbols_regex=r'(?:.*aubio|fvec|lvec|cvec|fmat|new|del)_.*',
    4647            vnum = ctx.env['LIB_VERSION'])
    4748
Note: See TracChangeset for help on using the changeset viewer.