source: src/mathutils.c @ 98d8d2b

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 98d8d2b was 98d8d2b, checked in by Paul Brossier <piem@piem.org>, 9 years ago

src/mathutils.c: Accelerate fvec_sum and fvec_mean

  • Property mode set to 100644
File size: 13.9 KB
RevLine 
[96fb8ad]1/*
[7380327]2  Copyright (C) 2003-2014 Paul Brossier <piem@aubio.org>
[96fb8ad]3
[a6db140]4  This file is part of aubio.
[96fb8ad]5
[a6db140]6  aubio is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
[96fb8ad]10
[a6db140]11  aubio is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
[96fb8ad]18
19*/
20
21/* see in mathutils.h for doc */
22
23#include "aubio_priv.h"
[6c7d49b]24#include "fvec.h"
[96fb8ad]25#include "mathutils.h"
[83963b3]26#include "musicutils.h"
[714380d]27#include "config.h"
[96fb8ad]28
[7c07af2]29#ifdef HAVE_ACCELERATE
30#include <Accelerate/Accelerate.h>
31#endif
[407bba9]32
33/** Window types */
34typedef enum
35{
36  aubio_win_rectangle,
37  aubio_win_hamming,
38  aubio_win_hanning,
39  aubio_win_hanningz,
40  aubio_win_blackman,
41  aubio_win_blackman_harris,
42  aubio_win_gaussian,
43  aubio_win_welch,
44  aubio_win_parzen,
45  aubio_win_default = aubio_win_hanningz,
46} aubio_window_type;
47
[eb7f743]48fvec_t *
[33cd81f]49new_aubio_window (char_t * window_type, uint_t length)
[eb7f743]50{
[33cd81f]51  fvec_t * win = new_fvec (length);
[c21acb9]52  uint_t err;
[ca45e58]53  if (win == NULL) {
54    return NULL;
55  }
[c21acb9]56  err = fvec_set_window (win, window_type);
[ca45e58]57  if (err != 0) {
58    del_fvec(win);
59    return NULL;
60  }
[33cd81f]61  return win;
62}
63
64uint_t fvec_set_window (fvec_t *win, char_t *window_type) {
[8e5c051]65  smpl_t * w = win->data;
[33cd81f]66  uint_t i, size = win->length;
[407bba9]67  aubio_window_type wintype;
[33cd81f]68  if (window_type == NULL) {
69      AUBIO_ERR ("window type can not be null.\n");
70      return 1;
71  } else if (strcmp (window_type, "rectangle") == 0)
[407bba9]72      wintype = aubio_win_rectangle;
73  else if (strcmp (window_type, "hamming") == 0)
74      wintype = aubio_win_hamming;
75  else if (strcmp (window_type, "hanning") == 0)
76      wintype = aubio_win_hanning;
77  else if (strcmp (window_type, "hanningz") == 0)
78      wintype = aubio_win_hanningz;
79  else if (strcmp (window_type, "blackman") == 0)
80      wintype = aubio_win_blackman;
81  else if (strcmp (window_type, "blackman_harris") == 0)
82      wintype = aubio_win_blackman_harris;
83  else if (strcmp (window_type, "gaussian") == 0)
84      wintype = aubio_win_gaussian;
85  else if (strcmp (window_type, "welch") == 0)
86      wintype = aubio_win_welch;
87  else if (strcmp (window_type, "parzen") == 0)
88      wintype = aubio_win_parzen;
89  else if (strcmp (window_type, "default") == 0)
90      wintype = aubio_win_default;
91  else {
[33cd81f]92      AUBIO_ERR ("unknown window type `%s`.\n", window_type);
93      return 1;
[407bba9]94  }
[96fb8ad]95  switch(wintype) {
[b4b0324]96    case aubio_win_rectangle:
[96fb8ad]97      for (i=0;i<size;i++)
[ade9afe]98        w[i] = 0.5;
[96fb8ad]99      break;
[b4b0324]100    case aubio_win_hamming:
[96fb8ad]101      for (i=0;i<size;i++)
102        w[i] = 0.54 - 0.46 * COS(TWO_PI * i / (size));
103      break;
[b4b0324]104    case aubio_win_hanning:
[96fb8ad]105      for (i=0;i<size;i++)
106        w[i] = 0.5 - (0.5 * COS(TWO_PI * i / (size)));
107      break;
[b4b0324]108    case aubio_win_hanningz:
[96fb8ad]109      for (i=0;i<size;i++)
110        w[i] = 0.5 * (1.0 - COS(TWO_PI * i / (size)));
111      break;
[b4b0324]112    case aubio_win_blackman:
[96fb8ad]113      for (i=0;i<size;i++)
114        w[i] = 0.42
115          - 0.50 * COS(    TWO_PI*i/(size-1.0))
[ade9afe]116          + 0.08 * COS(2.0*TWO_PI*i/(size-1.0));
[96fb8ad]117      break;
[b4b0324]118    case aubio_win_blackman_harris:
[96fb8ad]119      for (i=0;i<size;i++)
[ade9afe]120        w[i] = 0.35875
[96fb8ad]121          - 0.48829 * COS(    TWO_PI*i/(size-1.0))
122          + 0.14128 * COS(2.0*TWO_PI*i/(size-1.0))
123          - 0.01168 * COS(3.0*TWO_PI*i/(size-1.0));
124      break;
[b4b0324]125    case aubio_win_gaussian:
[9e56228]126      {
127        lsmp_t a, b, c = 0.5;
128        uint_t n;
129        for (n = 0; n < size; n++)
130        {
131          a = (n-c*(size-1))/(SQR(c)*(size-1));
132          b = -c*SQR(a);
133          w[n] = EXP(b);
134        }
135      }
[96fb8ad]136      break;
[b4b0324]137    case aubio_win_welch:
[96fb8ad]138      for (i=0;i<size;i++)
[f9d5346]139        w[i] = 1.0 - SQR((2.*i-size)/(size+1.0));
[96fb8ad]140      break;
[b4b0324]141    case aubio_win_parzen:
[96fb8ad]142      for (i=0;i<size;i++)
[053495b]143        w[i] = 1.0 - ABS((2.f*i-size)/(size+1.0f));
[96fb8ad]144      break;
145    default:
146      break;
147  }
[33cd81f]148  return 0;
[96fb8ad]149}
150
[eb7f743]151smpl_t
152aubio_unwrap2pi (smpl_t phase)
153{
[96fb8ad]154  /* mod(phase+pi,-2pi)+pi */
[eb7f743]155  return phase + TWO_PI * (1. + FLOOR (-(phase + PI) / TWO_PI));
[96fb8ad]156}
157
[eb7f743]158smpl_t
159fvec_mean (fvec_t * s)
160{
[56ef7e1]161  smpl_t tmp = 0.0;
[98d8d2b]162#ifndef HAVE_ACCELERATE
163  uint_t j;
[8e5c051]164  for (j = 0; j < s->length; j++) {
165    tmp += s->data[j];
166  }
[56ef7e1]167  return tmp / (smpl_t) (s->length);
[98d8d2b]168#else
169#if !HAVE_AUBIO_DOUBLE
170  vDSP_meanv(s->data, 1, &tmp, s->length);
171#else /* HAVE_AUBIO_DOUBLE */
172  vDSP_meanvD(s->data, 1, &tmp, s->length);
173#endif /* HAVE_AUBIO_DOUBLE */
174  return tmp;
175#endif /* HAVE_ACCELERATE */
[56ef7e1]176}
177
178smpl_t
[eb7f743]179fvec_sum (fvec_t * s)
180{
[acf7d30]181  smpl_t tmp = 0.0;
[98d8d2b]182#ifndef HAVE_ACCELERATE
183  uint_t j;
[8e5c051]184  for (j = 0; j < s->length; j++) {
185    tmp += s->data[j];
[eb7f743]186  }
[98d8d2b]187#else
188#if !HAVE_AUBIO_DOUBLE
189  vDSP_sve(s->data, 1, &tmp, s->length);
190#else /* HAVE_AUBIO_DOUBLE */
191  vDSP_sveD(s->data, 1, &tmp, s->length);
192#endif /* HAVE_AUBIO_DOUBLE */
193#endif /* HAVE_ACCELERATE */
[96fb8ad]194  return tmp;
195}
196
[eb7f743]197smpl_t
198fvec_max (fvec_t * s)
199{
[7c07af2]200#ifndef HAVE_ACCELERATE
[8e5c051]201  uint_t j;
[acf7d30]202  smpl_t tmp = 0.0;
[8e5c051]203  for (j = 0; j < s->length; j++) {
204    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
[eb7f743]205  }
[7c07af2]206#else
207  smpl_t tmp = 0.;
208#if !HAVE_AUBIO_DOUBLE
209  vDSP_maxv(s->data, 1, &tmp, s->length);
210#else
211  vDSP_maxvD(s->data, 1, &tmp, s->length);
212#endif
213#endif
[96fb8ad]214  return tmp;
215}
216
[eb7f743]217smpl_t
218fvec_min (fvec_t * s)
219{
[7c07af2]220#ifndef HAVE_ACCELERATE
[8e5c051]221  uint_t j;
222  smpl_t tmp = s->data[0];
223  for (j = 0; j < s->length; j++) {
224    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
[eb7f743]225  }
[7c07af2]226#else
227  smpl_t tmp = 0.;
228#if !HAVE_AUBIO_DOUBLE
229  vDSP_minv(s->data, 1, &tmp, s->length);
230#else
231  vDSP_minvD(s->data, 1, &tmp, s->length);
232#endif
233#endif
[96fb8ad]234  return tmp;
235}
236
[eb7f743]237uint_t
238fvec_min_elem (fvec_t * s)
239{
[7c07af2]240#ifndef HAVE_ACCELERATE
[8e5c051]241  uint_t j, pos = 0.;
242  smpl_t tmp = s->data[0];
243  for (j = 0; j < s->length; j++) {
244    pos = (tmp < s->data[j]) ? pos : j;
245    tmp = (tmp < s->data[j]) ? tmp : s->data[j];
[eb7f743]246  }
[7c07af2]247#else
248  smpl_t tmp = 0.;
249  uint_t pos = 0.;
250#if !HAVE_AUBIO_DOUBLE
251  vDSP_minvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
252#else
253  vDSP_minviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
254#endif
255#endif
[96fb8ad]256  return pos;
257}
258
[eb7f743]259uint_t
260fvec_max_elem (fvec_t * s)
261{
[7c07af2]262#ifndef HAVE_ACCELERATE
[8e5c051]263  uint_t j, pos = 0;
[acf7d30]264  smpl_t tmp = 0.0;
[8e5c051]265  for (j = 0; j < s->length; j++) {
266    pos = (tmp > s->data[j]) ? pos : j;
267    tmp = (tmp > s->data[j]) ? tmp : s->data[j];
[eb7f743]268  }
[7c07af2]269#else
270  smpl_t tmp = 0.;
271  uint_t pos = 0.;
272#if !HAVE_AUBIO_DOUBLE
273  vDSP_maxvi(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
274#else
275  vDSP_maxviD(s->data, 1, &tmp, (vDSP_Length *)&pos, s->length);
276#endif
277#endif
[96fb8ad]278  return pos;
279}
280
[eb7f743]281void
282fvec_shift (fvec_t * s)
283{
[8e5c051]284  uint_t j;
285  for (j = 0; j < s->length / 2; j++) {
286    ELEM_SWAP (s->data[j], s->data[j + s->length / 2]);
[eb7f743]287  }
[96fb8ad]288}
289
[eb7f743]290smpl_t
[5b41ef9]291aubio_level_lin (fvec_t * f)
[eb7f743]292{
293  smpl_t energy = 0.;
[8e5c051]294  uint_t j;
295  for (j = 0; j < f->length; j++) {
296    energy += SQR (f->data[j]);
[eb7f743]297  }
[1a74ac3]298  return energy / f->length;
[96fb8ad]299}
300
[eb7f743]301smpl_t
302fvec_local_hfc (fvec_t * v)
303{
304  smpl_t hfc = 0.;
[8e5c051]305  uint_t j;
306  for (j = 0; j < v->length; j++) {
307    hfc += (j + 1) * v->data[j];
[eb7f743]308  }
309  return hfc;
[96fb8ad]310}
311
[eb7f743]312void
313fvec_min_removal (fvec_t * v)
314{
315  smpl_t v_min = fvec_min (v);
316  fvec_add (v,  - v_min );
[96fb8ad]317}
318
[eb7f743]319smpl_t
320fvec_alpha_norm (fvec_t * o, smpl_t alpha)
[c0b295c]321{
[8e5c051]322  uint_t j;
[eb7f743]323  smpl_t tmp = 0.;
[8e5c051]324  for (j = 0; j < o->length; j++) {
325    tmp += POW (ABS (o->data[j]), alpha);
[c0b295c]326  }
[eb7f743]327  return POW (tmp / o->length, 1. / alpha);
[96fb8ad]328}
329
[eb7f743]330void
331fvec_alpha_normalise (fvec_t * o, smpl_t alpha)
332{
[8e5c051]333  uint_t j;
[eb7f743]334  smpl_t norm = fvec_alpha_norm (o, alpha);
[8e5c051]335  for (j = 0; j < o->length; j++) {
336    o->data[j] /= norm;
[96fb8ad]337  }
338}
339
[eb7f743]340void
341fvec_add (fvec_t * o, smpl_t val)
342{
[8e5c051]343  uint_t j;
344  for (j = 0; j < o->length; j++) {
345    o->data[j] += val;
[96fb8ad]346  }
347}
348
[5c4ec3c]349void fvec_adapt_thres(fvec_t * vec, fvec_t * tmp,
[8e5c051]350    uint_t post, uint_t pre) {
351  uint_t length = vec->length, j;
[96fb8ad]352  for (j=0;j<length;j++) {
[8e5c051]353    vec->data[j] -= fvec_moving_thres(vec, tmp, post, pre, j);
[96fb8ad]354  }
355}
356
[eb7f743]357smpl_t
358fvec_moving_thres (fvec_t * vec, fvec_t * tmpvec,
[8e5c051]359    uint_t post, uint_t pre, uint_t pos)
[eb7f743]360{
[8e5c051]361  uint_t k;
362  smpl_t *medar = (smpl_t *) tmpvec->data;
[eb7f743]363  uint_t win_length = post + pre + 1;
364  uint_t length = vec->length;
[96fb8ad]365  /* post part of the buffer does not exist */
[eb7f743]366  if (pos < post + 1) {
367    for (k = 0; k < post + 1 - pos; k++)
368      medar[k] = 0.;            /* 0-padding at the beginning */
369    for (k = post + 1 - pos; k < win_length; k++)
[8e5c051]370      medar[k] = vec->data[k + pos - post];
[eb7f743]371    /* the buffer is fully defined */
372  } else if (pos + pre < length) {
373    for (k = 0; k < win_length; k++)
[8e5c051]374      medar[k] = vec->data[k + pos - post];
[eb7f743]375    /* pre part of the buffer does not exist */
[96fb8ad]376  } else {
[eb7f743]377    for (k = 0; k < length - pos + post; k++)
[8e5c051]378      medar[k] = vec->data[k + pos - post];
[eb7f743]379    for (k = length - pos + post; k < win_length; k++)
380      medar[k] = 0.;            /* 0-padding at the end */
[ade9afe]381  }
[8e5c051]382  return fvec_median (tmpvec);
[96fb8ad]383}
384
[8e5c051]385smpl_t fvec_median (fvec_t * input) {
[96fb8ad]386  uint_t n = input->length;
[8e5c051]387  smpl_t * arr = (smpl_t *) input->data;
[96fb8ad]388  uint_t low, high ;
389  uint_t median;
390  uint_t middle, ll, hh;
391
392  low = 0 ; high = n-1 ; median = (low + high) / 2;
393  for (;;) {
394    if (high <= low) /* One element only */
395      return arr[median] ;
396
397    if (high == low + 1) {  /* Two elements only */
398      if (arr[low] > arr[high])
399        ELEM_SWAP(arr[low], arr[high]) ;
400      return arr[median] ;
401    }
402
403    /* Find median of low, middle and high items; swap into position low */
404    middle = (low + high) / 2;
405    if (arr[middle] > arr[high])    ELEM_SWAP(arr[middle], arr[high]);
406    if (arr[low]    > arr[high])    ELEM_SWAP(arr[low],    arr[high]);
407    if (arr[middle] > arr[low])     ELEM_SWAP(arr[middle], arr[low]) ;
408
409    /* Swap low item (now in position middle) into position (low+1) */
410    ELEM_SWAP(arr[middle], arr[low+1]) ;
411
412    /* Nibble from each end towards middle, swapping items when stuck */
413    ll = low + 1;
414    hh = high;
415    for (;;) {
416      do ll++; while (arr[low] > arr[ll]) ;
417      do hh--; while (arr[hh]  > arr[low]) ;
418
419      if (hh < ll)
420        break;
421
422      ELEM_SWAP(arr[ll], arr[hh]) ;
423    }
424
425    /* Swap middle item (in position low) back into correct position */
426    ELEM_SWAP(arr[low], arr[hh]) ;
427
428    /* Re-set active partition */
429    if (hh <= median)
430      low = ll;
431    if (hh >= median)
432      high = hh - 1;
433  }
434}
435
[9499eefb]436smpl_t fvec_quadratic_peak_pos (fvec_t * x, uint_t pos) {
[5644069]437  smpl_t s0, s1, s2; uint_t x0, x2;
[acd97d1]438  if (pos == 0 || pos == x->length - 1) return pos;
[5644069]439  x0 = (pos < 1) ? pos : pos - 1;
440  x2 = (pos + 1 < x->length) ? pos + 1 : pos;
[9499eefb]441  if (x0 == pos) return (x->data[pos] <= x->data[x2]) ? pos : x2;
442  if (x2 == pos) return (x->data[pos] <= x->data[x0]) ? pos : x0;
443  s0 = x->data[x0];
444  s1 = x->data[pos];
445  s2 = x->data[x2];
446  return pos + 0.5 * (s0 - s2 ) / (s0 - 2.* s1 + s2);
447}
448
[7380327]449smpl_t fvec_quadratic_peak_mag (fvec_t *x, smpl_t pos) {
450  smpl_t x0, x1, x2;
451  uint_t index = (uint_t)(pos - .5) + 1;
452  if (pos >= x->length || pos < 0.) return 0.;
453  if ((smpl_t)index == pos) return x->data[index];
454  x0 = x->data[index - 1];
455  x1 = x->data[index];
456  x2 = x->data[index + 1];
457  return x1 - .25 * (x0 - x2) * (pos - index);
458}
459
[5c4ec3c]460uint_t fvec_peakpick(fvec_t * onset, uint_t pos) {
[8e5c051]461  uint_t tmp=0;
462  tmp = (onset->data[pos] > onset->data[pos-1]
463      &&  onset->data[pos] > onset->data[pos+1]
464      &&  onset->data[pos] > 0.);
[ade9afe]465  return tmp;
[96fb8ad]466}
467
[eb7f743]468smpl_t
469aubio_quadfrac (smpl_t s0, smpl_t s1, smpl_t s2, smpl_t pf)
470{
471  smpl_t tmp =
472      s0 + (pf / 2.) * (pf * (s0 - 2. * s1 + s2) - 3. * s0 + 4. * s1 - s2);
473  return tmp;
474}
475
476smpl_t
477aubio_freqtomidi (smpl_t freq)
478{
[5644069]479  smpl_t midi;
[037319a]480  if (freq < 2. || freq > 100000.) return 0.; // avoid nans and infs
[ade9afe]481  /* log(freq/A-2)/log(2) */
[5644069]482  midi = freq / 6.875;
[eb7f743]483  midi = LOG (midi) / 0.69314718055995;
[ade9afe]484  midi *= 12;
485  midi -= 3;
486  return midi;
[79c2e52]487}
488
[eb7f743]489smpl_t
490aubio_miditofreq (smpl_t midi)
491{
[5644069]492  smpl_t freq;
[037319a]493  if (midi > 140.) return 0.; // avoid infs
[5644069]494  freq = (midi + 3.) / 12.;
[eb7f743]495  freq = EXP (freq * 0.69314718055995);
[ade9afe]496  freq *= 6.875;
497  return freq;
[96fb8ad]498}
499
[eb7f743]500smpl_t
501aubio_bintofreq (smpl_t bin, smpl_t samplerate, smpl_t fftsize)
502{
503  smpl_t freq = samplerate / fftsize;
[c965b33]504  return freq * MAX(bin, 0);
[96fb8ad]505}
506
[eb7f743]507smpl_t
508aubio_bintomidi (smpl_t bin, smpl_t samplerate, smpl_t fftsize)
509{
510  smpl_t midi = aubio_bintofreq (bin, samplerate, fftsize);
511  return aubio_freqtomidi (midi);
[96fb8ad]512}
513
[eb7f743]514smpl_t
515aubio_freqtobin (smpl_t freq, smpl_t samplerate, smpl_t fftsize)
516{
517  smpl_t bin = fftsize / samplerate;
[c965b33]518  return MAX(freq, 0) * bin;
[79c2e52]519}
520
[eb7f743]521smpl_t
522aubio_miditobin (smpl_t midi, smpl_t samplerate, smpl_t fftsize)
523{
524  smpl_t freq = aubio_miditofreq (midi);
525  return aubio_freqtobin (freq, samplerate, fftsize);
[79c2e52]526}
527
[10a5413]528uint_t
[41f4c5b]529aubio_is_power_of_two (uint_t a)
530{
531  if ((a & (a - 1)) == 0) {
[10a5413]532    return 1;
533  } else {
[41f4c5b]534    return 0;
[10a5413]535  }
536}
537
538uint_t
[41f4c5b]539aubio_next_power_of_two (uint_t a)
540{
[7581185]541  uint_t i = 1;
542  while (i < a) i <<= 1;
543  return i;
[10a5413]544}
545
[eb7f743]546smpl_t
547aubio_db_spl (fvec_t * o)
548{
[5b41ef9]549  return 10. * LOG10 (aubio_level_lin (o));
[96fb8ad]550}
551
[eb7f743]552uint_t
553aubio_silence_detection (fvec_t * o, smpl_t threshold)
554{
555  return (aubio_db_spl (o) < threshold);
556}
[96fb8ad]557
[eb7f743]558smpl_t
559aubio_level_detection (fvec_t * o, smpl_t threshold)
560{
561  smpl_t db_spl = aubio_db_spl (o);
562  if (db_spl < threshold) {
[ade9afe]563    return 1.;
[eb7f743]564  } else {
565    return db_spl;
566  }
[96fb8ad]567}
[a0fd4e4]568
[eb7f743]569smpl_t
570aubio_zero_crossing_rate (fvec_t * input)
571{
[8e5c051]572  uint_t j;
[fff2bee]573  uint_t zcr = 0;
[eb7f743]574  for (j = 1; j < input->length; j++) {
[7e204d01]575    // previous was strictly negative
[8e5c051]576    if (input->data[j - 1] < 0.) {
[7e204d01]577      // current is positive or null
[8e5c051]578      if (input->data[j] >= 0.) {
[7e204d01]579        zcr += 1;
580      }
[eb7f743]581      // previous was positive or null
[7e204d01]582    } else {
583      // current is strictly negative
[8e5c051]584      if (input->data[j] < 0.) {
[fff2bee]585        zcr += 1;
586      }
587    }
588  }
[eb7f743]589  return zcr / (smpl_t) input->length;
[fff2bee]590}
591
[eb7f743]592void
593aubio_autocorr (fvec_t * input, fvec_t * output)
594{
[8e5c051]595  uint_t i, j, length = input->length;
[eb7f743]596  smpl_t *data, *acf;
597  smpl_t tmp = 0;
[8e5c051]598  data = input->data;
599  acf = output->data;
600  for (i = 0; i < length; i++) {
601    tmp = 0.;
602    for (j = i; j < length; j++) {
603      tmp += data[j - i] * data[j];
[ade9afe]604    }
[8e5c051]605    acf[i] = tmp / (smpl_t) (length - i);
[ade9afe]606  }
[a0fd4e4]607}
608
[eb7f743]609void
610aubio_cleanup (void)
611{
[729a3c0]612#ifdef HAVE_FFTW3F
[eb7f743]613  fftwf_cleanup ();
[729a3c0]614#else
615#ifdef HAVE_FFTW3
616  fftw_cleanup ();
[714380d]617#endif
618#endif
619}
Note: See TracBrowser for help on using the repository browser.