8218f1cf6887aa52e5ef65dcd377043492cd515c
[aubio.git] / tests / src / test-filterbank_mel.c
1 #include <stdio.h>
2 #include <aubio.h>
3
4 int
5 main (void)
6 {
7   /* allocate some memory */
8   uint_t win_s = 512;           /* fft size */
9   uint_t channels = 2;          /* number of channel */
10   uint_t n_filters = 40;        /* number of filters */
11   cvec_t *in = new_cvec (win_s, channels);      /* input buffer */
12   fvec_t *out = new_fvec (win_s, channels);     /* input buffer */
13   fvec_t *coeffs = NULL;
14   smpl_t samplerate = 16000.;
15
16   /* allocate fft and other memory space */
17   aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);
18
19   /* assign Mel-frequency coefficients */
20   aubio_filterbank_set_mel_coeffs_slaney (o, samplerate);
21
22   coeffs = aubio_filterbank_get_coeffs (o);
23   if (coeffs == NULL) {
24     return -1;
25   }
26
27   //fvec_print (coeffs);
28
29   //fprintf(stderr, "%f\n", fvec_sum(coeffs));
30
31   aubio_filterbank_do (o, in, out);
32
33   del_aubio_filterbank (o);
34   del_cvec (in);
35   del_fvec (out);
36   aubio_cleanup ();
37
38   return 0;
39 }