History

Merge branch 'master' into feature/sink_vorbis

Paul Brossier committed 7 years ago

Commit f5adffe2 parents 0e6ad10 004566853 files · +405 −400Browse files

Showing the changes to tests/src (6 of 53 files). Show all

Unified · Split

6 files
  1. tests/src/io/base-sink_custom.h +16 −12
  2. tests/src/io/test-sink.c +16 −12
  3. tests/src/onset/test-onset.c +9 −12
  4. tests/src/tempo/test-tempo.c +7 −14
  5. tests/src/temporal/test-filter.c +7 −12
  6. tests/src/test-delnull.c +0 −24
tests/src/io/base-sink_custom.h+16−12
@@ -25,21 +25,25 @@ int base_main(int argc, char **argv) · 24 unmodified lines
2525 char_t *source_path = argv[1];
2626 char_t *sink_path = argv[2];
2727
28+ aubio_source_t *src = NULL;
29+ aubio_sink_custom_t *snk = NULL;
30+
2831 if ( argc >= 4 ) samplerate = atoi(argv[3]);
2932 if ( argc >= 5 ) hop_size = atoi(argv[4]);
3033
3134 fvec_t *vec = new_fvec(hop_size);
35+ if (!vec) { err = 1; goto failure; }
3236
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);
3740
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; }
3943
4044 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);
4347 n_frames += read;
4448 } while ( read == hop_size );
4549
@@ -48,13 +52,13 @@ int base_main(int argc, char **argv) · 2 unmodified lines
4852 source_path, sink_path);
4953
5054 // close sink now (optional)
51− aubio_sink_custom_close(o);
55+ aubio_sink_custom_close(snk);
5256
5357 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);
5862 if (vec)
5963 del_fvec(vec);
6064
tests/src/io/test-sink.c+16−12
@@ -21,21 +21,25 @@ int main(int argc, char **argv) · 20 unmodified lines
2121 char_t *source_path = argv[1];
2222 char_t *sink_path = argv[2];
2323
24+ aubio_source_t *src = NULL;
25+ aubio_sink_t *snk = NULL;
26+
2427 if ( argc >= 4 ) samplerate = atoi(argv[3]);
2528 if ( argc >= 5 ) hop_size = atoi(argv[4]);
2629
2730 fvec_t *vec = new_fvec(hop_size);
31+ if (!vec) { err = 1; goto failure; }
2832
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);
3336
34− if (!vec || !i || !o) { err = 1; goto failure; }
37+ snk = new_aubio_sink(sink_path, samplerate);
38+ if (!snk) { err = 1; goto failure; }
3539
3640 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);
3943 n_frames += read;
4044 } while ( read == hop_size );
4145
@@ -44,13 +48,13 @@ int main(int argc, char **argv) · 2 unmodified lines
4448 source_path, sink_path);
4549
4650 // close sink now (optional)
47− aubio_sink_close(o);
51+ aubio_sink_close(snk);
4852
4953 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);
5458 if (vec)
5559 del_fvec(vec);
5660
tests/src/onset/test-onset.c+9−12
@@ -69,21 +69,19 @@ int test_wrong_params(void) · 68 unmodified lines
6969 uint_t hop_size = win_size / 2;
7070 uint_t samplerate = 44100;
7171 // 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+
7474 // 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+
7777 // 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+
8080 // 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;
8382
8483 // 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;
8785
8886 aubio_onset_t *o;
8987
@@ -92,8 +90,7 @@ int test_wrong_params(void) · 2 unmodified lines
9290 if (o) del_aubio_onset(o);
9391
9492 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;
9794 del_aubio_onset(o);
9895
9996 return run_on_default_source(main);
tests/src/tempo/test-tempo.c+7−14
@@ -81,35 +81,28 @@ int test_wrong_params(void) · 80 unmodified lines
8181 uint_t i;
8282
8383 // 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;
8685
8786 // 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;
9088
9189 // 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;
9491
9592 // 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;
9894
9995 // 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;
10297
10398 // test short sizes workaround
10499 t = new_aubio_tempo("default", 2048, 2048, 500);
105− if (!t)
106− return 1;
100+ if (!t) return 1;
107101
108102 del_aubio_tempo(t);
109103
110104 t = new_aubio_tempo("default", win_size, hop_size, samplerate);
111− if (!t)
112− return 1;
105+ if (!t) return 1;
113106
114107 in = new_fvec(hop_size);
115108 out = new_fvec(1);
tests/src/temporal/test-filter.c+7−12
@@ -9,17 +9,13 @@ int main (void) · 8 unmodified lines
99
1010 aubio_filter_t *o = new_aubio_filter_c_weighting (44100);
1111
12− if (new_aubio_filter(0))
13− return 1;
12+ if (new_aubio_filter(0)) return 1;
1413
15− if (aubio_filter_get_samplerate(o) != 44100)
16− return 1;
14+ if (aubio_filter_get_samplerate(o) != 44100) return 1;
1715
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;
2017
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;
2319
2420 in->data[impulse_at] = 0.5;
2521 fvec_print (in);
@@ -29,10 +25,9 @@ int main (void) · 3 unmodified lines
2925
3026 o = new_aubio_filter_a_weighting (32000);
3127
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;
3631
3732 in->data[impulse_at] = 0.5;
3833 fvec_print (in);
tests/src/test-delnull.c+0−24
@@ -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−}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t