source: tests/src/spectral/test-dct.c @ 3aac194

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since 3aac194 was 52c1de9, checked in by Paul Brossier <piem@piem.org>, 6 years ago

tests/src/spectral/test-dct.c: check reconstruction works

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