source: tests/src/spectral/test-dct.c @ 37c7e61

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/timestretchfix/ffmpeg5
Last change on this file since 37c7e61 was 92c85b12, checked in by Paul Brossier <piem@piem.org>, 6 years ago

[tests] fail dct tests if reconstruction failed

  • Property mode set to 100644
File size: 1.1 KB
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);
[804c8eb]12  aubio_dct_t * tmp;
13
14  if (new_aubio_dct(0)) return 1;
[60583a3]15
16  fvec_t * in = new_fvec (win_s); // input buffer
17  fvec_t * dctout = new_fvec (win_s); // output buffer
[52c1de9]18  fvec_t * out = new_fvec (win_s); // input buffer
[60583a3]19
[804c8eb]20  if ((tmp = new_aubio_dct(1)) == 0) return 1;
[d050d02]21  //aubio_dct_do(tmp, dctout, out);
22  //aubio_dct_rdo(tmp, dctout, out);
[804c8eb]23  del_aubio_dct(tmp);
24
[60583a3]25  if (!dct || !in || !dctout) {
26    return_code = 1;
27    return return_code;
28  }
29
30  in->data[0] = 1.;
31  for (i = 0; i < n_iters; i++) {
32    aubio_dct_do (dct, in, dctout);
[52c1de9]33    aubio_dct_rdo (dct, dctout, out);
34    for (j = 0; j < in->length; j++) {
[92c85b12]35      return_code += (fabsf(in->data[j] - out->data[j]) > 10.e-4);
[52c1de9]36    }
[60583a3]37  }
[52c1de9]38
[60583a3]39  fvec_print(in);
[52c1de9]40  fvec_print(dctout);
41  fvec_print(out);
42
[60583a3]43  del_fvec(dctout);
44  del_fvec(in);
[52c1de9]45  del_fvec(out);
[60583a3]46  del_aubio_dct(dct);
[52c1de9]47
[60583a3]48  return return_code;
49}
Note: See TracBrowser for help on using the repository browser.