ref: 8f68dfbce6a384264ae9121a30aa359fc7c0fcd8
parent: b8c0685e23d0f31c8796ef4958bb167e55552216
author: Paul Brossier <piem@piem.org>
date: Sat Mar 2 17:54:04 EST 2013
tests/src/spectral/: improve test examples
--- a/tests/src/spectral/test-filterbank.c
+++ b/tests/src/spectral/test-filterbank.c
@@ -3,17 +3,14 @@
#include <stdio.h>
#include <aubio.h>
-int
-main (void)
-{
- /* allocate some memory */
- uint_t win_s = 1024; /* window size */
- uint_t n_filters = 13; /* number of filters */
- cvec_t *in = new_cvec (win_s); /* input buffer */
- fvec_t *out = new_fvec (win_s); /* input buffer */
+int main (void) {
+ uint_t win_s = 1024; // window size
+ uint_t n_filters = 13; // number of filters
+ cvec_t *in = new_cvec (win_s); // input buffer
+ fvec_t *out = new_fvec (win_s); // vector output */
fmat_t *coeffs = NULL;
- /* allocate fft and other memory space */
+ // create filterbank
aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);
coeffs = aubio_filterbank_get_coeffs (o);
--- a/tests/src/spectral/test-filterbank_mel.c
+++ b/tests/src/spectral/test-filterbank_mel.c
@@ -7,10 +7,10 @@
main (void)
{
/* allocate some memory */
- uint_t win_s = 512; /* fft size */
- uint_t n_filters = 40; /* number of filters */
- cvec_t *in = new_cvec (win_s); /* input buffer */
- fvec_t *out = new_fvec (win_s); /* input buffer */
+ uint_t win_s = 512; // fft size
+ uint_t n_filters = 40; // number of filters
+ cvec_t *in_spec = new_cvec (win_s); // input buffer */
+ fvec_t *out_filters = new_fvec (n_filters); // output coeffs */
fmat_t *coeffs = NULL;
smpl_t samplerate = 16000.;
@@ -21,19 +21,19 @@
aubio_filterbank_set_mel_coeffs_slaney (o, samplerate);
coeffs = aubio_filterbank_get_coeffs (o);
- if (coeffs == NULL) {
- return -1;
- }
- //fmat_print (coeffs);
+ fmat_print (coeffs);
//fprintf(stderr, "%f\n", fvec_sum(coeffs));
- aubio_filterbank_do (o, in, out);
+ aubio_filterbank_do (o, in_spec, out_filters);
+ fvec_print(in_spec);
+ fvec_print(out_filters);
+
del_aubio_filterbank (o);
- del_cvec (in);
- del_fvec (out);
+ del_cvec (in_spec);
+ del_fvec (out_filters);
aubio_cleanup ();
return 0;