source: tests/src/spectral/test-filterbank.c

Last change on this file was 1029ac7, checked in by Paul Brossier <piem@piem.org>, 5 years ago

[tests] check creating filterbank with wrong parameters returns null

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[addc9ec]1#include <aubio.h>
2
[158e031]3int main (void)
[6938a20]4{
[8f68dfb]5  uint_t win_s = 1024; // window size
6  uint_t n_filters = 13; // number of filters
[addc9ec]7
[6938a20]8  cvec_t *in_spec = new_cvec (win_s); // input vector of samples
9  fvec_t *out_filters = new_fvec (n_filters); // per-band outputs
10
[1029ac7]11  if (new_aubio_filterbank(0, win_s)) return 1;
12  if (new_aubio_filterbank(n_filters, 0)) return 1;
13
[6938a20]14  // create filterbank object
[addc9ec]15  aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);
16
[be8b18b]17  smpl_t power = aubio_filterbank_get_power(o);
18  smpl_t norm = aubio_filterbank_get_norm(o);
19  if (aubio_filterbank_set_power(o, power)) {
20    return 1;
21  }
22  if (aubio_filterbank_set_norm(o, norm)) {
23    return 1;
24  }
25
[845c435]26  // apply filterbank ten times
27  uint_t n = 10;
28  while (n) {
29    aubio_filterbank_do (o, in_spec, out_filters);
30    n--;
31  }
[addc9ec]32
[845c435]33  // print out filterbank coeffs
34  fmat_t *coeffs; // pointer to the coefficients
35  coeffs = aubio_filterbank_get_coeffs (o);
36  fmat_print (coeffs);
[addc9ec]37
[a4c1e86]38  aubio_filterbank_set_coeffs (o, coeffs);
39  coeffs = aubio_filterbank_get_coeffs (o);
40  fmat_print (coeffs);
41
[845c435]42  //fvec_print (out_filters);
[addc9ec]43
[845c435]44  // clean up
[addc9ec]45  del_aubio_filterbank (o);
[6938a20]46  del_cvec (in_spec);
47  del_fvec (out_filters);
[addc9ec]48  aubio_cleanup ();
49
50  return 0;
51}
Note: See TracBrowser for help on using the repository browser.