Changeset 116bd1b for src


Ignore:
Timestamp:
Feb 16, 2016, 5:47:43 PM (9 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:
7cdabbe
Parents:
d21a4b1
Message:

src/mathutils.h: add fvec_ishift

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mathutils.c

    rd21a4b1 r116bd1b  
    254254fvec_shift (fvec_t * s)
    255255{
     256  uint_t half = s->length / 2, start = half;
     257  // if length is odd, middle element is moved to the end
     258  if (2 * half < s->length) start ++;
    256259#ifndef HAVE_ATLAS
    257   uint_t j;
    258   for (j = 0; j < s->length / 2; j++) {
    259     ELEM_SWAP (s->data[j], s->data[j + s->length / 2]);
    260   }
    261 #else
    262   uint_t half = s->length / 2;
    263   aubio_cblas_swap(half, s->data, 1, s->data + half, 1);
    264 #endif
     260  for (uint_t j = 0; j < half; j++) {
     261    ELEM_SWAP (s->data[j], s->data[j + start]);
     262  }
     263#else
     264  aubio_cblas_swap(half, s->data, 1, s->data + start, 1);
     265#endif
     266  if (start != half) {
     267    for (uint_t j = 0; j < half; j++) {
     268      ELEM_SWAP (s->data[j + start - 1], s->data[j + start]);
     269    }
     270  }
     271}
     272
     273void
     274fvec_ishift (fvec_t * s)
     275{
     276  uint_t half = s->length / 2, start = half;
     277  // if length is odd, middle element is moved to the beginning
     278  if (2 * half < s->length) start ++;
     279#ifndef HAVE_ATLAS
     280  for (uint_t j = 0; j < half; j++) {
     281    ELEM_SWAP (s->data[j], s->data[j + start]);
     282  }
     283#else
     284  aubio_cblas_swap(half, s->data, 1, s->data + start, 1);
     285#endif
     286  if (start != half) {
     287    for (uint_t j = 0; j < half; j++) {
     288      ELEM_SWAP (s->data[half], s->data[j]);
     289    }
     290  }
    265291}
    266292
  • src/mathutils.h

    rd21a4b1 r116bd1b  
    9999*/
    100100void fvec_shift (fvec_t * v);
     101
     102/** swap the left and right halves of a vector
     103
     104  This function swaps the left part of the signal with the right part of the
     105signal. Therefore
     106
     107  \f$ a[0], a[1], ..., a[\frac{N}{2}], a[\frac{N}{2}+1], ..., a[N-1], a[N] \f$
     108
     109  becomes
     110
     111  \f$ a[\frac{N}{2}+1], ..., a[N-1], a[N], a[0], a[1], ..., a[\frac{N}{2}] \f$
     112
     113  This operation, known as 'ifftshift' in the Matlab Signal Processing Toolbox,
     114can be used after computing the inverse FFT to simplify the phase relationship
     115of the resulting spectrum. See Amalia de Götzen's paper referred to above.
     116
     117*/
     118void fvec_ishift (fvec_t * v);
    101119
    102120/** compute the sum of all elements of a vector
Note: See TracChangeset for help on using the changeset viewer.