Changes in / [ee6ca74:50961b9]


Ignore:
Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/fvec.c

    ree6ca74 r50961b9  
    108108}
    109109
     110void fvec_weighted_copy(fvec_t *in, fvec_t *weight, fvec_t *out) {
     111#ifndef HAVE_ACCELERATE
     112  uint_t j;
     113  uint_t length = MIN(s->length, weight->length);
     114  for (j=0; j< length; j++) {
     115    out->data[j] = in->data[j] * weight->data[j];
     116  }
     117#else
     118  aubio_vDSP_vmul(in->data, 1, weight->data, 1, out->data, 1, out->length);
     119#endif /* HAVE_ACCELERATE */
     120}
     121
    110122void fvec_copy(fvec_t *s, fvec_t *t) {
    111123  if (s->length != t->length) {
  • src/fvec.h

    ree6ca74 r50961b9  
    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

    ree6ca74 r50961b9  
    254254fvec_shift (fvec_t * s)
    255255{
     256#ifndef HAVE_ACCELERATE
    256257  uint_t j;
    257258  for (j = 0; j < s->length / 2; j++) {
    258259    ELEM_SWAP (s->data[j], s->data[j + s->length / 2]);
    259260  }
     261#else
     262  uint_t half = s->length / 2;
     263  aubio_cblas_xswap(half, s->data, 1, s->data + half, 1);
     264#endif
    260265}
    261266
     
    264269{
    265270  smpl_t energy = 0.;
     271#ifndef HAVE_ACCELERATE
    266272  uint_t j;
    267273  for (j = 0; j < f->length; j++) {
    268274    energy += SQR (f->data[j]);
    269275  }
     276#else
     277  energy = aubio_cblas_dot(f->length, f->data, 1, f->data, 1);
     278#endif
    270279  return energy / f->length;
    271280}
  • src/pitch/pitch.c

    ree6ca74 r50961b9  
    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

    ree6ca74 r50961b9  
    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.