add tests for most function
authorPaul Brossier <piem@altern.org>
Sat, 22 Jul 2006 09:48:08 +0000 (09:48 +0000)
committerPaul Brossier <piem@altern.org>
Sat, 22 Jul 2006 09:48:08 +0000 (09:48 +0000)
add tests for most function

19 files changed:
examples/tests/Makefile.am
examples/tests/test-beattracking.c [new file with mode: 0644]
examples/tests/test-biquad.c [new file with mode: 0644]
examples/tests/test-filter.c [new file with mode: 0644]
examples/tests/test-hist.c [new file with mode: 0644]
examples/tests/test-onset.c [new file with mode: 0644]
examples/tests/test-onsetdetection.c [new file with mode: 0644]
examples/tests/test-peakpick.c [new file with mode: 0644]
examples/tests/test-pitchdetection.c [new file with mode: 0644]
examples/tests/test-pitchfcomb.c [new file with mode: 0644]
examples/tests/test-pitchmcomb.c [new file with mode: 0644]
examples/tests/test-pitchschmitt.c [new file with mode: 0644]
examples/tests/test-pitchyin.c [new file with mode: 0644]
examples/tests/test-pitchyinfft.c [new file with mode: 0644]
examples/tests/test-resample.c [new file with mode: 0644]
examples/tests/test-sample.c [new file with mode: 0644]
examples/tests/test-scale.c [new file with mode: 0644]
examples/tests/test-tempo.c [new file with mode: 0644]
examples/tests/test-window.c [new file with mode: 0644]

index 430fed4dcfc104a3c53472a2cad8cb2149422477..a7ba51c1c30e2427e2ab2f52d5300adbf43eaf45 100644 (file)
@@ -1,9 +1,36 @@
-AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/ext @LASH_CFLAGS@
-AM_LDFLAGS = -L$(top_builddir)/src -L$(top_builddir)/ext -laubioext -laubio @JACK_LIBS@ @LASH_LIBS@
+AM_CFLAGS = -I$(top_srcdir)/src
+AM_LDFLAGS = -L$(top_builddir)/src -laubio @FFTWLIB_LIBS@
+
+test_phasevoc_jack_CFLAGS = -I$(top_builddir)/ext @JACK_CFLAGS@
+test_phasevoc_jack_LDADD  = -laubioext -L$(top_builddir)/ext @JACK_LIBS@ 
 
 bin_PROGRAMS = \
        test-fft \
        test-mfft \
+       test-hist \
+       test-scale \
+       test-sample \
+       test-window \
+       test-filter \
+       test-biquad \
+       test-resample \
+       test-peakpick \
        test-phasevoc \
        test-phasevoc-jack \
+       test-onsetdetection \
+       test-pitchyin \
+       test-pitchyinfft \
+       test-pitchschmitt \
+       test-pitchfcomb \
+       test-pitchmcomb \
+       test-pitchdetection \
+       test-beattracking \
+       test-onset \
+       test-tempo \
        test-tss
+
+run-tests: $(bin_PROGRAMS)
+       for i in $(bin_PROGRAMS); do echo $$i; time ./$$i 2>&1 > /dev/null; echo $$?; done
+
+run-valgrind-tests: $(bin_PROGRAMS)
+       for i in $(bin_PROGRAMS); do echo $$i; valgrind .libs/lt-$$i 2>&1 | grep ERROR\ SUMMARY -A4; echo $$?; done
diff --git a/examples/tests/test-beattracking.c b/examples/tests/test-beattracking.c
new file mode 100644 (file)
index 0000000..7578469
--- /dev/null
@@ -0,0 +1,27 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
+        fvec_t * out      = new_fvec (win_s/4, channels);     /* input buffer */
+  
+        /* allocate fft and other memory space */
+        aubio_beattracking_t * tempo  = new_aubio_beattracking(win_s, channels);
+
+        uint_t i = 0;
+
+        while (i < 10) {
+          aubio_beattracking_do(tempo,in,out);
+          i++;
+        };
+
+        del_aubio_beattracking(tempo);
+        del_fvec(in);
+        del_fvec(out);
+        aubio_cleanup();
+
+        return 0;
+}
+
diff --git a/examples/tests/test-biquad.c b/examples/tests/test-biquad.c
new file mode 100644 (file)
index 0000000..319e230
--- /dev/null
@@ -0,0 +1,16 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
+        aubio_biquad_t * o = new_aubio_biquad(0.3,0.2,0.1,0.2,0.3);
+
+        aubio_biquad_do_filtfilt(o,in,in);
+        aubio_biquad_do(o,in);
+
+        del_aubio_biquad(o);
+        del_fvec(in);
+        return 0;
+}
diff --git a/examples/tests/test-filter.c b/examples/tests/test-filter.c
new file mode 100644 (file)
index 0000000..37dd8d0
--- /dev/null
@@ -0,0 +1,23 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
+        fvec_t * out      = new_fvec (win_s, channels);     /* input buffer */
+  
+        /* allocate fft and other memory space */
+        aubio_filter_t * o = new_aubio_cdsgn_filter(44100);
+
+        aubio_filter_do(o,in);
+        aubio_filter_do_outplace(o,in,out);
+        aubio_filter_do_filtfilt(o,in,out);
+
+        del_aubio_filter(o);
+        del_fvec(in);
+        del_fvec(out);
+        aubio_cleanup();
+
+        return 0;
+}
diff --git a/examples/tests/test-hist.c b/examples/tests/test-hist.c
new file mode 100644 (file)
index 0000000..e739b3e
--- /dev/null
@@ -0,0 +1,38 @@
+#include <aubio.h>
+#include <stdlib.h>
+
+void print_array(fvec_t *f);
+void print_array(fvec_t *f){
+  uint i,j;
+  for (i=0;i<f->channels;i++){
+    for (j=0;j<f->length;j++){
+      printf("%f, ", f->data[i][j]); 
+    }
+    printf(";\n"); 
+  }
+}
+
+int main( int argc, char** argv )
+{
+  uint_t length;
+  for (length = 1; length < 10; length ++ ) {
+    fvec_t *t = new_fvec(length,5);
+    aubio_hist_t *o = new_aubio_hist(0, 1, length, 5);
+    aubio_window(t->data[0],t->length,aubio_win_hanning);
+    aubio_window(t->data[1],t->length,aubio_win_hanningz);
+    aubio_window(t->data[2],t->length,aubio_win_blackman);
+    aubio_window(t->data[3],t->length,aubio_win_blackman_harris);
+    aubio_window(t->data[4],t->length,aubio_win_hamming);
+    print_array(t);
+    aubio_hist_do(o,t);
+    print_array(t);
+    aubio_hist_do_notnull(o,t);
+    print_array(t);
+    aubio_hist_dyn_notnull(o,t);
+    print_array(t);
+    del_aubio_hist(o);
+    del_fvec(t);
+  }
+  return 0;
+}
+
diff --git a/examples/tests/test-onset.c b/examples/tests/test-onset.c
new file mode 100644 (file)
index 0000000..c26ccdc
--- /dev/null
@@ -0,0 +1,23 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s/4, channels); /* input buffer */
+        fvec_t * out      = new_fvec (2, channels);     /* input buffer */
+        aubio_onset_t * onset  = new_aubio_onset(aubio_onset_complex, win_s, win_s/4, channels);
+        uint_t i = 0;
+
+        while (i < 10) {
+          aubio_onset(onset,in,out);
+          i++;
+        };
+
+        del_aubio_onset(onset);
+        del_fvec(in);
+        del_fvec(out);
+        aubio_cleanup();
+
+        return 0;
+}
diff --git a/examples/tests/test-onsetdetection.c b/examples/tests/test-onsetdetection.c
new file mode 100644 (file)
index 0000000..0efa363
--- /dev/null
@@ -0,0 +1,54 @@
+
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        cvec_t * in       = new_cvec (win_s, channels); /* input buffer */
+        fvec_t * out      = new_fvec (1, channels);     /* input buffer */
+  
+        /* allocate fft and other memory space */
+        aubio_onsetdetection_t * o = 
+          new_aubio_onsetdetection(aubio_onset_energy, win_s, channels);
+        aubio_onsetdetection(o,in,out);
+        aubio_onsetdetection_energy(o,in,out);
+        del_aubio_onsetdetection(o);
+
+        o = new_aubio_onsetdetection(aubio_onset_specdiff, win_s, channels);
+        aubio_onsetdetection(o,in,out);
+        aubio_onsetdetection_specdiff(o,in,out);
+        del_aubio_onsetdetection(o);
+
+        o = new_aubio_onsetdetection(aubio_onset_hfc, win_s, channels);
+        aubio_onsetdetection(o,in,out);
+        aubio_onsetdetection_hfc(o,in,out);
+        del_aubio_onsetdetection(o);
+
+        o = new_aubio_onsetdetection(aubio_onset_complex, win_s, channels);
+        aubio_onsetdetection(o,in,out);
+        aubio_onsetdetection_complex(o,in,out);
+        del_aubio_onsetdetection(o);
+
+        o = new_aubio_onsetdetection(aubio_onset_phase, win_s, channels);
+        aubio_onsetdetection(o,in,out);
+        aubio_onsetdetection_phase(o,in,out);
+        del_aubio_onsetdetection(o);
+
+        o = new_aubio_onsetdetection(aubio_onset_kl, win_s, channels);
+        aubio_onsetdetection(o,in,out);
+        aubio_onsetdetection_kl(o,in,out);
+        del_aubio_onsetdetection(o);
+
+        o = new_aubio_onsetdetection(aubio_onset_mkl, win_s, channels);
+        aubio_onsetdetection(o,in,out);
+        aubio_onsetdetection_mkl(o,in,out);
+        del_aubio_onsetdetection(o);
+
+        del_cvec(in);
+        del_fvec(out);
+        aubio_cleanup();
+
+        return 0;
+}
+
diff --git a/examples/tests/test-peakpick.c b/examples/tests/test-peakpick.c
new file mode 100644 (file)
index 0000000..736f394
--- /dev/null
@@ -0,0 +1,19 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
+        aubio_pickpeak_t * o = new_aubio_peakpicker(0.3);
+
+        aubio_peakpick_pimrt(in,o);
+        aubio_peakpick_pimrt(in,o);
+        aubio_peakpick_pimrt(in,o);
+        aubio_peakpick_pimrt(in,o);
+
+        del_aubio_peakpicker(o);
+        del_fvec(in);
+        return 0;
+}
+
diff --git a/examples/tests/test-pitchdetection.c b/examples/tests/test-pitchdetection.c
new file mode 100644 (file)
index 0000000..71f8120
--- /dev/null
@@ -0,0 +1,27 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t hop_s      = win_s/4;                    /* hop size */
+        uint_t samplerate = 44100;                      /* samplerate */
+        uint_t channels   = 1;                          /* number of channel */
+        aubio_pitchdetection_mode mode = aubio_pitchm_freq;
+        aubio_pitchdetection_type type = aubio_pitch_yinfft;
+        fvec_t * in       = new_fvec (hop_s, channels); /* input buffer */
+        aubio_pitchdetection_t * o  = new_aubio_pitchdetection(
+          win_s, hop_s, channels, samplerate, type, mode
+          );
+        uint_t i = 0;
+
+        while (i < 1000) {
+          aubio_pitchdetection(o,in);
+          i++;
+        };
+
+        del_aubio_pitchdetection(o);
+        del_fvec(in);
+        aubio_cleanup();
+
+        return 0;
+}
diff --git a/examples/tests/test-pitchfcomb.c b/examples/tests/test-pitchfcomb.c
new file mode 100644 (file)
index 0000000..be59ec7
--- /dev/null
@@ -0,0 +1,25 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t hop_s      = win_s/4;                    /* hop size */
+        uint_t samplerate = 44100;                      /* samplerate */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (hop_s, channels); /* input buffer */
+        aubio_pitchfcomb_t * o  = new_aubio_pitchfcomb (
+          win_s, hop_s, samplerate
+          );
+        uint_t i = 0;
+
+        while (i < 1000) {
+          aubio_pitchfcomb_detect(o,in);
+          i++;
+        };
+
+        del_aubio_pitchfcomb(o);
+        del_fvec(in);
+        aubio_cleanup();
+
+        return 0;
+}
diff --git a/examples/tests/test-pitchmcomb.c b/examples/tests/test-pitchmcomb.c
new file mode 100644 (file)
index 0000000..a05ab7a
--- /dev/null
@@ -0,0 +1,24 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t hop_s      = win_s/4;                    /* hop size */
+        uint_t samplerate = 44100;
+        uint_t channels   = 1;                          /* number of channel */
+        cvec_t * in       = new_cvec (win_s, channels); /* input buffer */
+        aubio_pitchmcomb_t * o  = new_aubio_pitchmcomb(
+          win_s, hop_s, channels, samplerate );
+        uint_t i = 0;
+
+        while (i < 1000) {
+          aubio_pitchmcomb_detect (o,in);
+          i++;
+        };
+
+        del_aubio_pitchmcomb(o);
+        del_cvec(in);
+        aubio_cleanup();
+
+        return 0;
+}
diff --git a/examples/tests/test-pitchschmitt.c b/examples/tests/test-pitchschmitt.c
new file mode 100644 (file)
index 0000000..8a61c5c
--- /dev/null
@@ -0,0 +1,23 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t samplerate = 44100;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s, 1); /* input buffer */
+        aubio_pitchschmitt_t * o  = new_aubio_pitchschmitt(
+          win_s, samplerate );
+        uint_t i = 0;
+
+        while (i < 1000) {
+          aubio_pitchschmitt_detect (o,in);
+          i++;
+        };
+
+        del_aubio_pitchschmitt(o);
+        del_fvec(in);
+        aubio_cleanup();
+
+        return 0;
+}
+
diff --git a/examples/tests/test-pitchyin.c b/examples/tests/test-pitchyin.c
new file mode 100644 (file)
index 0000000..5766a71
--- /dev/null
@@ -0,0 +1,24 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
+        fvec_t * out      = new_fvec (win_s/2, channels); /* input buffer */
+        uint_t i = 0;
+
+        while (i < 10) {
+          aubio_pitchyin_diff   (in,out);
+          aubio_pitchyin_getcum (out);
+          aubio_pitchyin_getpitch (out);
+          aubio_pitchyin_getpitchfast (in,out,0.2);
+          i++;
+        };
+
+        del_fvec(in);
+        del_fvec(out);
+        aubio_cleanup();
+
+        return 0;
+}
diff --git a/examples/tests/test-pitchyinfft.c b/examples/tests/test-pitchyinfft.c
new file mode 100644 (file)
index 0000000..dfb8fc6
--- /dev/null
@@ -0,0 +1,22 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
+        aubio_pitchyinfft_t * o  = new_aubio_pitchyinfft(win_s);
+        uint_t i = 0;
+
+        while (i < 10) {
+          aubio_pitchyinfft_detect (o,in,0.2);
+          i++;
+        };
+
+        del_aubio_pitchyinfft(o);
+        del_fvec(in);
+        aubio_cleanup();
+
+        return 0;
+}
+
diff --git a/examples/tests/test-resample.c b/examples/tests/test-resample.c
new file mode 100644 (file)
index 0000000..48a5055
--- /dev/null
@@ -0,0 +1,23 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        smpl_t ratio      = 0.5;
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
+        fvec_t * out      = new_fvec ((uint_t)(win_s*ratio), channels);     /* input buffer */
+        aubio_resampler_t * o  = new_aubio_resampler(0.5, 0);
+        uint_t i = 0;
+
+        while (i < 100) {
+          aubio_resampler_process(o,in,out);
+          i++;
+        };
+
+        del_aubio_resampler(o);
+        del_fvec(in);
+        del_fvec(out);
+
+        return 0;
+}
diff --git a/examples/tests/test-sample.c b/examples/tests/test-sample.c
new file mode 100644 (file)
index 0000000..d31c1d2
--- /dev/null
@@ -0,0 +1,14 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
+        cvec_t * sp       = new_cvec (win_s, channels); /* input buffer */
+        del_fvec(in);
+        del_cvec(sp);
+
+        return 0;
+}
+
diff --git a/examples/tests/test-scale.c b/examples/tests/test-scale.c
new file mode 100644 (file)
index 0000000..c35111b
--- /dev/null
@@ -0,0 +1,21 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
+        aubio_scale_t * o = new_aubio_scale(0,1,2,3);
+        aubio_scale_set(o,0,1,2,3);
+        uint_t i = 0;
+
+        while (i < 1000) {
+          aubio_scale_do(o,in);
+          i++;
+        };
+
+        del_aubio_scale(o);
+        del_fvec(in);
+
+        return 0;
+}
diff --git a/examples/tests/test-tempo.c b/examples/tests/test-tempo.c
new file mode 100644 (file)
index 0000000..c7a9bd0
--- /dev/null
@@ -0,0 +1,23 @@
+#include <aubio.h>
+
+int main(){
+        /* allocate some memory */
+        uint_t win_s      = 1024;                       /* window size */
+        uint_t channels   = 1;                          /* number of channel */
+        fvec_t * in       = new_fvec (win_s, channels); /* input buffer */
+        fvec_t * out      = new_fvec (2, channels);     /* input buffer */
+        aubio_tempo_t * o  = new_aubio_tempo(aubio_onset_complex, win_s, win_s/4, channels);
+        uint_t i = 0;
+
+        while (i < 1000) {
+          aubio_tempo(o,in,out);
+          i++;
+        };
+
+        del_aubio_tempo(o);
+        del_fvec(in);
+        del_fvec(out);
+        aubio_cleanup();
+
+        return 0;
+}
diff --git a/examples/tests/test-window.c b/examples/tests/test-window.c
new file mode 100644 (file)
index 0000000..6201144
--- /dev/null
@@ -0,0 +1,37 @@
+#include <aubio.h>
+#include <stdlib.h>
+
+void print_array(fvec_t *f);
+void print_array(fvec_t *f){
+  uint i,j;
+  for (i=0;i<f->channels;i++)
+  {
+    for (j=0;j<f->length;j++)
+    {
+      printf("%1.3e, ", f->data[i][j]); 
+    }
+    printf(";\n"); 
+  }
+}
+
+int main( int argc, char** argv )
+{
+  uint_t length;
+  for (length = 2; length <= 5; length++)
+  {
+    fvec_t *t = new_fvec(length,9);
+    aubio_window(t->data[0],t->length,aubio_win_rectangle);
+    aubio_window(t->data[1],t->length,aubio_win_hamming);
+    aubio_window(t->data[2],t->length,aubio_win_hanning);
+    aubio_window(t->data[3],t->length,aubio_win_hanningz);
+    aubio_window(t->data[4],t->length,aubio_win_blackman);
+    aubio_window(t->data[5],t->length,aubio_win_blackman_harris);
+    aubio_window(t->data[6],t->length,aubio_win_gaussian);
+    aubio_window(t->data[7],t->length,aubio_win_welch);
+    aubio_window(t->data[8],t->length,aubio_win_parzen);
+    print_array(t);
+    del_fvec(t);
+  }
+  return 0;
+}
+