From: Paul Brossier Date: Tue, 30 Oct 2007 02:00:22 +0000 (+0100) Subject: move python/tests to tests/python, examples/tests to tests/src, add .bzrignore X-Git-Tag: 0.4.0-beta1~1037 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=de2a8af8ce5caf1a774185841fcdf7870039881a;p=aubio.git move python/tests to tests/python, examples/tests to tests/src, add .bzrignore --- diff --git a/.bzrignore b/.bzrignore new file mode 100644 index 00000000..4fb10de9 --- /dev/null +++ b/.bzrignore @@ -0,0 +1,25 @@ +*/Makefile.in +*/*/Makefile.in +*/*/*/Makefile.in +*/Makefile +*/*/Makefile +*/*/*/Makefile +*/.deps +*/*/.deps +*/*/*/.deps +*/.libs +*/*/.libs +*/*/*/.libs +*/*.lo +*/*/*.lo +*/*/*/*.lo +*/*.la +plugins/puredata/aubio.pd_linux +doc/aubiocut.1 +doc/aubionotes.1 +doc/aubioonset.1 +doc/aubiopitch.1 +doc/aubiotrack.1 +src/config.h +src/config.h.in +src/stamp-h1 diff --git a/configure.ac b/configure.ac index 1d0ab91e..93ef03a0 100644 --- a/configure.ac +++ b/configure.ac @@ -240,7 +240,8 @@ AC_OUTPUT([ src/Makefile ext/Makefile examples/Makefile - examples/tests/Makefile + tests/Makefile + tests/src/Makefile sounds/Makefile swig/Makefile python/Makefile diff --git a/examples/Makefile.am b/examples/Makefile.am index 94a20f11..a09dfc60 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,7 +1,3 @@ -if COMPILE_TESTS -SUBDIRS = tests -endif - # global flags AM_CFLAGS = -DAUBIO_PREFIX=\"$(prefix)\" -I$(top_srcdir)/src -I$(top_srcdir)/ext @AUBIO_CFLAGS@ @LASH_CFLAGS@ @FFTWLIB_CFLAGS@ AM_LDFLAGS = -L$(top_builddir)/src -L$(top_builddir)/ext -laubioext -laubio @LASH_LIBS@ diff --git a/examples/tests/Makefile.am b/examples/tests/Makefile.am deleted file mode 100644 index 7c44abfb..00000000 --- a/examples/tests/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -AM_CFLAGS = -I$(top_srcdir)/src -AM_LDFLAGS = -L$(top_builddir)/src -laubio @FFTWLIB_LIBS@ - -test_phasevoc_jack_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/ext @JACK_CFLAGS@ -test_phasevoc_jack_LDADD = $(AM_LDFLAGS) -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) 2>&1; 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 deleted file mode 100644 index 2812a3b0..00000000 --- a/examples/tests/test-beattracking.c +++ /dev/null @@ -1,39 +0,0 @@ -#include - -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; - - smpl_t curtempo, curtempoconf; - - while (i < 10) { - aubio_beattracking_do(tempo,in,out); - curtempo = aubio_beattracking_get_bpm(tempo); - if (curtempo != 0.) { - fprintf(stdout,"%f\n",curtempo); - return 1; - } - curtempoconf = aubio_beattracking_get_confidence(tempo); - if (curtempoconf != 0.) { - fprintf(stdout,"%f\n",curtempo); - return 1; - } - 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 deleted file mode 100644 index 319e2307..00000000 --- a/examples/tests/test-biquad.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -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-fft.c b/examples/tests/test-fft.c deleted file mode 100644 index 17adeb58..00000000 --- a/examples/tests/test-fft.c +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include -#include - -#define NEW_ARRAY(_t,_n) (_t*)malloc((_n)*sizeof(_t)) - - -int main(){ - uint_t i,j; - /* 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 * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ - fvec_t * out = new_fvec (win_s, channels); /* output buffer */ - - /* allocate fft and other memory space */ - aubio_fft_t * fft = new_aubio_fft(win_s); /* fft interface */ - smpl_t * w = NEW_ARRAY(smpl_t,win_s); /* window */ - /* complex spectral data */ - fft_data_t ** spec = NEW_ARRAY(fft_data_t*,channels); - for (i=0; i < channels; i++) - spec[i] = NEW_ARRAY(fft_data_t,win_s); - /* initialize the window (see mathutils.c) */ - aubio_window(w,win_s,aubio_win_hanningz); - - /* fill input with some data */ - in->data[0][win_s/2] = 1; - - /* execute stft */ - for (i=0; i < channels; i++) { - aubio_fft_do (fft,in->data[i],spec[i],win_s); - /* put norm and phase into fftgrain */ - aubio_fft_getnorm(fftgrain->norm[i], spec[i], win_s/2+1); - aubio_fft_getphas(fftgrain->phas[i], spec[i], win_s/2+1); - } - - /* execute inverse fourier transform */ - for (i=0; i < channels; i++) { - for (j=0; jphas[i][j])); - spec[i][j] *= fftgrain->norm[i][j]; - } - aubio_fft_rdo(fft,spec[i],out->data[i],win_s); - } - - del_fvec(in); - del_fvec(out); - del_cvec(fftgrain); - free(w); - del_aubio_fft(fft); - for (i=0; i < channels; i++) - free(spec[i]); - free(spec); - aubio_cleanup(); - return 0; -} diff --git a/examples/tests/test-filter.c b/examples/tests/test-filter.c deleted file mode 100644 index 37dd8d05..00000000 --- a/examples/tests/test-filter.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -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 deleted file mode 100644 index e739b3e7..00000000 --- a/examples/tests/test-hist.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include - -void print_array(fvec_t *f); -void print_array(fvec_t *f){ - uint i,j; - for (i=0;ichannels;i++){ - for (j=0;jlength;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-mfft.c b/examples/tests/test-mfft.c deleted file mode 100644 index c2ec9f7e..00000000 --- a/examples/tests/test-mfft.c +++ /dev/null @@ -1,28 +0,0 @@ - -#include - -int main(){ - /* allocate some memory */ - uint_t win_s = 4096; /* window size */ - uint_t channels = 100; /* number of channels */ - fvec_t * in = new_fvec (win_s, channels); /* input buffer */ - cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ - fvec_t * out = new_fvec (win_s, channels); /* output buffer */ - /* allocate fft and other memory space */ - aubio_mfft_t * fft = new_aubio_mfft(win_s,channels); - /* fill input with some data */ - //printf("initialised\n"); - /* execute stft */ - aubio_mfft_do (fft,in,fftgrain); - //printf("computed forward\n"); - /* execute inverse fourier transform */ - aubio_mfft_rdo(fft,fftgrain,out); - //printf("computed backard\n"); - del_aubio_mfft(fft); - del_fvec(in); - del_cvec(fftgrain); - del_fvec(out); - //printf("memory freed\n"); - aubio_cleanup(); - return 0; -} diff --git a/examples/tests/test-onset.c b/examples/tests/test-onset.c deleted file mode 100644 index c26ccdcc..00000000 --- a/examples/tests/test-onset.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -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 deleted file mode 100644 index 0efa3639..00000000 --- a/examples/tests/test-onsetdetection.c +++ /dev/null @@ -1,54 +0,0 @@ - -#include - -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 deleted file mode 100644 index 736f394e..00000000 --- a/examples/tests/test-peakpick.c +++ /dev/null @@ -1,19 +0,0 @@ -#include - -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-phasevoc-jack.c b/examples/tests/test-phasevoc-jack.c deleted file mode 100644 index 00570686..00000000 --- a/examples/tests/test-phasevoc-jack.c +++ /dev/null @@ -1,84 +0,0 @@ -/* test sample for phase vocoder - * - * this program should start correctly using JACK_START_SERVER=true and - * reconstruct each audio input frame perfectly on the corresponding input with - * a delay equal to the window size, hop_s. - */ - -#include /* pause() or sleep() */ -#include -#include - -uint_t win_s = 32; /* window size */ -uint_t hop_s = 8; /* hop size */ -uint_t channels = 4; /* number of channels */ -uint_t pos = 0; /* frames%dspblocksize for jack loop */ - -fvec_t * in; -cvec_t * fftgrain; -fvec_t * out; - -aubio_pvoc_t * pv; - -#ifdef JACK_SUPPORT -aubio_jack_t * jack_setup; -#endif - -int aubio_process(float **input, float **output, int nframes); - -int main(){ - /* allocate some memory */ - in = new_fvec (hop_s, channels); /* input buffer */ - fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ - out = new_fvec (hop_s, channels); /* output buffer */ - /* allocate fft and other memory space */ - pv = new_aubio_pvoc(win_s,hop_s,channels); - /* fill input with some data */ - printf("initialised\n"); - /* execute stft */ - aubio_pvoc_do (pv,in,fftgrain); - printf("computed forward\n"); - /* execute inverse fourier transform */ - aubio_pvoc_rdo(pv,fftgrain,out); - printf("computed backard\n"); - -#ifdef JACK_SUPPORT - jack_setup = new_aubio_jack(channels, channels, - (aubio_process_func_t)aubio_process); - aubio_jack_activate(jack_setup); - sleep(10); //pause(); /* enter main jack loop */ - aubio_jack_close(jack_setup); -#endif - - del_aubio_pvoc(pv); - del_cvec(fftgrain); - del_fvec(in); - del_fvec(out); - aubio_cleanup(); - printf("memory freed\n"); - return 0; -} - -int aubio_process(float **input, float **output, int nframes) { - uint_t i; /*channels*/ - uint_t j; /*frames*/ - for (j=0;j<(unsigned)nframes;j++) { - for (i=0;ilength;i++) fftgrain->phas[0][i] *= 2.; - //for (i=0;ilength;i++) fftgrain->phas[0][i] = 0.; - aubio_pvoc_rdo(pv,fftgrain,out); - pos = -1; - } - pos++; - } - return 0; -} diff --git a/examples/tests/test-phasevoc.c b/examples/tests/test-phasevoc.c deleted file mode 100644 index 3914bef9..00000000 --- a/examples/tests/test-phasevoc.c +++ /dev/null @@ -1,30 +0,0 @@ -/* test sample for phase vocoder */ - -#include - -int main(){ - uint_t win_s = 1024; /* window size */ - uint_t hop_s = 256; /* hop size */ - uint_t channels = 4; /* number of channels */ - /* allocate some memory */ - fvec_t * in = new_fvec (hop_s, channels); /* input buffer */ - cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ - fvec_t * out = new_fvec (hop_s, channels); /* output buffer */ - /* allocate fft and other memory space */ - aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s,channels); - /* fill input with some data */ - printf("initialised\n"); - /* execute stft */ - aubio_pvoc_do (pv,in,fftgrain); - printf("computed forward\n"); - /* execute inverse fourier transform */ - aubio_pvoc_rdo(pv,fftgrain,out); - printf("computed backard\n"); - del_aubio_pvoc(pv); - del_fvec(in); - del_cvec(fftgrain); - del_fvec(out); - aubio_cleanup(); - printf("memory freed\n"); - return 0; -} diff --git a/examples/tests/test-pitchdetection.c b/examples/tests/test-pitchdetection.c deleted file mode 100644 index 71f8120e..00000000 --- a/examples/tests/test-pitchdetection.c +++ /dev/null @@ -1,27 +0,0 @@ -#include - -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 deleted file mode 100644 index be59ec7f..00000000 --- a/examples/tests/test-pitchfcomb.c +++ /dev/null @@ -1,25 +0,0 @@ -#include - -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 deleted file mode 100644 index a05ab7aa..00000000 --- a/examples/tests/test-pitchmcomb.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -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 deleted file mode 100644 index 8a61c5c5..00000000 --- a/examples/tests/test-pitchschmitt.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -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 deleted file mode 100644 index 5766a71e..00000000 --- a/examples/tests/test-pitchyin.c +++ /dev/null @@ -1,24 +0,0 @@ -#include - -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 deleted file mode 100644 index dfb8fc61..00000000 --- a/examples/tests/test-pitchyinfft.c +++ /dev/null @@ -1,22 +0,0 @@ -#include - -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 deleted file mode 100644 index 48a50552..00000000 --- a/examples/tests/test-resample.c +++ /dev/null @@ -1,23 +0,0 @@ -#include - -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 deleted file mode 100644 index d31c1d2a..00000000 --- a/examples/tests/test-sample.c +++ /dev/null @@ -1,14 +0,0 @@ -#include - -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 deleted file mode 100644 index c35111b5..00000000 --- a/examples/tests/test-scale.c +++ /dev/null @@ -1,21 +0,0 @@ -#include - -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 deleted file mode 100644 index 53906720..00000000 --- a/examples/tests/test-tempo.c +++ /dev/null @@ -1,35 +0,0 @@ -#include - -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; - - smpl_t curtempo, curtempoconf; - - while (i < 1000) { - aubio_tempo(o,in,out); - curtempo = aubio_tempo_get_bpm(o); - if (curtempo != 0.) { - fprintf(stdout,"%f\n",curtempo); - return 1; - } - curtempoconf = aubio_beattracking_get_confidence(o); - if (curtempoconf != 0.) { - fprintf(stdout,"%f\n",curtempo); - return 1; - } - i++; - }; - - del_aubio_tempo(o); - del_fvec(in); - del_fvec(out); - aubio_cleanup(); - - return 0; -} diff --git a/examples/tests/test-tss.c b/examples/tests/test-tss.c deleted file mode 100644 index a9cc335e..00000000 --- a/examples/tests/test-tss.c +++ /dev/null @@ -1,47 +0,0 @@ -/* test sample for phase vocoder - * - * this program should start correctly using JACK_START_SERVER=true and - * reconstruct each audio input frame perfectly on the corresponding input with - * a delay equal to the window size, hop_s. - */ - -#include - -int main(){ - int i; - uint_t win_s = 1024; /* window size */ - uint_t hop_s = 256; /* hop size */ - uint_t channels = 4; /* number of channels */ - /* allocate some memory */ - fvec_t * in = new_fvec (hop_s, channels); /* input buffer */ - cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ - cvec_t * cstead = new_cvec (win_s, channels); /* fft norm and phase */ - cvec_t * ctrans = new_cvec (win_s, channels); /* fft norm and phase */ - fvec_t * stead = new_fvec (hop_s, channels); /* output buffer */ - fvec_t * trans = new_fvec (hop_s, channels); /* output buffer */ - /* allocate fft and other memory space */ - aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s,channels); - aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s,channels); - aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s,channels); - - aubio_tss_t * tss = new_aubio_tss(0.01,3.,4.,win_s,hop_s,channels); - /* fill input with some data */ - printf("initialised\n"); - /* execute stft */ - for (i = 0; i < 10; i++) { - aubio_pvoc_do (pv,in,fftgrain); - aubio_tss_do (tss,fftgrain,ctrans,cstead); - aubio_pvoc_rdo(pvt,cstead,stead); - aubio_pvoc_rdo(pvs,ctrans,trans); - } - del_aubio_pvoc(pv); - del_fvec(in); - del_cvec(fftgrain); - del_cvec(cstead); - del_cvec(ctrans); - del_fvec(stead); - del_fvec(trans); - aubio_cleanup(); - printf("memory freed\n"); - return 0; -} diff --git a/examples/tests/test-window.c b/examples/tests/test-window.c deleted file mode 100644 index 62011446..00000000 --- a/examples/tests/test-window.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - -void print_array(fvec_t *f); -void print_array(fvec_t *f){ - uint i,j; - for (i=0;ichannels;i++) - { - for (j=0;jlength;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; -} - diff --git a/python/test/aubiomodule.py b/python/test/aubiomodule.py deleted file mode 100644 index cc2445c1..00000000 --- a/python/test/aubiomodule.py +++ /dev/null @@ -1,14 +0,0 @@ -import unittest - -class aubiomodule_test_case(unittest.TestCase): - - def test_aubio(self): - """ try importing aubio module """ - import aubio - - def test_aubiowrapper(self): - """ try importing aubio.aubiowrapper module """ - from aubio import aubiowrapper - -if __name__ == '__main__': - unittest.main() diff --git a/python/test/bench/onset/Makefile.am b/python/test/bench/onset/Makefile.am deleted file mode 100644 index 98a27b6b..00000000 --- a/python/test/bench/onset/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -export BASEDIR=../../../.. -export PYTHONPATH=$(BASEDIR)/python -export LD_LIBRARY_PATH=$(BASEDIR)/src/.libs:$(BASEDIR)/ext/.libs - -DETAILSOURCE = \ - /var/tmp/Onset-Mirex2005/poly_pitched \ - /var/tmp/Onset-Mirex2005/solo_bars_and_bells \ - /var/tmp/Onset-Mirex2005/solo_brass \ - /var/tmp/Onset-Mirex2005/solo_drums \ - /var/tmp/Onset-Mirex2005/solo_plucked_strings \ - /var/tmp/Onset-Mirex2005/solo_singing_voice \ - /var/tmp/Onset-Mirex2005/solo_sustained_strings \ - /var/tmp/Onset-Mirex2005/solo_winds \ - /var/tmp/Onset-Mirex2005/complex - -SOURCE = /var/tmp/Onset-Mirex2005 - -TESTSOURCE = \ - /var/tmp/Onset-Mirex2005/solo_bars_and_bells \ - /var/tmp/Onset-Mirex2005/solo_winds \ - /archives/samples/DB/PercussivePhrases/CM18/Samba_Audio - -test-aubiocut: $(patsubst %, %.aubiocut, $(TESTSOURCE)) -test-aubiodelay: $(patsubst %, %.aubiodelay, $(TESTSOURCE)) -test-aubiowindow: $(patsubst %, %.aubiowindow, $(TESTSOURCE)) - -final-aubiocut: $(patsubst %, %.aubiocut, $(DETAILSOURCE) $(SOURCE)) -final-aubiodelay: $(patsubst %, %.aubiodelay, $(SOURCE)) -final-aubiowindow: $(patsubst %, %.aubiowindow, $(SOURCE)) - -%.aubiocut: % - rm -f `basename $@` - ./bench-onset $< | tee `basename $@` - -diff `basename $@`.ref `basename $@` - -%.aubiodelay: % - rm -f `basename $@` - ./bench-delay $< | tee `basename $@` - -diff `basename $@`.ref `basename $@` - -%.aubiowindow: % - rm -f `basename $@` - ./bench-window $< | tee `basename $@` - -diff `basename $@`.ref `basename $@` diff --git a/python/test/bench/onset/bench-delay b/python/test/bench/onset/bench-delay deleted file mode 100755 index 9a213d09..00000000 --- a/python/test/bench/onset/bench-delay +++ /dev/null @@ -1,62 +0,0 @@ -#! /usr/bin/python - -from aubio.bench.onset import benchonset -from aubio.task.onset import taskonset -from aubio.task.params import taskparams - -class mybenchonset(benchonset): - - def run_bench(self,modes=['dual'],thresholds=[0.5]): - from os.path import dirname,basename - self.thresholds = thresholds - self.pretty_titles() - - for mode in modes: - d = [] - self.params.onsetmode = mode - self.params.localmin = True - self.params.delay = 1. - self.params.threshold = thresholds[0] - # - self.params.localmin = False - self.params.delay = 0. - self.dir_eval_print() - self.plotdiffs(d,plottitle="Causal") - # - self.params.localmin = True - self.params.delay = 0. - self.dir_eval_print() - self.plotdiffs(d,plottitle="Local min") - - self.params.localmin = False - self.params.delay = 6. - self.dir_eval_print() - self.plotdiffs(d,plottitle="Fixed delay") - - #self.plotplotdiffs(d) - outplot = "_-_".join(("delay",mode,basename(self.datadir) )) - for ext in ("png","svg","ps"): - self.plotplotdiffs(d,outplot=outplot,extension=ext) - -if __name__ == "__main__": - import sys - if len(sys.argv) > 1: datapath = sys.argv[1] - else: print "ERR: a path is required"; sys.exit(1) - modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual'] - #thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2] - #modes = [ 'hfc' ] - thresholds = [0.5] - - #datapath = "%s%s" % (DATADIR,'/onset/DB/*/') - respath = '/var/tmp/DB-testings' - - benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True) - benchonset.params = taskparams() - benchonset.task = taskonset - benchonset.valuesdict = {} - - try: - #benchonset.auto_learn2(modes=modes) - benchonset.run_bench(modes=modes,thresholds=thresholds) - except KeyboardInterrupt: - sys.exit(1) diff --git a/python/test/bench/onset/bench-onset b/python/test/bench/onset/bench-onset deleted file mode 100755 index 53a7ee95..00000000 --- a/python/test/bench/onset/bench-onset +++ /dev/null @@ -1,68 +0,0 @@ -#! /usr/bin/python - -from aubio.task import * - -from aubio.bench.onset import mmean, stdev, benchonset - -class mybenchonset(benchonset): - - def run_bench(self,modes=['dual'],thresholds=[0.5]): - from os.path import dirname,basename - self.thresholds = thresholds - self.pretty_titles() - d,e,f,g = [],[],[],[] - for mode in modes: - self.vlist = [] - self.params.onsetmode = mode - #self.params.localmin = True - - for threshold in self.thresholds: - self.params.threshold = threshold - self.dir_eval_print() - self.vlist.append(self.v) - self.plotroc(d) - self.plotfmeas(e) - self.plotpr(f) - #self.plothistcat(g) - - - - #self.plotplotroc(d) - #self.plotplotfmeas(e) - #self.plotplotpr(f) - outplot = basename(self.datadir) - for ext in ("png","svg","ps"): - self.plotplotroc(d,outplot=outplot,extension=ext) - self.plotplotfmeas(e,outplot=outplot,extension=ext) - self.plotplotpr(f,outplot=outplot,extension=ext) - #self.plotplothistcat(g,outplot=outplot,extension=ext) - -if __name__ == "__main__": - import sys - if len(sys.argv) > 1: datapath = sys.argv[1] - else: print "ERR: a path is required"; sys.exit(1) - modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual'] - thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2] - #modes = [ 'hfc' ] - #thresholds = [0.5] - - #datapath = "%s%s" % (DATADIR,'/onset/DB/*/') - respath = '/var/tmp/DB-testings' - - benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True) - benchonset.params = taskparams() - benchonset.params.dcthreshold = -1. - benchonset.params.silence = -100. - benchonset.params.delay = 5. - benchonset.params.bufsize = 1024 - benchonset.params.hopsize = 256 - benchonset.params.step = float(benchonset.params.hopsize)/float(benchonset.params.samplerate) - benchonset.params.mintol = 4.1 - benchonset.task = taskonset - benchonset.valuesdict = {} - - try: - #benchonset.auto_learn2(modes=modes) - benchonset.run_bench(modes=modes,thresholds=thresholds) - except KeyboardInterrupt: - sys.exit(1) diff --git a/python/test/bench/onset/bench-window b/python/test/bench/onset/bench-window deleted file mode 100755 index 1fa4a7b6..00000000 --- a/python/test/bench/onset/bench-window +++ /dev/null @@ -1,59 +0,0 @@ -#! /usr/bin/python - -from aubio.bench.onset import benchonset -from aubio.task.onset import taskonset -from aubio.task.params import taskparams - -class mybenchonset(benchonset): - - def run_bench(self,modes=['dual'],thresholds=[0.5]): - from os.path import dirname,basename - self.thresholds = thresholds - self.pretty_titles() - - for mode in modes: - - self.params.onsetmode = mode - self.params.localmin = True - self.params.delay = 1. - self.params.threshold = thresholds[0] - self.params.localmin = False - # - for delay in (0., 4.): - d = [] - self.params.delay = delay - for buf in (2048, 1024, 512): - for hop in (buf/2, buf/4): - self.params.bufsize = buf - self.params.hopsize = hop - self.params.step = float(self.params.hopsize)/float(self.params.samplerate) - self.dir_eval_print() - self.plotdiffs(d,plottitle="%s %s" % (buf,hop)) - #plotplotdiffs(d) - outplot = "_-_".join(("window",mode,"delay-%s" % int(delay), - basename(self.datadir) )) - for ext in ("png","svg","ps"): - self.plotplotdiffs(d,outplot=outplot,extension=ext) - -if __name__ == "__main__": - import sys - if len(sys.argv) > 1: datapath = sys.argv[1] - else: print "ERR: a path is required"; sys.exit(1) - modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual'] - #thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2] - #modes = [ 'hfc' ] - thresholds = [0.5] - - #datapath = "%s%s" % (DATADIR,'/onset/DB/*/') - respath = '/var/tmp/DB-testings' - - benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True) - benchonset.params = taskparams() - benchonset.task = taskonset - benchonset.valuesdict = {} - - try: - #benchonset.auto_learn2(modes=modes) - benchonset.run_bench(modes=modes,thresholds=thresholds) - except KeyboardInterrupt: - sys.exit(1) diff --git a/python/test/bench/pitch/Makefile.am b/python/test/bench/pitch/Makefile.am deleted file mode 100644 index c2a08b3b..00000000 --- a/python/test/bench/pitch/Makefile.am +++ /dev/null @@ -1,59 +0,0 @@ -export AUBIODIR=../../../.. -export PYTHONPATH=$(AUBIODIR)/python -export LD_LIBRARY_PATH=$(AUBIODIR)/src/.libs:$(AUBIODIR)/ext/.libs - -CP=cp -a - -SOURCE = \ - $(BASEDIR)/isolated/vibraphone \ - $(BASEDIR)/isolated/clavinet \ - $(BASEDIR)/isolated/elecguitar \ - $(BASEDIR)/isolated/piano \ - $(BASEDIR)/isolated/rhodes \ - $(BASEDIR)/isolated - - -MONOSOURCE = \ - $(BASEDIR)/monophonic/Mirex04/daisy \ - $(BASEDIR)/monophonic/Mirex04/midi \ - $(BASEDIR)/monophonic/Mirex04/jazz \ - $(BASEDIR)/monophonic/Mirex04/pop \ - $(BASEDIR)/monophonic/Mirex04/opera \ - $(BASEDIR)/monophonic/Mirex04 - -POLYSOURCE = \ - $(BASEDIR)/polyphonic/Mirex04/daisy \ - $(BASEDIR)/polyphonic/Mirex04/midi \ - $(BASEDIR)/polyphonic/Mirex04/jazz \ - $(BASEDIR)/polyphonic/Mirex04/pop \ - $(BASEDIR)/polyphonic/Mirex04/opera \ - $(BASEDIR)/polyphonic/Mirex04 - -test-aubiopitch-isolated: $(patsubst %, %.aubiopitch-isolated, $(SOURCE)) -test-aubiopitch-monophonic: $(patsubst %, %.aubiopitch-monophonic, $(MONOSOURCE)) -test-aubiopitch-polyphonic: $(patsubst %, %.aubiopitch-polyphonic, $(POLYSOURCE)) - -plotpitch: - ../../../aubiopitch -m fcomb,mcomb,yinfft,yin,schmitt -i jazz2REF.wav -p -t 0.2 -l 100 -M 600 -O jazz2REF.ps - ../../../aubiopitch -m fcomb,mcomb,yinfft,yin,schmitt -p -t 0.2 -l 300 -M 900 -i opera_fem2REF.wav -O opera_fem2REF.ps - -timings: - ./bench-timings $(BASEDIR)/polyphonic/Mirex04/opera - -%.aubiopitch-isolated: % - $(CP) isolated/`basename $@` isolated/`basename $@`.old - ./bench-pitch-isolated $< | tee isolated/`basename $@` - -diff isolated/`basename $@`.old isolated/`basename $@` - -diff isolated/`basename $@`.ref isolated/`basename $@` - -%.aubiopitch-monophonic: % - $(CP) monophonic/`basename $@` monophonic/`basename $@`.old - ./bench-pitch-monophonic $< | tee monophonic/`basename $@` - -diff monophonic/`basename $@`.ref monophonic/`basename $@` - -diff monophonic/`basename $@`.old monophonic/`basename $@` - -%.aubiopitch-polyphonic: % - $(CP) polyphonic/`basename $@` polyphonic/`basename $@`.old - ./bench-pitch-polyphonic $< | tee polyphonic/`basename $@` - -diff polyphonic/`basename $@`.ref polyphonic/`basename $@` - -diff polyphonic/`basename $@`.old polyphonic/`basename $@` diff --git a/python/test/bench/pitch/bench-pitch-isolated b/python/test/bench/pitch/bench-pitch-isolated deleted file mode 100755 index c048b01a..00000000 --- a/python/test/bench/pitch/bench-pitch-isolated +++ /dev/null @@ -1,198 +0,0 @@ -#! /usr/bin/python - -from aubio.bench.node import * -from aubio.task import * - -class benchpitch(bench): - - """ list of values to store per file """ - valuenames = ['mode'] - """ list of lists to store per file """ - valuelists = ['truth', 'osil', 'esil', 'opit', 'epit', 'echr', - 'Msil', 'Mpit', 'Mchr', - 'TotalPit', 'TotalPit', 'TotalChr' ] - """ list of values to print per dir """ - printnames_total = [ 'mode', 'MinPit', 'MaxPit', 'TotalSil', 'TotalPit', 'TotalChr'] - printnames_notes = [ 'mode', 'Note', 'Sil', 'Pit', 'Chr'] - printnames = printnames_notes - - """ per dir """ - formats = {'mode': "%12s" , - 'truth': "%s", - 'osil': "%s", 'esil': "%s", - 'opit': "%s", 'epit': "%s", 'echr': "%s", - 'Note': "%s", 'Sil': "%s", 'Chr': "%s", 'Pit': "%s", - 'TotalPit': "%s", 'TotalSil': "%s", 'TotalChr': "%s", - 'MinPit': "%s", 'MaxPit': "%s", - 'Msil': "%s", 'Mpit': "%s", 'Mchr': "%s"} - - def dir_eval(self): - """ evaluate statistical data over the directory """ - v = self.v - v['mode'] = self.params.pitchmode - - def file_exec(self,input,output): - filetask = self.task(input,params=self.params) - computed_data = filetask.compute_all() - osil, esil, opit, epit, echr = filetask.eval(computed_data,tol=0.5) - self.v['truth'].append(int(filetask.truth)) - assert opit > 0 - - self.v['osil'].append(osil) - self.v['esil'].append(esil) - self.v['opit'].append(opit) - self.v['epit'].append(epit) - self.v['echr'].append(echr) - - self.v['Msil'].append(esil/float(osil)*100.) - self.v['Mpit'].append(epit/float(opit)*100.) - self.v['Mchr'].append(echr/float(opit)*100.) - #print results#, computed_data - #print input, results, results - float(input.split('.')[-2]) - - def run_bench(self,modes=['schmitt'],multiplot=0): - from os.path import basename - self.modes = modes - self.pretty_titles() - d = [] - for mode in self.modes: - self.params.pitchmode = mode - self.dir_exec() - self.dir_eval() - truth = [i for i in range(min(self.v['truth']),max(self.v['truth'])+1)] - allOsil = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] - allEsil = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] - allOpit = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] - allEpit = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] - allEchr = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] - allMsil = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] - allMpit = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] - allMchr = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] - for i in range(len(self.v['truth'])): - allOsil[self.v['truth'][i]-min(self.v['truth'])] += self.v['osil'][i] - allEsil[self.v['truth'][i]-min(self.v['truth'])] += self.v['esil'][i] - allOpit[self.v['truth'][i]-min(self.v['truth'])] += self.v['opit'][i] - allEpit[self.v['truth'][i]-min(self.v['truth'])] += self.v['epit'][i] - allEchr[self.v['truth'][i]-min(self.v['truth'])] += self.v['echr'][i] - for i in range(len(truth)): - allOsil[i] = max(1,allOsil[i]) - allOpit[i] = max(1,allOpit[i]) - allMsil[i] = allEsil[i]/float(allOsil[i])*100. - allMpit[i] = allEpit[i]/float(allOpit[i])*100. - allMchr[i] = allEchr[i]/float(allOpit[i])*100. - self.v['Sil'], self.v['Pit'], self.v['Chr'] = allMsil[i], allMpit[i], allMchr[i] - self.v['Note'] = truth[i] - #self.printnames = self.printnames_notes - self.pretty_print() - self.v['TotalSil'] = sum(allMsil)/len(truth) - self.v['TotalPit'] = sum(allMpit)/len(truth) - self.v['TotalChr'] = sum(allMchr)/len(truth) - self.v['MinPit'] = min(truth) - self.v['MaxPit'] = max(truth) - #self.printnames = self.printnames_total - #self.pretty_print() - - plot = [] - self.plotpitchtessiture(plot, - truth, - allMpit, - plottitle="%s %s" % (self.v['mode'],self.params.bufsize), - plotmode='lines') - """ - self.plotpitchtessiture(plot, - truth, - allMchr, - plottitle="%s %s" % (self.v['mode'],"%12"), - plotmode='lines') - self.plotpitchtessiture(plot, - truth, - allMsil, - plottitle="%s %s" % (self.v['mode'],"sil"), - plotmode='lines') - """ - title = basename(self.datadir) - if multiplot: - d.append(plot) - else: - d += plot - outplot = "_-_".join(('pitchtessiture',title)) - self.xmin = min(self.v['truth']) #20. - self.xmax = max(self.v['truth']) - for ext in ('ps','png','svg'): #,''): - self.plotplotpitchtessiture(d, - plottitle="".join(['Performance against MIDI Note number (', - title, - ", %s" % len(self.sndlist), " samples)"]), - outplot=outplot, - extension=ext,multiplot=multiplot) - #d.append('beta = .25,orig(x) title \"-2 octave\"') - #d.append('beta = .50,orig(x) title \"-1 octave\"') - #d.append('beta = 1.0,orig(x) title \"original\"') - #d.append('beta = 2.0,orig(x) title \"+1 octave\"') - - """ - Plot functions - """ - - def plotpitchtessiture(self,d,lx,ly,plottitle="",plotmode='linespoints'): - import Gnuplot, Gnuplot.funcutils - d.append(Gnuplot.Data(lx, ly, with=plotmode, title="%s" % (plottitle) )) - - def plotplotpitchtessiture(self,d,plottitle='',outplot=0,extension='',multiplot=1): - from aubio.gnuplot import gnuplot_create - g = gnuplot_create(outplot=outplot,extension=extension) - #g.title(plottitle) - #g('orig(x) = beta*x') - g.title(plottitle) - g('set yrange [50:100]') - # erase axis - g('set xrange [%f:%f]' % (self.xmin,self.xmax)) #(self.xmax - (self.xmax-self.xmin)*5./4.,self.xmax)) - #g.plot(*d) - g('set border 3') - g('set xtics nomirror') - g('set ytics nomirror') - g('set key bottom') - if multiplot: - g('set multiplot') - for i in range(len(d)): - # plot onset detection functions - g('set size 1,%f' % ( 1.0/float(len(d)) ) ) - g('set origin 0,%f' % ( 1.0*float(len(d)-i-1)/float(len(d)) ) ) - #g.ylabel('%Correct detections') - g('set xrange [%f:%f]' % (self.xmin,self.xmax)) #(self.xmax - (self.xmax-self.xmin)*5./4.,self.xmax)) - g.plot(*d[i]) - g('unset title') - g('unset multiplot') - else: - g.plot(*d) - - -if __name__ == "__main__": - import sys - if len(sys.argv) > 1: datapath = sys.argv[1] - else: print "error: a path is required"; sys.exit(1) - if len(sys.argv) > 2: - for each in sys.argv[3:-1]: print each - modes = ['schmitt', 'yin', 'yinfft', 'mcomb', 'fcomb'] - #modes = ['mcomb'] - - params = taskparams() - params.bufsize = 2048 # 4096 - params.hopsize = 256 - params.silence = -60. - params.pitchsmooth = 0 - params.pitchmax = 20000 - params.pitchmin = 20 - params.pitchyinfft = 0.95 - benchpitch = benchpitch(datapath,params=params) - benchpitch.task = taskpitch - - #benchpitch.titles = [ 'mode', 'thres', 'avg', 'avgdist' ] - #benchpitch.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s" ] - try: - benchpitch.run_bench(modes=modes) - except KeyboardInterrupt: - print "Interrupted by user" - sys.exit(1) - - sys.exit(0) diff --git a/python/test/bench/pitch/bench-pitch-plot-isolated b/python/test/bench/pitch/bench-pitch-plot-isolated deleted file mode 100755 index 9bae85e8..00000000 --- a/python/test/bench/pitch/bench-pitch-plot-isolated +++ /dev/null @@ -1,63 +0,0 @@ -#! /usr/bin/python - -if __name__ == '__main__': - import sys, Gnuplot - from aubio.gnuplot import gnuplot_create - from aubio.txtfile import read_datafile - from aubio.plot.keyboard import draw_keyboard - lines = [] - titles = [] - for file in range(len(sys.argv)-1): - l = read_datafile(sys.argv[file+1]) - notes, score = [],[] - for i in range(len(l)): - notes.append(l[i][0]) - score.append(l[i][2]) - lines.append(Gnuplot.Data(notes,score, - with='linespoints', - title=sys.argv[file+1].split('.')[-1])) - titles.append(sys.argv[file+1].split('.')[-1]) - blacks,whites = draw_keyboard(firstnote = notes[0], lastnote = notes[-1], - y0= 40, y1 = 50) - - g = gnuplot_create(sys.argv[file+1].split('.')[-3],'ps') - #g = gnuplot_create('','') - #g = gnuplot_create('/tmp/test','eps') - g('set yrange [40:100]') - #g('set xrange [%f:%f]' % (notes[0],notes[-1]+60)) - g('set size 0.5') - g('set key outside') - - g('set border 3') - g('set xtics nomirror') - g('set ytics nomirror') - multiplot = 1 - oplots = lines - g('set size 1,2') - if multiplot: - height = 2. - g('set lmargin 10') - #g('set rmargin 15') - g('set multiplot') - g('set yrange [50:100]') - g('set xrange [%f:%f]' % (notes[0],notes[-1])) - g('set xtics %f,12' % notes[0]) - g('set nokey') - for i in range(len(oplots)): - g.ylabel(titles[i]) - g('set size %f,%f' % (1.,height*.85/float(len(oplots)))) - g('set origin 0,%f' % (height*(.15+.85*float(len(oplots)-i-1)/float(len(oplots))))) - g.plot(oplots[i]) - g('set title "Raw pitch accuracy (%) against midi note numbers"') - g('set noxtics') - g('set noytics') - g('set size %f,%f' % (1.,.15*height)) - g('set origin 0,%f' % 0) - g('set yrange [40:50]') - g('set xrange [%f:%f]' % (notes[0],notes[-1])) - g.xlabel('') - g.ylabel('') - g.plot(whites,blacks) - g('unset multiplot') - else: - g.plot(whites,blacks,*lines) diff --git a/python/test/bench/tempo/demo-tempo b/python/test/bench/tempo/demo-tempo deleted file mode 100755 index 02579a62..00000000 --- a/python/test/bench/tempo/demo-tempo +++ /dev/null @@ -1,313 +0,0 @@ -#! /usr/bin/python - -""" this file was written by Paul Brossier - it is released under the GNU/GPL license. -""" - -import sys,time -from aubio.task import taskbeat,taskparams -from aubio.aubioclass import fvec, aubio_autocorr -from aubio.gnuplot import gnuplot_create, gnuplot_addargs -from aubio.aubiowrapper import * -from math import exp,log - -usage = "usage: %s [options] -i soundfile" % sys.argv[0] - -def parse_args(): - from optparse import OptionParser - parser = OptionParser(usage=usage) - parser.add_option("-i","--input", - action="store", dest="filename", - help="input sound file") - parser.add_option("-n","--printframe", - action="store", dest="printframe", default=-1, - help="make a plot of the n_th frame") - gnuplot_addargs(parser) - (options, args) = parser.parse_args() - if not options.filename: - print "no file name given\n", usage - sys.exit(1) - return options, args - -def plotdata(x,y,plottitle="",**keyw): - import Gnuplot - return Gnuplot.Data(x, y, title="%s" % plottitle,**keyw) - -options, args = parse_args() -filename = options.filename -xsize = float(options.xsize) -ysize = float(options.ysize) - -printframe = int(options.printframe) - -if options.outplot and printframe > 0: - extension = options.outplot.split('.')[-1] - outplot = '.'.join(options.outplot.split('.')[:-1]) -else: - extension = '' - outplot = None -f = gnuplot_create(outplot=outplot,extension=extension,options=options) - -params = taskparams() -params.onsetmode = 'specdiff' -task = taskbeat(filename,params=params) - -hopsize = params.hopsize -bufsize = params.bufsize -btstep = task.btstep -winlen = task.btwinlen -laglen = winlen/4 -step = winlen/4 - -timesig = 0 -maxnumelem = 4 -gp = 0 -counter = 0 -flagconst = 0 -constthresh = 3.901 -g_var = 3.901 -rp = 0 -rp1 = 0 -rp2 = 0 -g_mu = 0 - -rayparam = 48/512.*winlen - -#t = [i for i in range(hopsize)] -#tlong = [i for i in range(hopsize*(btstep-1))] -#tall = [i for i in range(hopsize*btstep)] -#a = [0 for i in range(hopsize*btstep)] -dfx = [i for i in range(winlen)] -dfframe = [0 for i in range(winlen)] -dfrev = [0 for i in range(winlen)] -acframe = [0 for i in range(winlen)] - -localacf = [0 for i in range(winlen)] -inds = [0 for i in range(maxnumelem)] - -acx = [i for i in range(laglen)] -acfout = [0 for i in range(laglen)] - -phwv = [0 for i in range(2*laglen)] -phwvx = [i for i in range(2*laglen)] - -dfwvnorm = exp(log(2.0)*(winlen+2.)/rayparam); -dfwv = [exp(log(2.)*(i+1.)/rayparam)/dfwvnorm for i in range(winlen)] - -gwv = [exp(-.5*(j+1.-g_mu)**2/g_var**2) for j in range(laglen)] -rwv = [(i+1.)/rayparam**2 * exp(-(i+1.)**2 / (2.*rayparam)**2) - for i in range(0,laglen)] -acf = fvec(winlen,1) - -nrframe = 0 -while (task.readsize == params.hopsize): - task() - #print task.pos2 - #a[:-hopsize] = [i for i in a[-(btstep-1)*hopsize:]] - #a[-hopsize:] = [task.myvec.get(i,0) for i in t] - - #g('set xrange [%f:%f]' % (t[0],t[-1])) - #time.sleep(.2) - if task.pos2==btstep-1: - nrframe += 1 - dfframe = [task.dfframe.get(i,0) for i in range(winlen)] - if printframe == nrframe or printframe == -1: - d = [[plotdata(range(-winlen,0),dfframe,plottitle="onset detection", with='lines')]] - # start beattracking_do - for i in range(winlen): - dfrev[winlen-1-i] = 0. - dfrev[winlen-1-i] = dfframe[i]*dfwv[i] - aubio_autocorr(task.dfframe(),acf()); - acframe = [acf.get(i,0) for i in range(winlen)] - if not timesig: - numelem = 4 - else: - numelem = timesig - - old = 0 - acfout = [0 for i in range(winlen/4)] - for i in range(1,laglen-1): - for a in range(1,numelem+1): - for b in range (1-a,a): - acfout[i] += acframe[a*(i+1)+b-1] * 1./(2.*a-1.)*rwv[i] - if old < acfout[i]: - old = acfout[i] - maxi = i - rp = max(maxi,1); - - if printframe == nrframe or printframe == -1: - rwvs = [rwv[i]*max(acframe) for i in range(len(rwv))] - d += [[plotdata(acx,acfout,plottitle="comb filterbank", with='lines', axes='x1y1'), - plotdata([rp,rp],[1.2*old,min(acfout)],plottitle="period", with='impulses', axes='x1y1'), - plotdata(acx,rwvs,plottitle="L_w", with='lines', axes='x1y1')]] - - # getperiod - inds = [0 for i in range(maxnumelem)] - localacf = [0 for i in range(winlen)] - period = 0 - for a in range(1,4+1): - for b in range(1-a,a): - localacf[a*rp+b-1] = acframe[a*rp+b-1] - for i in range(numelem): - maxindex = 0 - maxval = 0.0 - for j in range(rp*(i+1)+i): - if localacf[j] > maxval: - maxval = localacf[j] - maxind = j - localacf[j] = 0 - inds[i] = maxind - for i in range(numelem): - period += inds[i]/(i+1.) - period = period/numelem - #print "period", period - - # checkstate - if gp: - # context dependant model - acfout = [0 for i in range(winlen/4)] - old = 0 - for i in range(laglen-1): - for a in range(timesig): - for b in range(1-a,a): - acfout[i] += acframe[a*(i+1)+b-1] * gwv[i] - if old < acfout[i]: - old = acfout[i] - maxi = i - gp = maxi - else: - # general model - gp = 0 - #print "gp", gp - if printframe == nrframe or printframe == -1: - gwvs = [gwv[i]*max(acfout) for i in range(len(gwv))] - d += [[plotdata(acx,acfout,plottitle="comb filterbank", with='lines', axes='x1y1'), - plotdata(gp,old,plottitle="period", with='impulses', axes='x1y1'), - plotdata(acx,gwvs,plottitle="L_{gw}", with='lines', axes='x1y1')]] - - if counter == 0: - # initial step - if abs(gp-rp) > 2.*constthresh: - flagstep = 1 - counter = 3 - else: - flagstep = 0 - #print "flagstep", flagstep - #print "rp2,rp1,rp", rp2,rp1,rp - acfw = [dfframe[i]*dfwv[i] for i in range(winlen)] - - if counter == 1 and flagstep == 1: - # "3rd frame after flagstep set" - if abs(2.*rp-rp1- rp2) < constthresh: - flagconst = 1 - counter = 0 - else: - flagconst = 0 - counter = 2 - elif counter > 0: - counter -= 1 - - rp2 = rp1; rp1 = rp - - if flagconst: - # "first run of new hypothesis" - gp = rp - g_mu = gp - timesig = 4 #FIXME - gwv = [exp(-.5*(j+1.-g_mu)**2/g_var**2) for j in range(laglen)] - flagconst = 0 - bp = gp - phwv = [1 for i in range(2*laglen)] - elif timesig: - # "contex dependant" - bp = gp - if step > lastbeat: - phwv = [exp(-.5*(1.+j-step+lastbeat)**2/(bp/8.)) for j in range(2*laglen)] - else: - print "NOT using phase weighting" - phwv = [1 for i in range(2*laglen)] - else: - # "initial state" - bp = rp - phwv = [1 for i in range(2*laglen)] - - while bp < 25: - print "WARNING, doubling the beat period" - bp *= 2 - - # - phout = [0. for i in range(winlen)] - - kmax = int(winlen/float(bp)); - - old = 0 - for i in range(bp): - phout[i] = 0. - for k in range(kmax): - phout[i] += dfrev[i+bp*k] * phwv[i] - if phout[i] > old: - old = phout[i] - maxi = i - maxindex = maxi - if (maxindex == winlen - 1): maxindex = 0 - phase = 1 + maxindex - i = 1 - beat = bp - phase - beats= [] - if beat >= 0: beats.append(beat) - while beat+bp < step: - beat += bp - beats.append(beat) - lastbeat = beat - #print beats, - #print "the lastbeat is", lastbeat - - # plot all this - if printframe == nrframe or printframe == -1: - phwvs = [phwv[i]*max(phout) for i in range(len(phwv))] - d += [[plotdata(range(-laglen,0),phwvs[laglen:0:-1],plottitle="A_{gw}", with='lines',axes='x1y1'), - plotdata(range(-laglen,0),phout[laglen:0:-1],plottitle="df", with='lines'), - plotdata(-phase,old,plottitle="phase", with='impulses', axes='x1y1'), - plotdata([i for i in beats],[old for i in beats],plottitle="predicted", with='impulses') - ]] - #d += [[plotdata(dfx,dfwv,plottitle="phase weighting", with='lines', axes='x1y2'), - # plotdata(dfx,dfrev,plottitle="df reverse", with='lines', axes='x1y1')]] - #d += [[plotdata(dfx,phout,plottitle="phase", with='lines', axes='x1y2')]] - #d += [[plotdata(dfx,dfwv,plottitle="phase weighting", with='lines', axes='x1y2'), - # plotdata(dfx,dfrev,plottitle="df reverse", with='lines', axes='x1y1')]] - #d += [[plotdata(dfx,phout,plottitle="phase", with='lines', axes='x1y2')]] - - f('set lmargin 4') - f('set rmargin 4') - f('set size %f,%f' % (1.0*xsize,1.0*ysize) ) - f('set key spacing 1.3') - f('set multiplot') - - f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) - f('set orig %f,%f' % (0.0*xsize,0.66*ysize) ) - f('set xrange [%f:%f]' % (-winlen,0) ) - f.title('Onset detection function') - f.xlabel('time (df samples)') - f.plot(*d[0]) - f('set size %f,%f' % (0.5*xsize,0.33*ysize) ) - f('set orig %f,%f' % (0.0*xsize,0.33*ysize) ) - f('set xrange [%f:%f]' % (0,laglen) ) - f.title('Period detection: Rayleygh weighting') - f.xlabel('lag (df samples)') - f.plot(*d[1]) - f('set size %f,%f' % (0.5*xsize,0.33*ysize) ) - f('set orig %f,%f' % (0.5*xsize,0.33*ysize) ) - f('set xrange [%f:%f]' % (0,laglen) ) - f.title('Period detection: Gaussian weighting') - f.xlabel('lag (df samples)') - f.plot(*d[2]) - f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) - f('set orig %f,%f' % (0.0*xsize,0.00*ysize) ) - f('set xrange [%f:%f]' % (-laglen,laglen) ) - f.title('Phase detection and predicted beats') - f.xlabel('time (df samples)') - f.plot(*d[3]) - f('set nomultiplot') - if printframe == -1: a = sys.stdin.read() - elif 0 < printframe and printframe < nrframe: - break diff --git a/python/test/bench/tempo/demo-tempo-acf b/python/test/bench/tempo/demo-tempo-acf deleted file mode 100755 index e099b81c..00000000 --- a/python/test/bench/tempo/demo-tempo-acf +++ /dev/null @@ -1,157 +0,0 @@ -#! /usr/bin/python - -""" this file was written by Paul Brossier - it is released under the GNU/GPL license. -""" - -import sys,time -from aubio.task import taskbeat,taskparams -from aubio.aubioclass import fvec, aubio_autocorr -from aubio.gnuplot import gnuplot_create, gnuplot_addargs -from aubio.aubiowrapper import * -from math import exp,log - -usage = "usage: %s [options] -i soundfile" % sys.argv[0] - -def parse_args(): - from optparse import OptionParser - parser = OptionParser(usage=usage) - parser.add_option("-i","--input", - action="store", dest="filename", - help="input sound file") - parser.add_option("-n","--printframe", - action="store", dest="printframe", default=-1, - help="make a plot of the n_th frame") - gnuplot_addargs(parser) - (options, args) = parser.parse_args() - if not options.filename: - print "no file name given\n", usage - sys.exit(1) - return options, args - -def plotdata(x,y,plottitle="",**keyw): - import Gnuplot - return Gnuplot.Data(x, y, title="%s" % plottitle,**keyw) - -options, args = parse_args() -filename = options.filename -xsize = float(options.xsize) -ysize = float(options.ysize) - -printframe = int(options.printframe) - -if options.outplot and printframe > 0: - extension = options.outplot.split('.')[-1] - outplot = '.'.join(options.outplot.split('.')[:-1]) -else: - extension = '' - outplot = None -f = gnuplot_create(outplot,extension,options) - -params = taskparams() -params.onsetmode = 'specdiff' -task = taskbeat(filename,params=params) - -hopsize = params.hopsize -bufsize = params.bufsize -btstep = task.btstep -winlen = task.btwinlen -laglen = winlen/4 -step = winlen/4 - -timesig = 0 -maxnumelem = 4 -gp = 0 -counter = 0 -flagconst = 0 -constthresh = 3.901 -g_var = 3.901 -rp = 0 -rp1 = 0 -rp2 = 0 -g_mu = 0 - -rayparam = 48/512.*winlen - -t = [i for i in range(hopsize)] -#tlong = [i for i in range(hopsize*(btstep-1))] -#tall = [i for i in range(hopsize*btstep)] -sig = [0 for i in range(hopsize*btstep*4)] -dfx = [i for i in range(winlen)] -dfframe = [0 for i in range(winlen)] -dfrev = [0 for i in range(winlen)] -acframe = [0 for i in range(winlen/2)] - -localacf = [0 for i in range(winlen)] -inds = [0 for i in range(maxnumelem)] - -acx = [i for i in range(laglen)] -acfout = [0 for i in range(laglen)] - -phwv = [0 for i in range(2*laglen)] -phwvx = [i for i in range(2*laglen)] - -dfwvnorm = exp(log(2.0)*(winlen+2.)/rayparam); -dfwv = [exp(log(2.)*(i+1.)/rayparam)/dfwvnorm for i in range(winlen)] - -gwv = [exp(-.5*(j+1.-g_mu)**2/g_var**2) for j in range(laglen)] -rwv = [(i+1.)/rayparam**2 * exp(-(i+1.)**2 / (2.*rayparam)**2) - for i in range(0,laglen)] -acf = fvec(winlen,1) - -nrframe = 0 -while (task.readsize == params.hopsize): - task() - #print task.pos2 - sig[:-hopsize] = [i for i in sig[-(btstep*4-1)*hopsize:]] - sig[-hopsize:] = [task.myvec.get(i,0) for i in t] - - #g('set xrange [%f:%f]' % (t[0],t[-1])) - #time.sleep(.2) - if task.pos2==btstep-1: - nrframe += 1 - dfframe = [task.dfframe.get(i,0) for i in range(winlen)] - # start beattracking_do - for i in range(winlen): - dfrev[winlen-1-i] = 0. - dfrev[winlen-1-i] = dfframe[i]*dfwv[i] - aubio_autocorr(task.dfframe(),acf()); - acframe = [acf.get(i,0) for i in range(winlen/2)] - if printframe == nrframe or printframe == -1: - d = [[plotdata(range(0,btstep*hopsize*4,4),sig[0:-1:4],plottitle="input signal", with='lines')]] - d += [[plotdata(range(-winlen,0),dfframe,plottitle="onset detection", with='lines')]] - d += [[plotdata(range(winlen/2),acframe,plottitle="autocorrelation", with='lines')]] - - # plot all this - if printframe == nrframe or printframe == -1: - - f('set lmargin 4') - f('set rmargin 4') - f('set size %f,%f' % (1.0*xsize,1.0*ysize) ) - f('set key spacing 1.3') - f('set multiplot') - - f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) - f('set orig %f,%f' % (0.0*xsize,0.66*ysize) ) - f('set xrange [%f:%f]' % (0,btstep*hopsize*4) ) - f('set yrange [%f:%f]' % (-1.2*max(sig),1.2*max(sig)) ) - f.title('Input signal') - f.xlabel('time (samples)') - f.plot(*d[0]) - f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) - f('set orig %f,%f' % (0.0*xsize,0.33*ysize) ) - f('set xrange [%f:%f]' % (-winlen,0) ) - f('set autoscale y') - f.title('Onset detection function') - f.xlabel('time (df samples)') - f.plot(*d[1]) - f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) - f('set orig %f,%f' % (0.0*xsize,0.00*ysize) ) - f('set xrange [%f:%f]' % (0,winlen/2) ) - f.title('Autocorrelation') - f.xlabel('lag (df samples)') - f.plot(*d[2]) - f('set nomultiplot') - if printframe == -1: a = sys.stdin.read() - elif 0 < printframe and printframe < nrframe: - break diff --git a/python/test/cvec.py b/python/test/cvec.py deleted file mode 100644 index f1043004..00000000 --- a/python/test/cvec.py +++ /dev/null @@ -1,51 +0,0 @@ -import unittest - -from aubio.aubiowrapper import * - -buf_size = 2048 -channels = 3 - -class cvec_test_case(unittest.TestCase): - - def setUp(self): - self.vector = new_cvec(buf_size, channels) - - def tearDown(self): - del_cvec(self.vector) - - def test_cvec(self): - """ create and delete cvec """ - pass - - def test_cvec_read_norm(self): - """ check new cvec norm elements are set to 0. """ - for index in range(buf_size/2+1): - for channel in range(channels): - self.assertEqual(cvec_read_norm(self.vector,channel,index),0.) - - def test_cvec_read_phas(self): - """ check new cvec phas elements are set to 0. """ - for index in range(buf_size/2+1): - for channel in range(channels): - self.assertEqual(cvec_read_phas(self.vector,channel,index),0.) - - def test_cvec_write_norm(self): - """ check new cvec norm elements are set with cvec_write_norm """ - for index in range(buf_size/2+1): - for channel in range(channels): - cvec_write_norm(self.vector,1.,channel,index) - for index in range(buf_size/2+1): - for channel in range(channels): - self.assertEqual(cvec_read_norm(self.vector,channel,index),1.) - - def test_cvec_write_phas(self): - """ check new cvec phas elements are set with cvec_write_phas """ - for index in range(buf_size/2+1): - for channel in range(channels): - cvec_write_phas(self.vector,1.,channel,index) - for index in range(buf_size/2+1): - for channel in range(channels): - self.assertEqual(cvec_read_phas(self.vector,channel,index),1.) - -if __name__ == '__main__': - unittest.main() diff --git a/python/test/fvec.py b/python/test/fvec.py deleted file mode 100644 index 5159af93..00000000 --- a/python/test/fvec.py +++ /dev/null @@ -1,36 +0,0 @@ -import unittest - -from aubio.aubiowrapper import * - -buf_size = 2048 -channels = 3 - -class fvec_test_case(unittest.TestCase): - - def setUp(self): - self.vector = new_fvec(buf_size, channels) - - def tearDown(self): - del_fvec(self.vector) - - def test_fvec(self): - """ create and delete fvec """ - pass - - def test_fvec_read_sample(self): - """ check new fvec elements are set to 0. """ - for index in range(buf_size): - for channel in range(channels): - self.assertEqual(fvec_read_sample(self.vector,channel,index),0.) - - def test_fvec_write_sample(self): - """ check new fvec elements are set with fvec_write_sample """ - for index in range(buf_size): - for channel in range(channels): - fvec_write_sample(self.vector,1.,channel,index) - for index in range(buf_size): - for channel in range(channels): - self.assertEqual(fvec_read_sample(self.vector,channel,index),1.) - -if __name__ == '__main__': - unittest.main() diff --git a/python/test/list_missing_tests b/python/test/list_missing_tests deleted file mode 100755 index 3d5e5744..00000000 --- a/python/test/list_missing_tests +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/python - -from glob import glob -from os.path import splitext, exists -import sys - -if len(sys.argv) > 1: verbose = True -else: verbose = False - -cfiles = [ file.split('/')[-1] for file in glob('../../src/*.c') ] -cfiles.sort() - -for cfile in cfiles: - pythonfile=splitext(cfile)[0]+'.py' - if not exists(pythonfile): - print "[X] %30s" % cfile, "[ ] %30s" % pythonfile - #print cfile, "has NO test", pythonfile - elif verbose: - print "[X] %30s" % cfile, "[X] %30s" % pythonfile - -pythonfiles = [ file.split('/')[-1] for file in glob('*.py') ] -pythonfiles.sort() - -for pythonfile in pythonfiles: - cfile=splitext(pythonfile)[0]+'.c' - if not exists('../../'+cfile): - print "[ ] %30s" % cfile, "[X] %30s" % pythonfile - #print pythonfile, "has NO source", cfile - elif verbose: - print "[X] %30s" % cfile, "[X] %30s" % pythonfile diff --git a/python/test/run_all_tests b/python/test/run_all_tests deleted file mode 100755 index a066ca3a..00000000 --- a/python/test/run_all_tests +++ /dev/null @@ -1,15 +0,0 @@ -#! /usr/bin/python - -# add ${src}/python and ${src}/python/aubio/.libs to python path -# so the script is runnable from a compiled source tree. -import sys, os -sys.path.append('..') -sys.path.append(os.path.join('..','aubio','.libs')) - -import unittest - -modules_to_test = ['aubiomodule', 'fvec', 'cvec'] - -if __name__ == '__main__': - for module in modules_to_test: exec('from %s import *' % module) - unittest.main() diff --git a/tests/list_missing_python_tests b/tests/list_missing_python_tests new file mode 100755 index 00000000..33bd8bc0 --- /dev/null +++ b/tests/list_missing_python_tests @@ -0,0 +1,37 @@ +#! /usr/bin/python + +from glob import glob +from os.path import splitext, exists, join, dirname +import sys + +tst_dir = join(dirname(sys.argv[0]),'python') +src_dir = join(dirname(sys.argv[0]),'..','src') + +if len(sys.argv) > 1: verbose = True +else: verbose = False + +status = 0 + +cfiles = [ file.split('/')[-1] for file in glob(join(src_dir,'*.c')) ] +cfiles.sort() + +for cfile in cfiles: + pythonfile=splitext(cfile)[0]+'.py' + if not exists(pythonfile): + print "%20s [X]" % cfile, "[ ] %s" % pythonfile + status = 1 + elif verbose: + print "%20s [X]" % cfile, "[X] %s" % pythonfile + +pythonfiles = [ file.split('/')[-1] for file in glob(join(tst_dir,'*.py')) ] +pythonfiles.sort() + +for pythonfile in pythonfiles: + cfile=splitext(pythonfile)[0]+'.c' + if not exists(join(src_dir,cfile)): + print "%20s [ ]" % cfile, "[X] %s" % pythonfile + status = 1 + elif verbose: + print "%20s [X]" % cfile, "[X] %s" % pythonfile + +sys.exit(status) diff --git a/tests/python/aubiomodule.py b/tests/python/aubiomodule.py new file mode 100644 index 00000000..cc2445c1 --- /dev/null +++ b/tests/python/aubiomodule.py @@ -0,0 +1,14 @@ +import unittest + +class aubiomodule_test_case(unittest.TestCase): + + def test_aubio(self): + """ try importing aubio module """ + import aubio + + def test_aubiowrapper(self): + """ try importing aubio.aubiowrapper module """ + from aubio import aubiowrapper + +if __name__ == '__main__': + unittest.main() diff --git a/tests/python/bench/onset/Makefile.am b/tests/python/bench/onset/Makefile.am new file mode 100644 index 00000000..98a27b6b --- /dev/null +++ b/tests/python/bench/onset/Makefile.am @@ -0,0 +1,44 @@ +export BASEDIR=../../../.. +export PYTHONPATH=$(BASEDIR)/python +export LD_LIBRARY_PATH=$(BASEDIR)/src/.libs:$(BASEDIR)/ext/.libs + +DETAILSOURCE = \ + /var/tmp/Onset-Mirex2005/poly_pitched \ + /var/tmp/Onset-Mirex2005/solo_bars_and_bells \ + /var/tmp/Onset-Mirex2005/solo_brass \ + /var/tmp/Onset-Mirex2005/solo_drums \ + /var/tmp/Onset-Mirex2005/solo_plucked_strings \ + /var/tmp/Onset-Mirex2005/solo_singing_voice \ + /var/tmp/Onset-Mirex2005/solo_sustained_strings \ + /var/tmp/Onset-Mirex2005/solo_winds \ + /var/tmp/Onset-Mirex2005/complex + +SOURCE = /var/tmp/Onset-Mirex2005 + +TESTSOURCE = \ + /var/tmp/Onset-Mirex2005/solo_bars_and_bells \ + /var/tmp/Onset-Mirex2005/solo_winds \ + /archives/samples/DB/PercussivePhrases/CM18/Samba_Audio + +test-aubiocut: $(patsubst %, %.aubiocut, $(TESTSOURCE)) +test-aubiodelay: $(patsubst %, %.aubiodelay, $(TESTSOURCE)) +test-aubiowindow: $(patsubst %, %.aubiowindow, $(TESTSOURCE)) + +final-aubiocut: $(patsubst %, %.aubiocut, $(DETAILSOURCE) $(SOURCE)) +final-aubiodelay: $(patsubst %, %.aubiodelay, $(SOURCE)) +final-aubiowindow: $(patsubst %, %.aubiowindow, $(SOURCE)) + +%.aubiocut: % + rm -f `basename $@` + ./bench-onset $< | tee `basename $@` + -diff `basename $@`.ref `basename $@` + +%.aubiodelay: % + rm -f `basename $@` + ./bench-delay $< | tee `basename $@` + -diff `basename $@`.ref `basename $@` + +%.aubiowindow: % + rm -f `basename $@` + ./bench-window $< | tee `basename $@` + -diff `basename $@`.ref `basename $@` diff --git a/tests/python/bench/onset/bench-delay b/tests/python/bench/onset/bench-delay new file mode 100755 index 00000000..9a213d09 --- /dev/null +++ b/tests/python/bench/onset/bench-delay @@ -0,0 +1,62 @@ +#! /usr/bin/python + +from aubio.bench.onset import benchonset +from aubio.task.onset import taskonset +from aubio.task.params import taskparams + +class mybenchonset(benchonset): + + def run_bench(self,modes=['dual'],thresholds=[0.5]): + from os.path import dirname,basename + self.thresholds = thresholds + self.pretty_titles() + + for mode in modes: + d = [] + self.params.onsetmode = mode + self.params.localmin = True + self.params.delay = 1. + self.params.threshold = thresholds[0] + # + self.params.localmin = False + self.params.delay = 0. + self.dir_eval_print() + self.plotdiffs(d,plottitle="Causal") + # + self.params.localmin = True + self.params.delay = 0. + self.dir_eval_print() + self.plotdiffs(d,plottitle="Local min") + + self.params.localmin = False + self.params.delay = 6. + self.dir_eval_print() + self.plotdiffs(d,plottitle="Fixed delay") + + #self.plotplotdiffs(d) + outplot = "_-_".join(("delay",mode,basename(self.datadir) )) + for ext in ("png","svg","ps"): + self.plotplotdiffs(d,outplot=outplot,extension=ext) + +if __name__ == "__main__": + import sys + if len(sys.argv) > 1: datapath = sys.argv[1] + else: print "ERR: a path is required"; sys.exit(1) + modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual'] + #thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2] + #modes = [ 'hfc' ] + thresholds = [0.5] + + #datapath = "%s%s" % (DATADIR,'/onset/DB/*/') + respath = '/var/tmp/DB-testings' + + benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True) + benchonset.params = taskparams() + benchonset.task = taskonset + benchonset.valuesdict = {} + + try: + #benchonset.auto_learn2(modes=modes) + benchonset.run_bench(modes=modes,thresholds=thresholds) + except KeyboardInterrupt: + sys.exit(1) diff --git a/tests/python/bench/onset/bench-onset b/tests/python/bench/onset/bench-onset new file mode 100755 index 00000000..53a7ee95 --- /dev/null +++ b/tests/python/bench/onset/bench-onset @@ -0,0 +1,68 @@ +#! /usr/bin/python + +from aubio.task import * + +from aubio.bench.onset import mmean, stdev, benchonset + +class mybenchonset(benchonset): + + def run_bench(self,modes=['dual'],thresholds=[0.5]): + from os.path import dirname,basename + self.thresholds = thresholds + self.pretty_titles() + d,e,f,g = [],[],[],[] + for mode in modes: + self.vlist = [] + self.params.onsetmode = mode + #self.params.localmin = True + + for threshold in self.thresholds: + self.params.threshold = threshold + self.dir_eval_print() + self.vlist.append(self.v) + self.plotroc(d) + self.plotfmeas(e) + self.plotpr(f) + #self.plothistcat(g) + + + + #self.plotplotroc(d) + #self.plotplotfmeas(e) + #self.plotplotpr(f) + outplot = basename(self.datadir) + for ext in ("png","svg","ps"): + self.plotplotroc(d,outplot=outplot,extension=ext) + self.plotplotfmeas(e,outplot=outplot,extension=ext) + self.plotplotpr(f,outplot=outplot,extension=ext) + #self.plotplothistcat(g,outplot=outplot,extension=ext) + +if __name__ == "__main__": + import sys + if len(sys.argv) > 1: datapath = sys.argv[1] + else: print "ERR: a path is required"; sys.exit(1) + modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual'] + thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2] + #modes = [ 'hfc' ] + #thresholds = [0.5] + + #datapath = "%s%s" % (DATADIR,'/onset/DB/*/') + respath = '/var/tmp/DB-testings' + + benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True) + benchonset.params = taskparams() + benchonset.params.dcthreshold = -1. + benchonset.params.silence = -100. + benchonset.params.delay = 5. + benchonset.params.bufsize = 1024 + benchonset.params.hopsize = 256 + benchonset.params.step = float(benchonset.params.hopsize)/float(benchonset.params.samplerate) + benchonset.params.mintol = 4.1 + benchonset.task = taskonset + benchonset.valuesdict = {} + + try: + #benchonset.auto_learn2(modes=modes) + benchonset.run_bench(modes=modes,thresholds=thresholds) + except KeyboardInterrupt: + sys.exit(1) diff --git a/tests/python/bench/onset/bench-window b/tests/python/bench/onset/bench-window new file mode 100755 index 00000000..1fa4a7b6 --- /dev/null +++ b/tests/python/bench/onset/bench-window @@ -0,0 +1,59 @@ +#! /usr/bin/python + +from aubio.bench.onset import benchonset +from aubio.task.onset import taskonset +from aubio.task.params import taskparams + +class mybenchonset(benchonset): + + def run_bench(self,modes=['dual'],thresholds=[0.5]): + from os.path import dirname,basename + self.thresholds = thresholds + self.pretty_titles() + + for mode in modes: + + self.params.onsetmode = mode + self.params.localmin = True + self.params.delay = 1. + self.params.threshold = thresholds[0] + self.params.localmin = False + # + for delay in (0., 4.): + d = [] + self.params.delay = delay + for buf in (2048, 1024, 512): + for hop in (buf/2, buf/4): + self.params.bufsize = buf + self.params.hopsize = hop + self.params.step = float(self.params.hopsize)/float(self.params.samplerate) + self.dir_eval_print() + self.plotdiffs(d,plottitle="%s %s" % (buf,hop)) + #plotplotdiffs(d) + outplot = "_-_".join(("window",mode,"delay-%s" % int(delay), + basename(self.datadir) )) + for ext in ("png","svg","ps"): + self.plotplotdiffs(d,outplot=outplot,extension=ext) + +if __name__ == "__main__": + import sys + if len(sys.argv) > 1: datapath = sys.argv[1] + else: print "ERR: a path is required"; sys.exit(1) + modes = ['complex', 'energy', 'phase', 'hfc', 'specdiff', 'kl', 'mkl', 'dual'] + #thresholds = [ 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2] + #modes = [ 'hfc' ] + thresholds = [0.5] + + #datapath = "%s%s" % (DATADIR,'/onset/DB/*/') + respath = '/var/tmp/DB-testings' + + benchonset = mybenchonset(datapath,respath,checkres=True,checkanno=True) + benchonset.params = taskparams() + benchonset.task = taskonset + benchonset.valuesdict = {} + + try: + #benchonset.auto_learn2(modes=modes) + benchonset.run_bench(modes=modes,thresholds=thresholds) + except KeyboardInterrupt: + sys.exit(1) diff --git a/tests/python/bench/pitch/Makefile.am b/tests/python/bench/pitch/Makefile.am new file mode 100644 index 00000000..c2a08b3b --- /dev/null +++ b/tests/python/bench/pitch/Makefile.am @@ -0,0 +1,59 @@ +export AUBIODIR=../../../.. +export PYTHONPATH=$(AUBIODIR)/python +export LD_LIBRARY_PATH=$(AUBIODIR)/src/.libs:$(AUBIODIR)/ext/.libs + +CP=cp -a + +SOURCE = \ + $(BASEDIR)/isolated/vibraphone \ + $(BASEDIR)/isolated/clavinet \ + $(BASEDIR)/isolated/elecguitar \ + $(BASEDIR)/isolated/piano \ + $(BASEDIR)/isolated/rhodes \ + $(BASEDIR)/isolated + + +MONOSOURCE = \ + $(BASEDIR)/monophonic/Mirex04/daisy \ + $(BASEDIR)/monophonic/Mirex04/midi \ + $(BASEDIR)/monophonic/Mirex04/jazz \ + $(BASEDIR)/monophonic/Mirex04/pop \ + $(BASEDIR)/monophonic/Mirex04/opera \ + $(BASEDIR)/monophonic/Mirex04 + +POLYSOURCE = \ + $(BASEDIR)/polyphonic/Mirex04/daisy \ + $(BASEDIR)/polyphonic/Mirex04/midi \ + $(BASEDIR)/polyphonic/Mirex04/jazz \ + $(BASEDIR)/polyphonic/Mirex04/pop \ + $(BASEDIR)/polyphonic/Mirex04/opera \ + $(BASEDIR)/polyphonic/Mirex04 + +test-aubiopitch-isolated: $(patsubst %, %.aubiopitch-isolated, $(SOURCE)) +test-aubiopitch-monophonic: $(patsubst %, %.aubiopitch-monophonic, $(MONOSOURCE)) +test-aubiopitch-polyphonic: $(patsubst %, %.aubiopitch-polyphonic, $(POLYSOURCE)) + +plotpitch: + ../../../aubiopitch -m fcomb,mcomb,yinfft,yin,schmitt -i jazz2REF.wav -p -t 0.2 -l 100 -M 600 -O jazz2REF.ps + ../../../aubiopitch -m fcomb,mcomb,yinfft,yin,schmitt -p -t 0.2 -l 300 -M 900 -i opera_fem2REF.wav -O opera_fem2REF.ps + +timings: + ./bench-timings $(BASEDIR)/polyphonic/Mirex04/opera + +%.aubiopitch-isolated: % + $(CP) isolated/`basename $@` isolated/`basename $@`.old + ./bench-pitch-isolated $< | tee isolated/`basename $@` + -diff isolated/`basename $@`.old isolated/`basename $@` + -diff isolated/`basename $@`.ref isolated/`basename $@` + +%.aubiopitch-monophonic: % + $(CP) monophonic/`basename $@` monophonic/`basename $@`.old + ./bench-pitch-monophonic $< | tee monophonic/`basename $@` + -diff monophonic/`basename $@`.ref monophonic/`basename $@` + -diff monophonic/`basename $@`.old monophonic/`basename $@` + +%.aubiopitch-polyphonic: % + $(CP) polyphonic/`basename $@` polyphonic/`basename $@`.old + ./bench-pitch-polyphonic $< | tee polyphonic/`basename $@` + -diff polyphonic/`basename $@`.ref polyphonic/`basename $@` + -diff polyphonic/`basename $@`.old polyphonic/`basename $@` diff --git a/tests/python/bench/pitch/bench-pitch-isolated b/tests/python/bench/pitch/bench-pitch-isolated new file mode 100755 index 00000000..c048b01a --- /dev/null +++ b/tests/python/bench/pitch/bench-pitch-isolated @@ -0,0 +1,198 @@ +#! /usr/bin/python + +from aubio.bench.node import * +from aubio.task import * + +class benchpitch(bench): + + """ list of values to store per file """ + valuenames = ['mode'] + """ list of lists to store per file """ + valuelists = ['truth', 'osil', 'esil', 'opit', 'epit', 'echr', + 'Msil', 'Mpit', 'Mchr', + 'TotalPit', 'TotalPit', 'TotalChr' ] + """ list of values to print per dir """ + printnames_total = [ 'mode', 'MinPit', 'MaxPit', 'TotalSil', 'TotalPit', 'TotalChr'] + printnames_notes = [ 'mode', 'Note', 'Sil', 'Pit', 'Chr'] + printnames = printnames_notes + + """ per dir """ + formats = {'mode': "%12s" , + 'truth': "%s", + 'osil': "%s", 'esil': "%s", + 'opit': "%s", 'epit': "%s", 'echr': "%s", + 'Note': "%s", 'Sil': "%s", 'Chr': "%s", 'Pit': "%s", + 'TotalPit': "%s", 'TotalSil': "%s", 'TotalChr': "%s", + 'MinPit': "%s", 'MaxPit': "%s", + 'Msil': "%s", 'Mpit': "%s", 'Mchr': "%s"} + + def dir_eval(self): + """ evaluate statistical data over the directory """ + v = self.v + v['mode'] = self.params.pitchmode + + def file_exec(self,input,output): + filetask = self.task(input,params=self.params) + computed_data = filetask.compute_all() + osil, esil, opit, epit, echr = filetask.eval(computed_data,tol=0.5) + self.v['truth'].append(int(filetask.truth)) + assert opit > 0 + + self.v['osil'].append(osil) + self.v['esil'].append(esil) + self.v['opit'].append(opit) + self.v['epit'].append(epit) + self.v['echr'].append(echr) + + self.v['Msil'].append(esil/float(osil)*100.) + self.v['Mpit'].append(epit/float(opit)*100.) + self.v['Mchr'].append(echr/float(opit)*100.) + #print results#, computed_data + #print input, results, results - float(input.split('.')[-2]) + + def run_bench(self,modes=['schmitt'],multiplot=0): + from os.path import basename + self.modes = modes + self.pretty_titles() + d = [] + for mode in self.modes: + self.params.pitchmode = mode + self.dir_exec() + self.dir_eval() + truth = [i for i in range(min(self.v['truth']),max(self.v['truth'])+1)] + allOsil = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] + allEsil = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] + allOpit = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] + allEpit = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] + allEchr = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] + allMsil = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] + allMpit = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] + allMchr = [0 for i in range(min(self.v['truth']),max(self.v['truth'])+1)] + for i in range(len(self.v['truth'])): + allOsil[self.v['truth'][i]-min(self.v['truth'])] += self.v['osil'][i] + allEsil[self.v['truth'][i]-min(self.v['truth'])] += self.v['esil'][i] + allOpit[self.v['truth'][i]-min(self.v['truth'])] += self.v['opit'][i] + allEpit[self.v['truth'][i]-min(self.v['truth'])] += self.v['epit'][i] + allEchr[self.v['truth'][i]-min(self.v['truth'])] += self.v['echr'][i] + for i in range(len(truth)): + allOsil[i] = max(1,allOsil[i]) + allOpit[i] = max(1,allOpit[i]) + allMsil[i] = allEsil[i]/float(allOsil[i])*100. + allMpit[i] = allEpit[i]/float(allOpit[i])*100. + allMchr[i] = allEchr[i]/float(allOpit[i])*100. + self.v['Sil'], self.v['Pit'], self.v['Chr'] = allMsil[i], allMpit[i], allMchr[i] + self.v['Note'] = truth[i] + #self.printnames = self.printnames_notes + self.pretty_print() + self.v['TotalSil'] = sum(allMsil)/len(truth) + self.v['TotalPit'] = sum(allMpit)/len(truth) + self.v['TotalChr'] = sum(allMchr)/len(truth) + self.v['MinPit'] = min(truth) + self.v['MaxPit'] = max(truth) + #self.printnames = self.printnames_total + #self.pretty_print() + + plot = [] + self.plotpitchtessiture(plot, + truth, + allMpit, + plottitle="%s %s" % (self.v['mode'],self.params.bufsize), + plotmode='lines') + """ + self.plotpitchtessiture(plot, + truth, + allMchr, + plottitle="%s %s" % (self.v['mode'],"%12"), + plotmode='lines') + self.plotpitchtessiture(plot, + truth, + allMsil, + plottitle="%s %s" % (self.v['mode'],"sil"), + plotmode='lines') + """ + title = basename(self.datadir) + if multiplot: + d.append(plot) + else: + d += plot + outplot = "_-_".join(('pitchtessiture',title)) + self.xmin = min(self.v['truth']) #20. + self.xmax = max(self.v['truth']) + for ext in ('ps','png','svg'): #,''): + self.plotplotpitchtessiture(d, + plottitle="".join(['Performance against MIDI Note number (', + title, + ", %s" % len(self.sndlist), " samples)"]), + outplot=outplot, + extension=ext,multiplot=multiplot) + #d.append('beta = .25,orig(x) title \"-2 octave\"') + #d.append('beta = .50,orig(x) title \"-1 octave\"') + #d.append('beta = 1.0,orig(x) title \"original\"') + #d.append('beta = 2.0,orig(x) title \"+1 octave\"') + + """ + Plot functions + """ + + def plotpitchtessiture(self,d,lx,ly,plottitle="",plotmode='linespoints'): + import Gnuplot, Gnuplot.funcutils + d.append(Gnuplot.Data(lx, ly, with=plotmode, title="%s" % (plottitle) )) + + def plotplotpitchtessiture(self,d,plottitle='',outplot=0,extension='',multiplot=1): + from aubio.gnuplot import gnuplot_create + g = gnuplot_create(outplot=outplot,extension=extension) + #g.title(plottitle) + #g('orig(x) = beta*x') + g.title(plottitle) + g('set yrange [50:100]') + # erase axis + g('set xrange [%f:%f]' % (self.xmin,self.xmax)) #(self.xmax - (self.xmax-self.xmin)*5./4.,self.xmax)) + #g.plot(*d) + g('set border 3') + g('set xtics nomirror') + g('set ytics nomirror') + g('set key bottom') + if multiplot: + g('set multiplot') + for i in range(len(d)): + # plot onset detection functions + g('set size 1,%f' % ( 1.0/float(len(d)) ) ) + g('set origin 0,%f' % ( 1.0*float(len(d)-i-1)/float(len(d)) ) ) + #g.ylabel('%Correct detections') + g('set xrange [%f:%f]' % (self.xmin,self.xmax)) #(self.xmax - (self.xmax-self.xmin)*5./4.,self.xmax)) + g.plot(*d[i]) + g('unset title') + g('unset multiplot') + else: + g.plot(*d) + + +if __name__ == "__main__": + import sys + if len(sys.argv) > 1: datapath = sys.argv[1] + else: print "error: a path is required"; sys.exit(1) + if len(sys.argv) > 2: + for each in sys.argv[3:-1]: print each + modes = ['schmitt', 'yin', 'yinfft', 'mcomb', 'fcomb'] + #modes = ['mcomb'] + + params = taskparams() + params.bufsize = 2048 # 4096 + params.hopsize = 256 + params.silence = -60. + params.pitchsmooth = 0 + params.pitchmax = 20000 + params.pitchmin = 20 + params.pitchyinfft = 0.95 + benchpitch = benchpitch(datapath,params=params) + benchpitch.task = taskpitch + + #benchpitch.titles = [ 'mode', 'thres', 'avg', 'avgdist' ] + #benchpitch.formats = ["%12s" , "| %6s", "| %6s", "| %6s", "| %6s", "| %6s" ] + try: + benchpitch.run_bench(modes=modes) + except KeyboardInterrupt: + print "Interrupted by user" + sys.exit(1) + + sys.exit(0) diff --git a/tests/python/bench/pitch/bench-pitch-plot-isolated b/tests/python/bench/pitch/bench-pitch-plot-isolated new file mode 100755 index 00000000..9bae85e8 --- /dev/null +++ b/tests/python/bench/pitch/bench-pitch-plot-isolated @@ -0,0 +1,63 @@ +#! /usr/bin/python + +if __name__ == '__main__': + import sys, Gnuplot + from aubio.gnuplot import gnuplot_create + from aubio.txtfile import read_datafile + from aubio.plot.keyboard import draw_keyboard + lines = [] + titles = [] + for file in range(len(sys.argv)-1): + l = read_datafile(sys.argv[file+1]) + notes, score = [],[] + for i in range(len(l)): + notes.append(l[i][0]) + score.append(l[i][2]) + lines.append(Gnuplot.Data(notes,score, + with='linespoints', + title=sys.argv[file+1].split('.')[-1])) + titles.append(sys.argv[file+1].split('.')[-1]) + blacks,whites = draw_keyboard(firstnote = notes[0], lastnote = notes[-1], + y0= 40, y1 = 50) + + g = gnuplot_create(sys.argv[file+1].split('.')[-3],'ps') + #g = gnuplot_create('','') + #g = gnuplot_create('/tmp/test','eps') + g('set yrange [40:100]') + #g('set xrange [%f:%f]' % (notes[0],notes[-1]+60)) + g('set size 0.5') + g('set key outside') + + g('set border 3') + g('set xtics nomirror') + g('set ytics nomirror') + multiplot = 1 + oplots = lines + g('set size 1,2') + if multiplot: + height = 2. + g('set lmargin 10') + #g('set rmargin 15') + g('set multiplot') + g('set yrange [50:100]') + g('set xrange [%f:%f]' % (notes[0],notes[-1])) + g('set xtics %f,12' % notes[0]) + g('set nokey') + for i in range(len(oplots)): + g.ylabel(titles[i]) + g('set size %f,%f' % (1.,height*.85/float(len(oplots)))) + g('set origin 0,%f' % (height*(.15+.85*float(len(oplots)-i-1)/float(len(oplots))))) + g.plot(oplots[i]) + g('set title "Raw pitch accuracy (%) against midi note numbers"') + g('set noxtics') + g('set noytics') + g('set size %f,%f' % (1.,.15*height)) + g('set origin 0,%f' % 0) + g('set yrange [40:50]') + g('set xrange [%f:%f]' % (notes[0],notes[-1])) + g.xlabel('') + g.ylabel('') + g.plot(whites,blacks) + g('unset multiplot') + else: + g.plot(whites,blacks,*lines) diff --git a/tests/python/bench/tempo/demo-tempo b/tests/python/bench/tempo/demo-tempo new file mode 100755 index 00000000..02579a62 --- /dev/null +++ b/tests/python/bench/tempo/demo-tempo @@ -0,0 +1,313 @@ +#! /usr/bin/python + +""" this file was written by Paul Brossier + it is released under the GNU/GPL license. +""" + +import sys,time +from aubio.task import taskbeat,taskparams +from aubio.aubioclass import fvec, aubio_autocorr +from aubio.gnuplot import gnuplot_create, gnuplot_addargs +from aubio.aubiowrapper import * +from math import exp,log + +usage = "usage: %s [options] -i soundfile" % sys.argv[0] + +def parse_args(): + from optparse import OptionParser + parser = OptionParser(usage=usage) + parser.add_option("-i","--input", + action="store", dest="filename", + help="input sound file") + parser.add_option("-n","--printframe", + action="store", dest="printframe", default=-1, + help="make a plot of the n_th frame") + gnuplot_addargs(parser) + (options, args) = parser.parse_args() + if not options.filename: + print "no file name given\n", usage + sys.exit(1) + return options, args + +def plotdata(x,y,plottitle="",**keyw): + import Gnuplot + return Gnuplot.Data(x, y, title="%s" % plottitle,**keyw) + +options, args = parse_args() +filename = options.filename +xsize = float(options.xsize) +ysize = float(options.ysize) + +printframe = int(options.printframe) + +if options.outplot and printframe > 0: + extension = options.outplot.split('.')[-1] + outplot = '.'.join(options.outplot.split('.')[:-1]) +else: + extension = '' + outplot = None +f = gnuplot_create(outplot=outplot,extension=extension,options=options) + +params = taskparams() +params.onsetmode = 'specdiff' +task = taskbeat(filename,params=params) + +hopsize = params.hopsize +bufsize = params.bufsize +btstep = task.btstep +winlen = task.btwinlen +laglen = winlen/4 +step = winlen/4 + +timesig = 0 +maxnumelem = 4 +gp = 0 +counter = 0 +flagconst = 0 +constthresh = 3.901 +g_var = 3.901 +rp = 0 +rp1 = 0 +rp2 = 0 +g_mu = 0 + +rayparam = 48/512.*winlen + +#t = [i for i in range(hopsize)] +#tlong = [i for i in range(hopsize*(btstep-1))] +#tall = [i for i in range(hopsize*btstep)] +#a = [0 for i in range(hopsize*btstep)] +dfx = [i for i in range(winlen)] +dfframe = [0 for i in range(winlen)] +dfrev = [0 for i in range(winlen)] +acframe = [0 for i in range(winlen)] + +localacf = [0 for i in range(winlen)] +inds = [0 for i in range(maxnumelem)] + +acx = [i for i in range(laglen)] +acfout = [0 for i in range(laglen)] + +phwv = [0 for i in range(2*laglen)] +phwvx = [i for i in range(2*laglen)] + +dfwvnorm = exp(log(2.0)*(winlen+2.)/rayparam); +dfwv = [exp(log(2.)*(i+1.)/rayparam)/dfwvnorm for i in range(winlen)] + +gwv = [exp(-.5*(j+1.-g_mu)**2/g_var**2) for j in range(laglen)] +rwv = [(i+1.)/rayparam**2 * exp(-(i+1.)**2 / (2.*rayparam)**2) + for i in range(0,laglen)] +acf = fvec(winlen,1) + +nrframe = 0 +while (task.readsize == params.hopsize): + task() + #print task.pos2 + #a[:-hopsize] = [i for i in a[-(btstep-1)*hopsize:]] + #a[-hopsize:] = [task.myvec.get(i,0) for i in t] + + #g('set xrange [%f:%f]' % (t[0],t[-1])) + #time.sleep(.2) + if task.pos2==btstep-1: + nrframe += 1 + dfframe = [task.dfframe.get(i,0) for i in range(winlen)] + if printframe == nrframe or printframe == -1: + d = [[plotdata(range(-winlen,0),dfframe,plottitle="onset detection", with='lines')]] + # start beattracking_do + for i in range(winlen): + dfrev[winlen-1-i] = 0. + dfrev[winlen-1-i] = dfframe[i]*dfwv[i] + aubio_autocorr(task.dfframe(),acf()); + acframe = [acf.get(i,0) for i in range(winlen)] + if not timesig: + numelem = 4 + else: + numelem = timesig + + old = 0 + acfout = [0 for i in range(winlen/4)] + for i in range(1,laglen-1): + for a in range(1,numelem+1): + for b in range (1-a,a): + acfout[i] += acframe[a*(i+1)+b-1] * 1./(2.*a-1.)*rwv[i] + if old < acfout[i]: + old = acfout[i] + maxi = i + rp = max(maxi,1); + + if printframe == nrframe or printframe == -1: + rwvs = [rwv[i]*max(acframe) for i in range(len(rwv))] + d += [[plotdata(acx,acfout,plottitle="comb filterbank", with='lines', axes='x1y1'), + plotdata([rp,rp],[1.2*old,min(acfout)],plottitle="period", with='impulses', axes='x1y1'), + plotdata(acx,rwvs,plottitle="L_w", with='lines', axes='x1y1')]] + + # getperiod + inds = [0 for i in range(maxnumelem)] + localacf = [0 for i in range(winlen)] + period = 0 + for a in range(1,4+1): + for b in range(1-a,a): + localacf[a*rp+b-1] = acframe[a*rp+b-1] + for i in range(numelem): + maxindex = 0 + maxval = 0.0 + for j in range(rp*(i+1)+i): + if localacf[j] > maxval: + maxval = localacf[j] + maxind = j + localacf[j] = 0 + inds[i] = maxind + for i in range(numelem): + period += inds[i]/(i+1.) + period = period/numelem + #print "period", period + + # checkstate + if gp: + # context dependant model + acfout = [0 for i in range(winlen/4)] + old = 0 + for i in range(laglen-1): + for a in range(timesig): + for b in range(1-a,a): + acfout[i] += acframe[a*(i+1)+b-1] * gwv[i] + if old < acfout[i]: + old = acfout[i] + maxi = i + gp = maxi + else: + # general model + gp = 0 + #print "gp", gp + if printframe == nrframe or printframe == -1: + gwvs = [gwv[i]*max(acfout) for i in range(len(gwv))] + d += [[plotdata(acx,acfout,plottitle="comb filterbank", with='lines', axes='x1y1'), + plotdata(gp,old,plottitle="period", with='impulses', axes='x1y1'), + plotdata(acx,gwvs,plottitle="L_{gw}", with='lines', axes='x1y1')]] + + if counter == 0: + # initial step + if abs(gp-rp) > 2.*constthresh: + flagstep = 1 + counter = 3 + else: + flagstep = 0 + #print "flagstep", flagstep + #print "rp2,rp1,rp", rp2,rp1,rp + acfw = [dfframe[i]*dfwv[i] for i in range(winlen)] + + if counter == 1 and flagstep == 1: + # "3rd frame after flagstep set" + if abs(2.*rp-rp1- rp2) < constthresh: + flagconst = 1 + counter = 0 + else: + flagconst = 0 + counter = 2 + elif counter > 0: + counter -= 1 + + rp2 = rp1; rp1 = rp + + if flagconst: + # "first run of new hypothesis" + gp = rp + g_mu = gp + timesig = 4 #FIXME + gwv = [exp(-.5*(j+1.-g_mu)**2/g_var**2) for j in range(laglen)] + flagconst = 0 + bp = gp + phwv = [1 for i in range(2*laglen)] + elif timesig: + # "contex dependant" + bp = gp + if step > lastbeat: + phwv = [exp(-.5*(1.+j-step+lastbeat)**2/(bp/8.)) for j in range(2*laglen)] + else: + print "NOT using phase weighting" + phwv = [1 for i in range(2*laglen)] + else: + # "initial state" + bp = rp + phwv = [1 for i in range(2*laglen)] + + while bp < 25: + print "WARNING, doubling the beat period" + bp *= 2 + + # + phout = [0. for i in range(winlen)] + + kmax = int(winlen/float(bp)); + + old = 0 + for i in range(bp): + phout[i] = 0. + for k in range(kmax): + phout[i] += dfrev[i+bp*k] * phwv[i] + if phout[i] > old: + old = phout[i] + maxi = i + maxindex = maxi + if (maxindex == winlen - 1): maxindex = 0 + phase = 1 + maxindex + i = 1 + beat = bp - phase + beats= [] + if beat >= 0: beats.append(beat) + while beat+bp < step: + beat += bp + beats.append(beat) + lastbeat = beat + #print beats, + #print "the lastbeat is", lastbeat + + # plot all this + if printframe == nrframe or printframe == -1: + phwvs = [phwv[i]*max(phout) for i in range(len(phwv))] + d += [[plotdata(range(-laglen,0),phwvs[laglen:0:-1],plottitle="A_{gw}", with='lines',axes='x1y1'), + plotdata(range(-laglen,0),phout[laglen:0:-1],plottitle="df", with='lines'), + plotdata(-phase,old,plottitle="phase", with='impulses', axes='x1y1'), + plotdata([i for i in beats],[old for i in beats],plottitle="predicted", with='impulses') + ]] + #d += [[plotdata(dfx,dfwv,plottitle="phase weighting", with='lines', axes='x1y2'), + # plotdata(dfx,dfrev,plottitle="df reverse", with='lines', axes='x1y1')]] + #d += [[plotdata(dfx,phout,plottitle="phase", with='lines', axes='x1y2')]] + #d += [[plotdata(dfx,dfwv,plottitle="phase weighting", with='lines', axes='x1y2'), + # plotdata(dfx,dfrev,plottitle="df reverse", with='lines', axes='x1y1')]] + #d += [[plotdata(dfx,phout,plottitle="phase", with='lines', axes='x1y2')]] + + f('set lmargin 4') + f('set rmargin 4') + f('set size %f,%f' % (1.0*xsize,1.0*ysize) ) + f('set key spacing 1.3') + f('set multiplot') + + f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) + f('set orig %f,%f' % (0.0*xsize,0.66*ysize) ) + f('set xrange [%f:%f]' % (-winlen,0) ) + f.title('Onset detection function') + f.xlabel('time (df samples)') + f.plot(*d[0]) + f('set size %f,%f' % (0.5*xsize,0.33*ysize) ) + f('set orig %f,%f' % (0.0*xsize,0.33*ysize) ) + f('set xrange [%f:%f]' % (0,laglen) ) + f.title('Period detection: Rayleygh weighting') + f.xlabel('lag (df samples)') + f.plot(*d[1]) + f('set size %f,%f' % (0.5*xsize,0.33*ysize) ) + f('set orig %f,%f' % (0.5*xsize,0.33*ysize) ) + f('set xrange [%f:%f]' % (0,laglen) ) + f.title('Period detection: Gaussian weighting') + f.xlabel('lag (df samples)') + f.plot(*d[2]) + f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) + f('set orig %f,%f' % (0.0*xsize,0.00*ysize) ) + f('set xrange [%f:%f]' % (-laglen,laglen) ) + f.title('Phase detection and predicted beats') + f.xlabel('time (df samples)') + f.plot(*d[3]) + f('set nomultiplot') + if printframe == -1: a = sys.stdin.read() + elif 0 < printframe and printframe < nrframe: + break diff --git a/tests/python/bench/tempo/demo-tempo-acf b/tests/python/bench/tempo/demo-tempo-acf new file mode 100755 index 00000000..e099b81c --- /dev/null +++ b/tests/python/bench/tempo/demo-tempo-acf @@ -0,0 +1,157 @@ +#! /usr/bin/python + +""" this file was written by Paul Brossier + it is released under the GNU/GPL license. +""" + +import sys,time +from aubio.task import taskbeat,taskparams +from aubio.aubioclass import fvec, aubio_autocorr +from aubio.gnuplot import gnuplot_create, gnuplot_addargs +from aubio.aubiowrapper import * +from math import exp,log + +usage = "usage: %s [options] -i soundfile" % sys.argv[0] + +def parse_args(): + from optparse import OptionParser + parser = OptionParser(usage=usage) + parser.add_option("-i","--input", + action="store", dest="filename", + help="input sound file") + parser.add_option("-n","--printframe", + action="store", dest="printframe", default=-1, + help="make a plot of the n_th frame") + gnuplot_addargs(parser) + (options, args) = parser.parse_args() + if not options.filename: + print "no file name given\n", usage + sys.exit(1) + return options, args + +def plotdata(x,y,plottitle="",**keyw): + import Gnuplot + return Gnuplot.Data(x, y, title="%s" % plottitle,**keyw) + +options, args = parse_args() +filename = options.filename +xsize = float(options.xsize) +ysize = float(options.ysize) + +printframe = int(options.printframe) + +if options.outplot and printframe > 0: + extension = options.outplot.split('.')[-1] + outplot = '.'.join(options.outplot.split('.')[:-1]) +else: + extension = '' + outplot = None +f = gnuplot_create(outplot,extension,options) + +params = taskparams() +params.onsetmode = 'specdiff' +task = taskbeat(filename,params=params) + +hopsize = params.hopsize +bufsize = params.bufsize +btstep = task.btstep +winlen = task.btwinlen +laglen = winlen/4 +step = winlen/4 + +timesig = 0 +maxnumelem = 4 +gp = 0 +counter = 0 +flagconst = 0 +constthresh = 3.901 +g_var = 3.901 +rp = 0 +rp1 = 0 +rp2 = 0 +g_mu = 0 + +rayparam = 48/512.*winlen + +t = [i for i in range(hopsize)] +#tlong = [i for i in range(hopsize*(btstep-1))] +#tall = [i for i in range(hopsize*btstep)] +sig = [0 for i in range(hopsize*btstep*4)] +dfx = [i for i in range(winlen)] +dfframe = [0 for i in range(winlen)] +dfrev = [0 for i in range(winlen)] +acframe = [0 for i in range(winlen/2)] + +localacf = [0 for i in range(winlen)] +inds = [0 for i in range(maxnumelem)] + +acx = [i for i in range(laglen)] +acfout = [0 for i in range(laglen)] + +phwv = [0 for i in range(2*laglen)] +phwvx = [i for i in range(2*laglen)] + +dfwvnorm = exp(log(2.0)*(winlen+2.)/rayparam); +dfwv = [exp(log(2.)*(i+1.)/rayparam)/dfwvnorm for i in range(winlen)] + +gwv = [exp(-.5*(j+1.-g_mu)**2/g_var**2) for j in range(laglen)] +rwv = [(i+1.)/rayparam**2 * exp(-(i+1.)**2 / (2.*rayparam)**2) + for i in range(0,laglen)] +acf = fvec(winlen,1) + +nrframe = 0 +while (task.readsize == params.hopsize): + task() + #print task.pos2 + sig[:-hopsize] = [i for i in sig[-(btstep*4-1)*hopsize:]] + sig[-hopsize:] = [task.myvec.get(i,0) for i in t] + + #g('set xrange [%f:%f]' % (t[0],t[-1])) + #time.sleep(.2) + if task.pos2==btstep-1: + nrframe += 1 + dfframe = [task.dfframe.get(i,0) for i in range(winlen)] + # start beattracking_do + for i in range(winlen): + dfrev[winlen-1-i] = 0. + dfrev[winlen-1-i] = dfframe[i]*dfwv[i] + aubio_autocorr(task.dfframe(),acf()); + acframe = [acf.get(i,0) for i in range(winlen/2)] + if printframe == nrframe or printframe == -1: + d = [[plotdata(range(0,btstep*hopsize*4,4),sig[0:-1:4],plottitle="input signal", with='lines')]] + d += [[plotdata(range(-winlen,0),dfframe,plottitle="onset detection", with='lines')]] + d += [[plotdata(range(winlen/2),acframe,plottitle="autocorrelation", with='lines')]] + + # plot all this + if printframe == nrframe or printframe == -1: + + f('set lmargin 4') + f('set rmargin 4') + f('set size %f,%f' % (1.0*xsize,1.0*ysize) ) + f('set key spacing 1.3') + f('set multiplot') + + f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) + f('set orig %f,%f' % (0.0*xsize,0.66*ysize) ) + f('set xrange [%f:%f]' % (0,btstep*hopsize*4) ) + f('set yrange [%f:%f]' % (-1.2*max(sig),1.2*max(sig)) ) + f.title('Input signal') + f.xlabel('time (samples)') + f.plot(*d[0]) + f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) + f('set orig %f,%f' % (0.0*xsize,0.33*ysize) ) + f('set xrange [%f:%f]' % (-winlen,0) ) + f('set autoscale y') + f.title('Onset detection function') + f.xlabel('time (df samples)') + f.plot(*d[1]) + f('set size %f,%f' % (1.0*xsize,0.33*ysize) ) + f('set orig %f,%f' % (0.0*xsize,0.00*ysize) ) + f('set xrange [%f:%f]' % (0,winlen/2) ) + f.title('Autocorrelation') + f.xlabel('lag (df samples)') + f.plot(*d[2]) + f('set nomultiplot') + if printframe == -1: a = sys.stdin.read() + elif 0 < printframe and printframe < nrframe: + break diff --git a/tests/python/cvec.py b/tests/python/cvec.py new file mode 100644 index 00000000..f1043004 --- /dev/null +++ b/tests/python/cvec.py @@ -0,0 +1,51 @@ +import unittest + +from aubio.aubiowrapper import * + +buf_size = 2048 +channels = 3 + +class cvec_test_case(unittest.TestCase): + + def setUp(self): + self.vector = new_cvec(buf_size, channels) + + def tearDown(self): + del_cvec(self.vector) + + def test_cvec(self): + """ create and delete cvec """ + pass + + def test_cvec_read_norm(self): + """ check new cvec norm elements are set to 0. """ + for index in range(buf_size/2+1): + for channel in range(channels): + self.assertEqual(cvec_read_norm(self.vector,channel,index),0.) + + def test_cvec_read_phas(self): + """ check new cvec phas elements are set to 0. """ + for index in range(buf_size/2+1): + for channel in range(channels): + self.assertEqual(cvec_read_phas(self.vector,channel,index),0.) + + def test_cvec_write_norm(self): + """ check new cvec norm elements are set with cvec_write_norm """ + for index in range(buf_size/2+1): + for channel in range(channels): + cvec_write_norm(self.vector,1.,channel,index) + for index in range(buf_size/2+1): + for channel in range(channels): + self.assertEqual(cvec_read_norm(self.vector,channel,index),1.) + + def test_cvec_write_phas(self): + """ check new cvec phas elements are set with cvec_write_phas """ + for index in range(buf_size/2+1): + for channel in range(channels): + cvec_write_phas(self.vector,1.,channel,index) + for index in range(buf_size/2+1): + for channel in range(channels): + self.assertEqual(cvec_read_phas(self.vector,channel,index),1.) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/python/fvec.py b/tests/python/fvec.py new file mode 100644 index 00000000..5159af93 --- /dev/null +++ b/tests/python/fvec.py @@ -0,0 +1,36 @@ +import unittest + +from aubio.aubiowrapper import * + +buf_size = 2048 +channels = 3 + +class fvec_test_case(unittest.TestCase): + + def setUp(self): + self.vector = new_fvec(buf_size, channels) + + def tearDown(self): + del_fvec(self.vector) + + def test_fvec(self): + """ create and delete fvec """ + pass + + def test_fvec_read_sample(self): + """ check new fvec elements are set to 0. """ + for index in range(buf_size): + for channel in range(channels): + self.assertEqual(fvec_read_sample(self.vector,channel,index),0.) + + def test_fvec_write_sample(self): + """ check new fvec elements are set with fvec_write_sample """ + for index in range(buf_size): + for channel in range(channels): + fvec_write_sample(self.vector,1.,channel,index) + for index in range(buf_size): + for channel in range(channels): + self.assertEqual(fvec_read_sample(self.vector,channel,index),1.) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/python/run_all_tests b/tests/python/run_all_tests new file mode 100755 index 00000000..f09eaec3 --- /dev/null +++ b/tests/python/run_all_tests @@ -0,0 +1,17 @@ +#! /usr/bin/python + +# add ${src}/python and ${src}/python/aubio/.libs to python path +# so the script is runnable from a compiled source tree. +import sys, os + +cur_dir = os.path.dirname(sys.argv[0]) +sys.path.append(os.path.join(cur_dir,'..','..','python')) +sys.path.append(os.path.join(cur_dir,'..','..','python','aubio','.libs')) + +import unittest + +modules_to_test = ['aubiomodule', 'fvec', 'cvec'] + +if __name__ == '__main__': + for module in modules_to_test: exec('from %s import *' % module) + unittest.main() diff --git a/tests/src/Makefile.am b/tests/src/Makefile.am new file mode 100644 index 00000000..7c44abfb --- /dev/null +++ b/tests/src/Makefile.am @@ -0,0 +1,36 @@ +AM_CFLAGS = -I$(top_srcdir)/src +AM_LDFLAGS = -L$(top_builddir)/src -laubio @FFTWLIB_LIBS@ + +test_phasevoc_jack_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/ext @JACK_CFLAGS@ +test_phasevoc_jack_LDADD = $(AM_LDFLAGS) -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) 2>&1; 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/tests/src/test-beattracking.c b/tests/src/test-beattracking.c new file mode 100644 index 00000000..2812a3b0 --- /dev/null +++ b/tests/src/test-beattracking.c @@ -0,0 +1,39 @@ +#include + +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; + + smpl_t curtempo, curtempoconf; + + while (i < 10) { + aubio_beattracking_do(tempo,in,out); + curtempo = aubio_beattracking_get_bpm(tempo); + if (curtempo != 0.) { + fprintf(stdout,"%f\n",curtempo); + return 1; + } + curtempoconf = aubio_beattracking_get_confidence(tempo); + if (curtempoconf != 0.) { + fprintf(stdout,"%f\n",curtempo); + return 1; + } + i++; + }; + + del_aubio_beattracking(tempo); + del_fvec(in); + del_fvec(out); + aubio_cleanup(); + + return 0; +} + diff --git a/tests/src/test-biquad.c b/tests/src/test-biquad.c new file mode 100644 index 00000000..319e2307 --- /dev/null +++ b/tests/src/test-biquad.c @@ -0,0 +1,16 @@ +#include + +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/tests/src/test-fft.c b/tests/src/test-fft.c new file mode 100644 index 00000000..17adeb58 --- /dev/null +++ b/tests/src/test-fft.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include + +#define NEW_ARRAY(_t,_n) (_t*)malloc((_n)*sizeof(_t)) + + +int main(){ + uint_t i,j; + /* 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 * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ + fvec_t * out = new_fvec (win_s, channels); /* output buffer */ + + /* allocate fft and other memory space */ + aubio_fft_t * fft = new_aubio_fft(win_s); /* fft interface */ + smpl_t * w = NEW_ARRAY(smpl_t,win_s); /* window */ + /* complex spectral data */ + fft_data_t ** spec = NEW_ARRAY(fft_data_t*,channels); + for (i=0; i < channels; i++) + spec[i] = NEW_ARRAY(fft_data_t,win_s); + /* initialize the window (see mathutils.c) */ + aubio_window(w,win_s,aubio_win_hanningz); + + /* fill input with some data */ + in->data[0][win_s/2] = 1; + + /* execute stft */ + for (i=0; i < channels; i++) { + aubio_fft_do (fft,in->data[i],spec[i],win_s); + /* put norm and phase into fftgrain */ + aubio_fft_getnorm(fftgrain->norm[i], spec[i], win_s/2+1); + aubio_fft_getphas(fftgrain->phas[i], spec[i], win_s/2+1); + } + + /* execute inverse fourier transform */ + for (i=0; i < channels; i++) { + for (j=0; jphas[i][j])); + spec[i][j] *= fftgrain->norm[i][j]; + } + aubio_fft_rdo(fft,spec[i],out->data[i],win_s); + } + + del_fvec(in); + del_fvec(out); + del_cvec(fftgrain); + free(w); + del_aubio_fft(fft); + for (i=0; i < channels; i++) + free(spec[i]); + free(spec); + aubio_cleanup(); + return 0; +} diff --git a/tests/src/test-filter.c b/tests/src/test-filter.c new file mode 100644 index 00000000..37dd8d05 --- /dev/null +++ b/tests/src/test-filter.c @@ -0,0 +1,23 @@ +#include + +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/tests/src/test-hist.c b/tests/src/test-hist.c new file mode 100644 index 00000000..e739b3e7 --- /dev/null +++ b/tests/src/test-hist.c @@ -0,0 +1,38 @@ +#include +#include + +void print_array(fvec_t *f); +void print_array(fvec_t *f){ + uint i,j; + for (i=0;ichannels;i++){ + for (j=0;jlength;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/tests/src/test-mfft.c b/tests/src/test-mfft.c new file mode 100644 index 00000000..c2ec9f7e --- /dev/null +++ b/tests/src/test-mfft.c @@ -0,0 +1,28 @@ + +#include + +int main(){ + /* allocate some memory */ + uint_t win_s = 4096; /* window size */ + uint_t channels = 100; /* number of channels */ + fvec_t * in = new_fvec (win_s, channels); /* input buffer */ + cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ + fvec_t * out = new_fvec (win_s, channels); /* output buffer */ + /* allocate fft and other memory space */ + aubio_mfft_t * fft = new_aubio_mfft(win_s,channels); + /* fill input with some data */ + //printf("initialised\n"); + /* execute stft */ + aubio_mfft_do (fft,in,fftgrain); + //printf("computed forward\n"); + /* execute inverse fourier transform */ + aubio_mfft_rdo(fft,fftgrain,out); + //printf("computed backard\n"); + del_aubio_mfft(fft); + del_fvec(in); + del_cvec(fftgrain); + del_fvec(out); + //printf("memory freed\n"); + aubio_cleanup(); + return 0; +} diff --git a/tests/src/test-onset.c b/tests/src/test-onset.c new file mode 100644 index 00000000..c26ccdcc --- /dev/null +++ b/tests/src/test-onset.c @@ -0,0 +1,23 @@ +#include + +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/tests/src/test-onsetdetection.c b/tests/src/test-onsetdetection.c new file mode 100644 index 00000000..0efa3639 --- /dev/null +++ b/tests/src/test-onsetdetection.c @@ -0,0 +1,54 @@ + +#include + +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/tests/src/test-peakpick.c b/tests/src/test-peakpick.c new file mode 100644 index 00000000..736f394e --- /dev/null +++ b/tests/src/test-peakpick.c @@ -0,0 +1,19 @@ +#include + +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/tests/src/test-phasevoc-jack.c b/tests/src/test-phasevoc-jack.c new file mode 100644 index 00000000..00570686 --- /dev/null +++ b/tests/src/test-phasevoc-jack.c @@ -0,0 +1,84 @@ +/* test sample for phase vocoder + * + * this program should start correctly using JACK_START_SERVER=true and + * reconstruct each audio input frame perfectly on the corresponding input with + * a delay equal to the window size, hop_s. + */ + +#include /* pause() or sleep() */ +#include +#include + +uint_t win_s = 32; /* window size */ +uint_t hop_s = 8; /* hop size */ +uint_t channels = 4; /* number of channels */ +uint_t pos = 0; /* frames%dspblocksize for jack loop */ + +fvec_t * in; +cvec_t * fftgrain; +fvec_t * out; + +aubio_pvoc_t * pv; + +#ifdef JACK_SUPPORT +aubio_jack_t * jack_setup; +#endif + +int aubio_process(float **input, float **output, int nframes); + +int main(){ + /* allocate some memory */ + in = new_fvec (hop_s, channels); /* input buffer */ + fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ + out = new_fvec (hop_s, channels); /* output buffer */ + /* allocate fft and other memory space */ + pv = new_aubio_pvoc(win_s,hop_s,channels); + /* fill input with some data */ + printf("initialised\n"); + /* execute stft */ + aubio_pvoc_do (pv,in,fftgrain); + printf("computed forward\n"); + /* execute inverse fourier transform */ + aubio_pvoc_rdo(pv,fftgrain,out); + printf("computed backard\n"); + +#ifdef JACK_SUPPORT + jack_setup = new_aubio_jack(channels, channels, + (aubio_process_func_t)aubio_process); + aubio_jack_activate(jack_setup); + sleep(10); //pause(); /* enter main jack loop */ + aubio_jack_close(jack_setup); +#endif + + del_aubio_pvoc(pv); + del_cvec(fftgrain); + del_fvec(in); + del_fvec(out); + aubio_cleanup(); + printf("memory freed\n"); + return 0; +} + +int aubio_process(float **input, float **output, int nframes) { + uint_t i; /*channels*/ + uint_t j; /*frames*/ + for (j=0;j<(unsigned)nframes;j++) { + for (i=0;ilength;i++) fftgrain->phas[0][i] *= 2.; + //for (i=0;ilength;i++) fftgrain->phas[0][i] = 0.; + aubio_pvoc_rdo(pv,fftgrain,out); + pos = -1; + } + pos++; + } + return 0; +} diff --git a/tests/src/test-phasevoc.c b/tests/src/test-phasevoc.c new file mode 100644 index 00000000..3914bef9 --- /dev/null +++ b/tests/src/test-phasevoc.c @@ -0,0 +1,30 @@ +/* test sample for phase vocoder */ + +#include + +int main(){ + uint_t win_s = 1024; /* window size */ + uint_t hop_s = 256; /* hop size */ + uint_t channels = 4; /* number of channels */ + /* allocate some memory */ + fvec_t * in = new_fvec (hop_s, channels); /* input buffer */ + cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ + fvec_t * out = new_fvec (hop_s, channels); /* output buffer */ + /* allocate fft and other memory space */ + aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s,channels); + /* fill input with some data */ + printf("initialised\n"); + /* execute stft */ + aubio_pvoc_do (pv,in,fftgrain); + printf("computed forward\n"); + /* execute inverse fourier transform */ + aubio_pvoc_rdo(pv,fftgrain,out); + printf("computed backard\n"); + del_aubio_pvoc(pv); + del_fvec(in); + del_cvec(fftgrain); + del_fvec(out); + aubio_cleanup(); + printf("memory freed\n"); + return 0; +} diff --git a/tests/src/test-pitchdetection.c b/tests/src/test-pitchdetection.c new file mode 100644 index 00000000..71f8120e --- /dev/null +++ b/tests/src/test-pitchdetection.c @@ -0,0 +1,27 @@ +#include + +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/tests/src/test-pitchfcomb.c b/tests/src/test-pitchfcomb.c new file mode 100644 index 00000000..be59ec7f --- /dev/null +++ b/tests/src/test-pitchfcomb.c @@ -0,0 +1,25 @@ +#include + +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/tests/src/test-pitchmcomb.c b/tests/src/test-pitchmcomb.c new file mode 100644 index 00000000..a05ab7aa --- /dev/null +++ b/tests/src/test-pitchmcomb.c @@ -0,0 +1,24 @@ +#include + +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/tests/src/test-pitchschmitt.c b/tests/src/test-pitchschmitt.c new file mode 100644 index 00000000..8a61c5c5 --- /dev/null +++ b/tests/src/test-pitchschmitt.c @@ -0,0 +1,23 @@ +#include + +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/tests/src/test-pitchyin.c b/tests/src/test-pitchyin.c new file mode 100644 index 00000000..5766a71e --- /dev/null +++ b/tests/src/test-pitchyin.c @@ -0,0 +1,24 @@ +#include + +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/tests/src/test-pitchyinfft.c b/tests/src/test-pitchyinfft.c new file mode 100644 index 00000000..dfb8fc61 --- /dev/null +++ b/tests/src/test-pitchyinfft.c @@ -0,0 +1,22 @@ +#include + +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/tests/src/test-resample.c b/tests/src/test-resample.c new file mode 100644 index 00000000..48a50552 --- /dev/null +++ b/tests/src/test-resample.c @@ -0,0 +1,23 @@ +#include + +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/tests/src/test-sample.c b/tests/src/test-sample.c new file mode 100644 index 00000000..d31c1d2a --- /dev/null +++ b/tests/src/test-sample.c @@ -0,0 +1,14 @@ +#include + +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/tests/src/test-scale.c b/tests/src/test-scale.c new file mode 100644 index 00000000..c35111b5 --- /dev/null +++ b/tests/src/test-scale.c @@ -0,0 +1,21 @@ +#include + +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/tests/src/test-tempo.c b/tests/src/test-tempo.c new file mode 100644 index 00000000..53906720 --- /dev/null +++ b/tests/src/test-tempo.c @@ -0,0 +1,35 @@ +#include + +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; + + smpl_t curtempo, curtempoconf; + + while (i < 1000) { + aubio_tempo(o,in,out); + curtempo = aubio_tempo_get_bpm(o); + if (curtempo != 0.) { + fprintf(stdout,"%f\n",curtempo); + return 1; + } + curtempoconf = aubio_beattracking_get_confidence(o); + if (curtempoconf != 0.) { + fprintf(stdout,"%f\n",curtempo); + return 1; + } + i++; + }; + + del_aubio_tempo(o); + del_fvec(in); + del_fvec(out); + aubio_cleanup(); + + return 0; +} diff --git a/tests/src/test-tss.c b/tests/src/test-tss.c new file mode 100644 index 00000000..a9cc335e --- /dev/null +++ b/tests/src/test-tss.c @@ -0,0 +1,47 @@ +/* test sample for phase vocoder + * + * this program should start correctly using JACK_START_SERVER=true and + * reconstruct each audio input frame perfectly on the corresponding input with + * a delay equal to the window size, hop_s. + */ + +#include + +int main(){ + int i; + uint_t win_s = 1024; /* window size */ + uint_t hop_s = 256; /* hop size */ + uint_t channels = 4; /* number of channels */ + /* allocate some memory */ + fvec_t * in = new_fvec (hop_s, channels); /* input buffer */ + cvec_t * fftgrain = new_cvec (win_s, channels); /* fft norm and phase */ + cvec_t * cstead = new_cvec (win_s, channels); /* fft norm and phase */ + cvec_t * ctrans = new_cvec (win_s, channels); /* fft norm and phase */ + fvec_t * stead = new_fvec (hop_s, channels); /* output buffer */ + fvec_t * trans = new_fvec (hop_s, channels); /* output buffer */ + /* allocate fft and other memory space */ + aubio_pvoc_t * pv = new_aubio_pvoc (win_s,hop_s,channels); + aubio_pvoc_t * pvt = new_aubio_pvoc(win_s,hop_s,channels); + aubio_pvoc_t * pvs = new_aubio_pvoc(win_s,hop_s,channels); + + aubio_tss_t * tss = new_aubio_tss(0.01,3.,4.,win_s,hop_s,channels); + /* fill input with some data */ + printf("initialised\n"); + /* execute stft */ + for (i = 0; i < 10; i++) { + aubio_pvoc_do (pv,in,fftgrain); + aubio_tss_do (tss,fftgrain,ctrans,cstead); + aubio_pvoc_rdo(pvt,cstead,stead); + aubio_pvoc_rdo(pvs,ctrans,trans); + } + del_aubio_pvoc(pv); + del_fvec(in); + del_cvec(fftgrain); + del_cvec(cstead); + del_cvec(ctrans); + del_fvec(stead); + del_fvec(trans); + aubio_cleanup(); + printf("memory freed\n"); + return 0; +} diff --git a/tests/src/test-window.c b/tests/src/test-window.c new file mode 100644 index 00000000..62011446 --- /dev/null +++ b/tests/src/test-window.c @@ -0,0 +1,37 @@ +#include +#include + +void print_array(fvec_t *f); +void print_array(fvec_t *f){ + uint i,j; + for (i=0;ichannels;i++) + { + for (j=0;jlength;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; +} +