Showing the changes to tests (6 of 53 files). Show all
Unified · Split
| @@ -25,21 +25,25 @@ int base_main(int argc, char **argv) · 24 unmodified lines | |||
| 25 | char_t *source_path = argv[1]; | 25 | char_t *source_path = argv[1]; |
| 26 | char_t *sink_path = argv[2]; | 26 | char_t *sink_path = argv[2]; |
| 27 | 27 | ||
| 28 | aubio_source_t *src = NULL; | ||
| 29 | aubio_sink_custom_t *snk = NULL; | ||
| 30 | |||
| 28 | if ( argc >= 4 ) samplerate = atoi(argv[3]); | 31 | if ( argc >= 4 ) samplerate = atoi(argv[3]); |
| 29 | if ( argc >= 5 ) hop_size = atoi(argv[4]); | 32 | if ( argc >= 5 ) hop_size = atoi(argv[4]); |
| 30 | 33 | ||
| 31 | fvec_t *vec = new_fvec(hop_size); | 34 | fvec_t *vec = new_fvec(hop_size); |
| 35 | if (!vec) { err = 1; goto failure; } | ||
| 32 | 36 | ||
| 33 | aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); | 37 | src = new_aubio_source(source_path, samplerate, hop_size); |
| 34 | if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); | 38 | if (!src) { err = 1; goto failure; } |
| 35 | 39 | if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(src); | |
| 36 | aubio_sink_custom_t *o = new_aubio_sink_custom(sink_path, samplerate); | ||
| 37 | 40 | ||
| 38 | if (!vec || !i || !o) { err = 1; goto failure; } | 41 | snk = new_aubio_sink_custom(sink_path, samplerate); |
| 42 | if (!snk) { err = 1; goto failure; } | ||
| 39 | 43 | ||
| 40 | do { | 44 | do { |
| 41 | aubio_source_do(i, vec, &read); | 45 | aubio_source_do(src, vec, &read); |
| 42 | aubio_sink_custom_do(o, vec, read); | 46 | aubio_sink_custom_do(snk, vec, read); |
| 43 | n_frames += read; | 47 | n_frames += read; |
| 44 | } while ( read == hop_size ); | 48 | } while ( read == hop_size ); |
| 45 | 49 | ||
| @@ -48,13 +52,13 @@ int base_main(int argc, char **argv) · 2 unmodified lines | |||
| 48 | source_path, sink_path); | 52 | source_path, sink_path); |
| 49 | 53 | ||
| 50 | // close sink now (optional) | 54 | // close sink now (optional) |
| 51 | aubio_sink_custom_close(o); | 55 | aubio_sink_custom_close(snk); |
| 52 | 56 | ||
| 53 | failure: | 57 | failure: |
| 54 | if (o) | 58 | if (snk) |
| 55 | del_aubio_sink_custom(o); | 59 | del_aubio_sink_custom(snk); |
| 56 | if (i) | 60 | if (src) |
| 57 | del_aubio_source(i); | 61 | del_aubio_source(src); |
| 58 | if (vec) | 62 | if (vec) |
| 59 | del_fvec(vec); | 63 | del_fvec(vec); |
| 60 | 64 | ||
| @@ -21,21 +21,25 @@ int main(int argc, char **argv) · 20 unmodified lines | |||
| 21 | char_t *source_path = argv[1]; | 21 | char_t *source_path = argv[1]; |
| 22 | char_t *sink_path = argv[2]; | 22 | char_t *sink_path = argv[2]; |
| 23 | 23 | ||
| 24 | aubio_source_t *src = NULL; | ||
| 25 | aubio_sink_t *snk = NULL; | ||
| 26 | |||
| 24 | if ( argc >= 4 ) samplerate = atoi(argv[3]); | 27 | if ( argc >= 4 ) samplerate = atoi(argv[3]); |
| 25 | if ( argc >= 5 ) hop_size = atoi(argv[4]); | 28 | if ( argc >= 5 ) hop_size = atoi(argv[4]); |
| 26 | 29 | ||
| 27 | fvec_t *vec = new_fvec(hop_size); | 30 | fvec_t *vec = new_fvec(hop_size); |
| 31 | if (!vec) { err = 1; goto failure; } | ||
| 28 | 32 | ||
| 29 | aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); | 33 | src = new_aubio_source(source_path, samplerate, hop_size); |
| 30 | if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); | 34 | if (!src) { err = 1; goto failure; } |
| 31 | 35 | if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(src); | |
| 32 | aubio_sink_t *o = new_aubio_sink(sink_path, samplerate); | ||
| 33 | 36 | ||
| 34 | if (!vec || !i || !o) { err = 1; goto failure; } | 37 | snk = new_aubio_sink(sink_path, samplerate); |
| 38 | if (!snk) { err = 1; goto failure; } | ||
| 35 | 39 | ||
| 36 | do { | 40 | do { |
| 37 | aubio_source_do(i, vec, &read); | 41 | aubio_source_do(src, vec, &read); |
| 38 | aubio_sink_do(o, vec, read); | 42 | aubio_sink_do(snk, vec, read); |
| 39 | n_frames += read; | 43 | n_frames += read; |
| 40 | } while ( read == hop_size ); | 44 | } while ( read == hop_size ); |
| 41 | 45 | ||
| @@ -44,13 +48,13 @@ int main(int argc, char **argv) · 2 unmodified lines | |||
| 44 | source_path, sink_path); | 48 | source_path, sink_path); |
| 45 | 49 | ||
| 46 | // close sink now (optional) | 50 | // close sink now (optional) |
| 47 | aubio_sink_close(o); | 51 | aubio_sink_close(snk); |
| 48 | 52 | ||
| 49 | failure: | 53 | failure: |
| 50 | if (o) | 54 | if (snk) |
| 51 | del_aubio_sink(o); | 55 | del_aubio_sink(snk); |
| 52 | if (i) | 56 | if (src) |
| 53 | del_aubio_source(i); | 57 | del_aubio_source(src); |
| 54 | if (vec) | 58 | if (vec) |
| 55 | del_fvec(vec); | 59 | del_fvec(vec); |
| 56 | 60 | ||
| @@ -69,21 +69,19 @@ int test_wrong_params(void) · 68 unmodified lines | |||
| 69 | uint_t hop_size = win_size / 2; | 69 | uint_t hop_size = win_size / 2; |
| 70 | uint_t samplerate = 44100; | 70 | uint_t samplerate = 44100; |
| 71 | // hop_size < 1 | 71 | // hop_size < 1 |
| 72 | if (new_aubio_onset("default", 5, 0, samplerate)) | 72 | if (new_aubio_onset("default", 5, 0, samplerate)) return 1; |
| 73 | return 1; | 73 | |
| 74 | // buf_size < 2 | 74 | // buf_size < 2 |
| 75 | if (new_aubio_onset("default", 1, 1, samplerate)) | 75 | if (new_aubio_onset("default", 1, 1, samplerate)) return 1; |
| 76 | return 1; | 76 | |
| 77 | // buf_size < hop_size | 77 | // buf_size < hop_size |
| 78 | if (new_aubio_onset("default", hop_size, win_size, samplerate)) | 78 | if (new_aubio_onset("default", hop_size, win_size, samplerate)) return 1; |
| 79 | return 1; | 79 | |
| 80 | // samplerate < 1 | 80 | // samplerate < 1 |
| 81 | if (new_aubio_onset("default", 1024, 512, 0)) | 81 | if (new_aubio_onset("default", 1024, 512, 0)) return 1; |
| 82 | return 1; | ||
| 83 | 82 | ||
| 84 | // specdesc creation failed | 83 | // specdesc creation failed |
| 85 | if (new_aubio_onset("abcd", win_size, win_size/2, samplerate)) | 84 | if (new_aubio_onset("abcd", win_size, win_size/2, samplerate)) return 1; |
| 86 | return 1; | ||
| 87 | 85 | ||
| 88 | aubio_onset_t *o; | 86 | aubio_onset_t *o; |
| 89 | 87 | ||
| @@ -92,8 +90,7 @@ int test_wrong_params(void) · 2 unmodified lines | |||
| 92 | if (o) del_aubio_onset(o); | 90 | if (o) del_aubio_onset(o); |
| 93 | 91 | ||
| 94 | o = new_aubio_onset("default", win_size, hop_size, samplerate); | 92 | o = new_aubio_onset("default", win_size, hop_size, samplerate); |
| 95 | if (!aubio_onset_set_default_parameters(o, "wrong_type")) | 93 | if (!aubio_onset_set_default_parameters(o, "wrong_type")) return 1; |
| 96 | return 1; | ||
| 97 | del_aubio_onset(o); | 94 | del_aubio_onset(o); |
| 98 | 95 | ||
| 99 | return run_on_default_source(main); | 96 | return run_on_default_source(main); |
| @@ -81,35 +81,28 @@ int test_wrong_params(void) · 80 unmodified lines | |||
| 81 | uint_t i; | 81 | uint_t i; |
| 82 | 82 | ||
| 83 | // test wrong method fails | 83 | // test wrong method fails |
| 84 | if (new_aubio_tempo("unexisting_method", win_size, hop_size, samplerate)) | 84 | if (new_aubio_tempo("undefined", win_size, hop_size, samplerate)) return 1; |
| 85 | return 1; | ||
| 86 | 85 | ||
| 87 | // test hop > win fails | 86 | // test hop > win fails |
| 88 | if (new_aubio_tempo("default", hop_size, win_size, samplerate)) | 87 | if (new_aubio_tempo("default", hop_size, win_size, samplerate)) return 1; |
| 89 | return 1; | ||
| 90 | 88 | ||
| 91 | // test null hop_size fails | 89 | // test null hop_size fails |
| 92 | if (new_aubio_tempo("default", win_size, 0, samplerate)) | 90 | if (new_aubio_tempo("default", win_size, 0, samplerate)) return 1; |
| 93 | return 1; | ||
| 94 | 91 | ||
| 95 | // test 1 buf_size fails | 92 | // test 1 buf_size fails |
| 96 | if (new_aubio_tempo("default", 1, 1, samplerate)) | 93 | if (new_aubio_tempo("default", 1, 1, samplerate)) return 1; |
| 97 | return 1; | ||
| 98 | 94 | ||
| 99 | // test null samplerate fails | 95 | // test null samplerate fails |
| 100 | if (new_aubio_tempo("default", win_size, hop_size, 0)) | 96 | if (new_aubio_tempo("default", win_size, hop_size, 0)) return 1; |
| 101 | return 1; | ||
| 102 | 97 | ||
| 103 | // test short sizes workaround | 98 | // test short sizes workaround |
| 104 | t = new_aubio_tempo("default", 2048, 2048, 500); | 99 | t = new_aubio_tempo("default", 2048, 2048, 500); |
| 105 | if (!t) | 100 | if (!t) return 1; |
| 106 | return 1; | ||
| 107 | 101 | ||
| 108 | del_aubio_tempo(t); | 102 | del_aubio_tempo(t); |
| 109 | 103 | ||
| 110 | t = new_aubio_tempo("default", win_size, hop_size, samplerate); | 104 | t = new_aubio_tempo("default", win_size, hop_size, samplerate); |
| 111 | if (!t) | 105 | if (!t) return 1; |
| 112 | return 1; | ||
| 113 | 106 | ||
| 114 | in = new_fvec(hop_size); | 107 | in = new_fvec(hop_size); |
| 115 | out = new_fvec(1); | 108 | out = new_fvec(1); |
| @@ -9,17 +9,13 @@ int main (void) · 8 unmodified lines | |||
| 9 | 9 | ||
| 10 | aubio_filter_t *o = new_aubio_filter_c_weighting (44100); | 10 | aubio_filter_t *o = new_aubio_filter_c_weighting (44100); |
| 11 | 11 | ||
| 12 | if (new_aubio_filter(0)) | 12 | if (new_aubio_filter(0)) return 1; |
| 13 | return 1; | ||
| 14 | 13 | ||
| 15 | if (aubio_filter_get_samplerate(o) != 44100) | 14 | if (aubio_filter_get_samplerate(o) != 44100) return 1; |
| 16 | return 1; | ||
| 17 | 15 | ||
| 18 | if (aubio_filter_set_c_weighting (o, -1) == 0) | 16 | if (aubio_filter_set_c_weighting (o, -1) == 0) return 1; |
| 19 | return 1; | ||
| 20 | 17 | ||
| 21 | if (aubio_filter_set_c_weighting (0, 32000) == 0) | 18 | if (aubio_filter_set_c_weighting (0, 32000) == 0) return 1; |
| 22 | return 1; | ||
| 23 | 19 | ||
| 24 | in->data[impulse_at] = 0.5; | 20 | in->data[impulse_at] = 0.5; |
| 25 | fvec_print (in); | 21 | fvec_print (in); |
| @@ -29,10 +25,9 @@ int main (void) · 3 unmodified lines | |||
| 29 | 25 | ||
| 30 | o = new_aubio_filter_a_weighting (32000); | 26 | o = new_aubio_filter_a_weighting (32000); |
| 31 | 27 | ||
| 32 | if (aubio_filter_set_a_weighting (o, -1) == 0) | 28 | if (aubio_filter_set_a_weighting (o, -1) == 0) return 1; |
| 33 | return 1; | 29 | |
| 34 | if (aubio_filter_set_a_weighting (0, 32000) == 0) | 30 | if (aubio_filter_set_a_weighting (0, 32000) == 0) return 1; |
| 35 | return 1; | ||
| 36 | 31 | ||
| 37 | in->data[impulse_at] = 0.5; | 32 | in->data[impulse_at] = 0.5; |
| 38 | fvec_print (in); | 33 | fvec_print (in); |
| @@ -1,24 +0,0 @@ | |||
| 1 | #include <stdlib.h> | ||
| 2 | #include "aubio.h" | ||
| 3 | |||
| 4 | // When creating an aubio object, the user should check whether the object is | ||
| 5 | // set NULL, indicating the creation failed and the object was not allocated. | ||
| 6 | |||
| 7 | int main (void) | ||
| 8 | { | ||
| 9 | uint_t return_code = 0; | ||
| 10 | fvec_t *f = new_fvec(-12); | ||
| 11 | cvec_t *c = new_cvec(-12); | ||
| 12 | lvec_t *l = new_lvec(-12); | ||
| 13 | aubio_fft_t *fft = new_aubio_fft(-12); | ||
| 14 | if (f != NULL) { | ||
| 15 | return_code = 1; | ||
| 16 | } else if (c != NULL) { | ||
| 17 | return_code = 2; | ||
| 18 | } else if (l != NULL) { | ||
| 19 | return_code = 3; | ||
| 20 | } else if (fft != NULL) { | ||
| 21 | return_code = 3; | ||
| 22 | } | ||
| 23 | return return_code; | ||
| 24 | } | ||