test-filterbank.c: add trivial test for filterbank object
authorPaul Brossier <piem@piem.org>
Wed, 16 Sep 2009 23:37:03 +0000 (01:37 +0200)
committerPaul Brossier <piem@piem.org>
Wed, 16 Sep 2009 23:37:03 +0000 (01:37 +0200)
tests/src/Makefile.am
tests/src/test-filterbank.c [new file with mode: 0644]

index b2bbf8a6d41751c99f6c6d7340d1a5cabeac7f78..205af9e58208ea9a22caf7ee064f188079853a1e 100644 (file)
@@ -16,6 +16,7 @@ bin_PROGRAMS = \
        test-resample \
        test-peakpick \
        test-phasevoc \
+  test-filterbank \
        test-phasevoc-jack \
        test-onsetdetection \
        test-pitchyin \
diff --git a/tests/src/test-filterbank.c b/tests/src/test-filterbank.c
new file mode 100644 (file)
index 0000000..635d2fb
--- /dev/null
@@ -0,0 +1,40 @@
+#include <aubio.h>
+
+int
+main (void)
+{
+  /* allocate some memory */
+  uint_t win_s = 1024;          /* window size */
+  uint_t channels = 2;          /* number of channel */
+  uint_t n_filters = 13;        /* number of filters */
+  cvec_t *in = new_cvec (win_s, channels);      /* input buffer */
+  fvec_t *out = new_fvec (win_s, channels);     /* input buffer */
+  fvec_t *coeffs = NULL;
+
+  /* allocate fft and other memory space */
+  aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s);
+
+  coeffs = aubio_filterbank_get_coeffs (o);
+  if (coeffs == NULL) {
+    return -1;
+  }
+
+  if (vec_max (coeffs) != 0.) {
+    return -1;
+  }
+
+  if (vec_min (coeffs) != 0.) {
+    return -1;
+  }
+
+  // fvec_print (coeffs);
+
+  aubio_filterbank_do (o, in, out);
+
+  del_aubio_filterbank (o);
+  del_cvec (in);
+  del_fvec (out);
+  aubio_cleanup ();
+
+  return 0;
+}