Changes in / [f45dd12:c59e693]


Ignore:
Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/fvec.c

    rf45dd12 rc59e693  
    2828#define aubio_vDSP_vmul       vDSP_vmul
    2929#define aubio_vDSP_vfill      vDSP_vfill
     30#define aubio_catlas_set      catlas_sset
    3031#else /* HAVE_AUBIO_DOUBLE */
    3132#define aubio_vDSP_mmov       vDSP_mmovD
    3233#define aubio_vDSP_vmul       vDSP_vmulD
    3334#define aubio_vDSP_vfill      vDSP_vfillD
     35#define aubio_catlas_set      catlas_dset
    3436#endif /* HAVE_AUBIO_DOUBLE */
    3537#endif
     
    8082  }
    8183#else
     84  //aubio_catlas_set(s->length, val, s->data, 1);
    8285  aubio_vDSP_vfill(&val, s->data, 1, s->length);
    8386#endif
     
    119122}
    120123
     124void fvec_weighted_copy(fvec_t *in, fvec_t *weight, fvec_t *out) {
     125#ifndef HAVE_ACCELERATE
     126  uint_t j;
     127  uint_t length = MIN(s->length, weight->length);
     128  for (j=0; j< length; j++) {
     129    out->data[j] = in->data[j] * weight->data[j];
     130  }
     131#else
     132  aubio_vDSP_vmul(in->data, 1, weight->data, 1, out->data, 1, out->length);
     133#endif /* HAVE_ACCELERATE */
     134}
     135
    121136void fvec_copy(fvec_t *s, fvec_t *t) {
    122137  if (s->length != t->length) {
  • src/fvec.h

    rf45dd12 rc59e693  
    163163void fvec_copy(fvec_t *s, fvec_t *t);
    164164
     165/** make a copy of a vector, applying weights to each element
     166
     167  \param in input vector
     168  \param weight weights vector
     169  \param out output vector
     170
     171*/
     172void fvec_weighted_copy(fvec_t *in, fvec_t *weight, fvec_t *out);
     173
    165174#ifdef __cplusplus
    166175}
  • src/mathutils.c

    rf45dd12 rc59e693  
    2929#ifdef HAVE_ACCELERATE
    3030#include <Accelerate/Accelerate.h>
     31#endif
     32
     33#if !HAVE_AUBIO_DOUBLE
     34#define aubio_cblas_xswap cblas_sswap
     35#define aubio_cblas_dot   cblas_sdot
     36#else
     37#define aubio_cblas_xswap cblas_dswap
     38#define aubio_cblas_dot   cblas_ddot
    3139#endif
    3240
     
    282290fvec_shift (fvec_t * s)
    283291{
     292#ifndef HAVE_ACCELERATE
    284293  uint_t j;
    285294  for (j = 0; j < s->length / 2; j++) {
    286295    ELEM_SWAP (s->data[j], s->data[j + s->length / 2]);
    287296  }
     297#else
     298  uint_t half = s->length / 2;
     299  aubio_cblas_xswap(half, s->data, 1, s->data + half, 1);
     300#endif
    288301}
    289302
     
    292305{
    293306  smpl_t energy = 0.;
     307#ifndef HAVE_ACCELERATE
    294308  uint_t j;
    295309  for (j = 0; j < f->length; j++) {
    296310    energy += SQR (f->data[j]);
    297311  }
     312#else
     313  energy = aubio_cblas_dot(f->length, f->data, 1, f->data, 1);
     314#endif
    298315  return energy / f->length;
    299316}
  • src/pitch/pitch.c

    rf45dd12 rc59e693  
    240240aubio_pitch_slideblock (aubio_pitch_t * p, fvec_t * ibuf)
    241241{
    242   uint_t j = 0, overlap_size = 0;
    243   overlap_size = p->buf->length - ibuf->length;
     242  uint_t overlap_size = p->buf->length - ibuf->length;
     243#if !HAVE_MEMCPY_HACKS
     244  uint_t j;
    244245  for (j = 0; j < overlap_size; j++) {
    245246    p->buf->data[j] = p->buf->data[j + ibuf->length];
     
    248249    p->buf->data[j + overlap_size] = ibuf->data[j];
    249250  }
     251#else
     252  smpl_t *data = p->buf->data;
     253  smpl_t *newdata = ibuf->data;
     254  memmove(data, data + ibuf->length, overlap_size);
     255  memcpy(data + overlap_size, newdata, ibuf->length);
     256#endif
    250257}
    251258
  • src/pitch/pitchyinfft.c

    rf45dd12 rc59e693  
    108108  smpl_t tmp = 0., sum = 0.;
    109109  // window the input
    110   for (l = 0; l < input->length; l++) {
    111     p->winput->data[l] = p->win->data[l] * input->data[l];
    112   }
     110  fvec_weighted_copy(input, p->win, p->winput);
    113111  // get the real / imag parts of its fft
    114112  aubio_fft_do_complex (p->fft, p->winput, fftout);
Note: See TracChangeset for help on using the changeset viewer.