source: tests/src/spectral/test-dct.c @ 81abf91

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since 81abf91 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
RevLine 
[52c1de9]1#include <math.h>
2#include "aubio.h"
3#include "utils_tests.h"
[60583a3]4
5int main (void)
6{
7  int return_code = 0;
8  uint_t win_s = 32; // window size
[52c1de9]9  uint_t i, j, n_iters = 10; // number of iterations
[60583a3]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
[52c1de9]15  fvec_t * out = new_fvec (win_s); // input buffer
[60583a3]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);
[52c1de9]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    }
[60583a3]31  }
[52c1de9]32
[60583a3]33  fvec_print(in);
[52c1de9]34  fvec_print(dctout);
35  fvec_print(out);
36
[60583a3]37  del_fvec(dctout);
38  del_fvec(in);
[52c1de9]39  del_fvec(out);
[60583a3]40  del_aubio_dct(dct);
[52c1de9]41
[60583a3]42  return return_code;
43}
Note: See TracBrowser for help on using the repository browser.