From 8f68dfbce6a384264ae9121a30aa359fc7c0fcd8 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 2 Mar 2013 22:54:04 -0500 Subject: [PATCH] tests/src/spectral/: improve test examples --- tests/src/spectral/test-filterbank.c | 15 ++++++--------- tests/src/spectral/test-filterbank_mel.c | 22 +++++++++++----------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/tests/src/spectral/test-filterbank.c b/tests/src/spectral/test-filterbank.c index 4ab3fcf7..9b1db722 100644 --- a/tests/src/spectral/test-filterbank.c +++ b/tests/src/spectral/test-filterbank.c @@ -3,17 +3,14 @@ #include #include -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); diff --git a/tests/src/spectral/test-filterbank_mel.c b/tests/src/spectral/test-filterbank_mel.c index 79001dfd..1d0caf09 100644 --- a/tests/src/spectral/test-filterbank_mel.c +++ b/tests/src/spectral/test-filterbank_mel.c @@ -7,10 +7,10 @@ int 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 @@ main (void) 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; -- 2.26.2