Changeset 155cc10 for src/mathutils.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/applefworks, 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/mathutils.c

    r00d0275 r155cc10  
    2525#include "mathutils.h"
    2626#include "musicutils.h"
    27 #include "config.h"
    2827
    2928/** Window types */
     
    254253fvec_shift (fvec_t * s)
    255254{
     255  uint_t half = s->length / 2, start = half, j;
     256  // if length is odd, middle element is moved to the end
     257  if (2 * half < s->length) start ++;
    256258#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
    265 }
    266 
    267 smpl_t
    268 aubio_level_lin (fvec_t * f)
     259  for (j = 0; j < half; j++) {
     260    ELEM_SWAP (s->data[j], s->data[j + start]);
     261  }
     262#else
     263  aubio_cblas_swap(half, s->data, 1, s->data + start, 1);
     264#endif
     265  if (start != half) {
     266    for (j = 0; j < half; j++) {
     267      ELEM_SWAP (s->data[j + start - 1], s->data[j + start]);
     268    }
     269  }
     270}
     271
     272void
     273fvec_ishift (fvec_t * s)
     274{
     275  uint_t half = s->length / 2, start = half, j;
     276  // if length is odd, middle element is moved to the beginning
     277  if (2 * half < s->length) start ++;
     278#ifndef HAVE_ATLAS
     279  for (j = 0; j < half; j++) {
     280    ELEM_SWAP (s->data[j], s->data[j + start]);
     281  }
     282#else
     283  aubio_cblas_swap(half, s->data, 1, s->data + start, 1);
     284#endif
     285  if (start != half) {
     286    for (j = 0; j < half; j++) {
     287      ELEM_SWAP (s->data[half], s->data[j]);
     288    }
     289  }
     290}
     291
     292smpl_t
     293aubio_level_lin (const fvec_t * f)
    269294{
    270295  smpl_t energy = 0.;
     
    415440}
    416441
    417 smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) {
     442smpl_t fvec_quadratic_peak_pos (const fvec_t * x, uint_t pos) {
    418443  smpl_t s0, s1, s2; uint_t x0, x2;
     444  smpl_t half = .5, two = 2.;
    419445  if (pos == 0 || pos == x->length - 1) return pos;
    420446  x0 = (pos < 1) ? pos : pos - 1;
     
    425451  s1 = x->data[pos];
    426452  s2 = x->data[x2];
    427   return pos + 0.5 * (s0 - s2 ) / (s0 - 2.* s1 + s2);
     453  return pos + half * (s0 - s2 ) / (s0 - two * s1 + s2);
    428454}
    429455
     
    439465}
    440466
    441 uint_t fvec_peakpick(fvec_t * onset, uint_t pos) {
     467uint_t fvec_peakpick(const fvec_t * onset, uint_t pos) {
    442468  uint_t tmp=0;
    443469  tmp = (onset->data[pos] > onset->data[pos-1]
     
    526552
    527553smpl_t
    528 aubio_db_spl (fvec_t * o)
     554aubio_db_spl (const fvec_t * o)
    529555{
    530556  return 10. * LOG10 (aubio_level_lin (o));
     
    532558
    533559uint_t
    534 aubio_silence_detection (fvec_t * o, smpl_t threshold)
     560aubio_silence_detection (const fvec_t * o, smpl_t threshold)
    535561{
    536562  return (aubio_db_spl (o) < threshold);
     
    538564
    539565smpl_t
    540 aubio_level_detection (fvec_t * o, smpl_t threshold)
     566aubio_level_detection (const fvec_t * o, smpl_t threshold)
    541567{
    542568  smpl_t db_spl = aubio_db_spl (o);
     
    572598
    573599void
    574 aubio_autocorr (fvec_t * input, fvec_t * output)
     600aubio_autocorr (const fvec_t * input, fvec_t * output)
    575601{
    576602  uint_t i, j, length = input->length;
Note: See TracChangeset for help on using the changeset viewer.