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