From: Paul Brossier Date: Mon, 2 May 2011 10:37:41 +0000 (+0200) Subject: tests/: move tests around X-Git-Tag: 0.4.0-beta1~464 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=5f9df779ec5b48595e64ca66979a6fe670b321c5;p=aubio.git tests/: move tests around --- diff --git a/tests/src/spectral/test-fft.c b/tests/src/spectral/test-fft.c new file mode 100644 index 00000000..a17b9778 --- /dev/null +++ b/tests/src/spectral/test-fft.c @@ -0,0 +1,34 @@ + +#include + +int main(){ + /* allocate some memory */ + uint_t win_s = 8; /* window size */ + fvec_t * in = new_fvec (win_s); /* input buffer */ + cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */ + fvec_t * out = new_fvec (win_s); /* output buffer */ + in->data[0] = 1; + in->data[1] = 2; + in->data[2] = 3; + in->data[3] = 4; + in->data[4] = 5; + in->data[5] = 6; + in->data[6] = 5; + in->data[7] = 6; + /* allocate fft and other memory space */ + aubio_fft_t * fft = new_aubio_fft(win_s); + /* fill input with some data */ + fvec_print(in); + /* execute stft */ + aubio_fft_do (fft,in,fftgrain); + cvec_print(fftgrain); + /* execute inverse fourier transform */ + aubio_fft_rdo(fft,fftgrain,out); + fvec_print(out); + del_aubio_fft(fft); + del_fvec(in); + del_cvec(fftgrain); + del_fvec(out); + aubio_cleanup(); + return 0; +} diff --git a/tests/src/tempo/test-beattracking.c b/tests/src/tempo/test-beattracking.c new file mode 100644 index 00000000..e4ac6dc7 --- /dev/null +++ b/tests/src/tempo/test-beattracking.c @@ -0,0 +1,41 @@ +#define AUBIO_UNSTABLE 1 + +#include +#include + +int main(){ + /* allocate some memory */ + uint_t win_s = 1024; /* window size */ + fvec_t * in = new_fvec (win_s); /* input buffer */ + fvec_t * out = new_fvec (win_s/4); /* input buffer */ + + /* allocate fft and other memory space */ + aubio_beattracking_t * tempo = new_aubio_beattracking(win_s); + + 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/tempo/test-tempo.c b/tests/src/tempo/test-tempo.c new file mode 100644 index 00000000..3a6c2831 --- /dev/null +++ b/tests/src/tempo/test-tempo.c @@ -0,0 +1,35 @@ +#include +#include + +int main(){ + /* allocate some memory */ + uint_t win_s = 1024; /* window size */ + fvec_t * in = new_fvec (win_s); /* input buffer */ + fvec_t * out = new_fvec (2); /* input buffer */ + aubio_tempo_t * o = new_aubio_tempo("complex", win_s, win_s/4, 44100.); + uint_t i = 0; + + smpl_t curtempo, curtempoconf; + + while (i < 1000) { + aubio_tempo_do(o,in,out); + curtempo = aubio_tempo_get_bpm(o); + if (curtempo != 0.) { + fprintf(stdout,"%f\n",curtempo); + return 1; + } + curtempoconf = aubio_tempo_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-beattracking.c b/tests/src/test-beattracking.c deleted file mode 100644 index e4ac6dc7..00000000 --- a/tests/src/test-beattracking.c +++ /dev/null @@ -1,41 +0,0 @@ -#define AUBIO_UNSTABLE 1 - -#include -#include - -int main(){ - /* allocate some memory */ - uint_t win_s = 1024; /* window size */ - fvec_t * in = new_fvec (win_s); /* input buffer */ - fvec_t * out = new_fvec (win_s/4); /* input buffer */ - - /* allocate fft and other memory space */ - aubio_beattracking_t * tempo = new_aubio_beattracking(win_s); - - 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-fft.c b/tests/src/test-fft.c deleted file mode 100644 index a17b9778..00000000 --- a/tests/src/test-fft.c +++ /dev/null @@ -1,34 +0,0 @@ - -#include - -int main(){ - /* allocate some memory */ - uint_t win_s = 8; /* window size */ - fvec_t * in = new_fvec (win_s); /* input buffer */ - cvec_t * fftgrain = new_cvec (win_s); /* fft norm and phase */ - fvec_t * out = new_fvec (win_s); /* output buffer */ - in->data[0] = 1; - in->data[1] = 2; - in->data[2] = 3; - in->data[3] = 4; - in->data[4] = 5; - in->data[5] = 6; - in->data[6] = 5; - in->data[7] = 6; - /* allocate fft and other memory space */ - aubio_fft_t * fft = new_aubio_fft(win_s); - /* fill input with some data */ - fvec_print(in); - /* execute stft */ - aubio_fft_do (fft,in,fftgrain); - cvec_print(fftgrain); - /* execute inverse fourier transform */ - aubio_fft_rdo(fft,fftgrain,out); - fvec_print(out); - del_aubio_fft(fft); - del_fvec(in); - del_cvec(fftgrain); - del_fvec(out); - aubio_cleanup(); - return 0; -} diff --git a/tests/src/test-tempo.c b/tests/src/test-tempo.c deleted file mode 100644 index 3a6c2831..00000000 --- a/tests/src/test-tempo.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -int main(){ - /* allocate some memory */ - uint_t win_s = 1024; /* window size */ - fvec_t * in = new_fvec (win_s); /* input buffer */ - fvec_t * out = new_fvec (2); /* input buffer */ - aubio_tempo_t * o = new_aubio_tempo("complex", win_s, win_s/4, 44100.); - uint_t i = 0; - - smpl_t curtempo, curtempoconf; - - while (i < 1000) { - aubio_tempo_do(o,in,out); - curtempo = aubio_tempo_get_bpm(o); - if (curtempo != 0.) { - fprintf(stdout,"%f\n",curtempo); - return 1; - } - curtempoconf = aubio_tempo_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; -}