source: tests/src/spectral/test-dct.c @ 7df72ac

Last change on this file since 7df72ac was 7df72ac, checked in by Paul Brossier <piem@piem.org>, 6 months ago

[tests] use ABS in test-dct

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#include <math.h>
2#include "aubio.h"
3#include "aubio_priv.h"
4#include "utils_tests.h"
5
6int main (void)
7{
8  int return_code = 0;
9  uint_t win_s = 32; // window size
10  uint_t i, j, n_iters = 10; // number of iterations
11  // create dct object
12  aubio_dct_t * dct = new_aubio_dct(win_s);
13  aubio_dct_t * tmp;
14
15  if (new_aubio_dct(0)) return 1;
16
17  fvec_t * in = new_fvec (win_s); // input buffer
18  fvec_t * dctout = new_fvec (win_s); // output buffer
19  fvec_t * out = new_fvec (win_s); // input buffer
20
21  if ((tmp = new_aubio_dct(1)) == 0) return 1;
22  //aubio_dct_do(tmp, dctout, out);
23  //aubio_dct_rdo(tmp, dctout, out);
24  del_aubio_dct(tmp);
25
26  if (!dct || !in || !dctout) {
27    return_code = 1;
28    return return_code;
29  }
30
31  in->data[0] = 1.;
32  for (i = 0; i < n_iters; i++) {
33    aubio_dct_do (dct, in, dctout);
34    aubio_dct_rdo (dct, dctout, out);
35    for (j = 0; j < in->length; j++) {
36      return_code += (ABS(in->data[j] - out->data[j]) > 10.e-4);
37    }
38  }
39
40  fvec_print(in);
41  fvec_print(dctout);
42  fvec_print(out);
43
44  del_fvec(dctout);
45  del_fvec(in);
46  del_fvec(out);
47  del_aubio_dct(dct);
48
49  return return_code;
50}
Note: See TracBrowser for help on using the repository browser.