- Timestamp:
- Dec 19, 2018, 6:16:29 PM (6 years ago)
- Branches:
- feature/constantq
- Children:
- dfe6ab6
- Parents:
- f87e191 (diff), fda3394 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- tests/src
- Files:
-
- 3 added
- 7 deleted
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/src/io/test-sink.c
rf87e191 r868c6b8 2 2 #include "utils_tests.h" 3 3 4 int main (int argc, char **argv) 4 int test_wrong_params(void); 5 6 int main(int argc, char **argv) 5 7 { 6 sint_t err = 0;7 8 if (argc < 3) {9 err = 2;10 PRINT_ ERR("not enough arguments\n");11 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n",argv[0]);8 uint_t err = 0; 9 if (argc < 3 || argc >= 6) { 10 PRINT_ERR("wrong number of arguments, running tests\n"); 11 err = test_wrong_params(); 12 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", 13 argv[0]); 12 14 return err; 13 15 } … … 20 22 char_t *sink_path = argv[2]; 21 23 24 aubio_source_t *src = NULL; 25 aubio_sink_t *snk = NULL; 26 22 27 if ( argc >= 4 ) samplerate = atoi(argv[3]); 23 28 if ( argc >= 5 ) hop_size = atoi(argv[4]); 24 if ( argc >= 6 ) {25 err = 2;26 PRINT_ERR("too many arguments\n");27 return err;28 }29 29 30 30 fvec_t *vec = new_fvec(hop_size); 31 if (!vec) { err = 1; goto beach_fvec; }31 if (!vec) { err = 1; goto failure; } 32 32 33 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); 34 if (!i) { err = 1; goto beach_source; } 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); 35 36 36 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); 37 38 aubio_sink_t *o = new_aubio_sink(sink_path, samplerate); 39 if (!o) { err = 1; goto beach_sink; } 37 snk = new_aubio_sink(sink_path, samplerate); 38 if (!snk) { err = 1; goto failure; } 40 39 41 40 do { 42 aubio_source_do( i, vec, &read);43 aubio_sink_do( o, vec, read);41 aubio_source_do(src, vec, &read); 42 aubio_sink_do(snk, vec, read); 44 43 n_frames += read; 45 44 } while ( read == hop_size ); 46 45 47 PRINT_MSG(" read %d frames at %dHz (%d blocks) from %swritten to %s\n",46 PRINT_MSG("%d frames read at %dHz (%d blocks) from %s and written to %s\n", 48 47 n_frames, samplerate, n_frames / hop_size, 49 48 source_path, sink_path); 50 49 51 del_aubio_sink(o); 52 beach_sink: 53 del_aubio_source(i); 54 beach_source: 55 del_fvec(vec); 56 beach_fvec: 50 // close sink now (optional) 51 aubio_sink_close(snk); 52 53 failure: 54 if (snk) 55 del_aubio_sink(snk); 56 if (src) 57 del_aubio_source(src); 58 if (vec) 59 del_fvec(vec); 60 57 61 return err; 58 62 } 63 64 int test_wrong_params(void) 65 { 66 fvec_t *vec; 67 fmat_t *mat; 68 aubio_sink_t *s; 69 char_t sink_path[PATH_MAX] = "tmp_aubio_XXXXXX"; 70 uint_t samplerate = 44100; 71 uint_t hop_size = 256; 72 uint_t oversized_hop_size = 4097; 73 uint_t oversized_samplerate = 192000 * 8 + 1; 74 uint_t channels = 3; 75 uint_t oversized_channels = 1025; 76 // create temp file 77 int fd = create_temp_sink(sink_path); 78 79 if (!fd) return 1; 80 81 if (new_aubio_sink( 0, samplerate)) return 1; 82 if (new_aubio_sink("\0", samplerate)) return 1; 83 if (new_aubio_sink(sink_path, -1)) return 1; 84 85 s = new_aubio_sink(sink_path, 0); 86 87 // check setting wrong parameters fails 88 if (!aubio_sink_preset_samplerate(s, oversized_samplerate)) return 1; 89 if (!aubio_sink_preset_channels(s, oversized_channels)) return 1; 90 if (!aubio_sink_preset_channels(s, -1)) return 1; 91 92 // check setting valid parameters passes 93 if (aubio_sink_preset_samplerate(s, samplerate)) return 1; 94 if (aubio_sink_preset_channels(s, 1)) return 1; 95 96 // check writing a vector with valid length 97 vec = new_fvec(hop_size); 98 aubio_sink_do(s, vec, hop_size); 99 // check writing more than in the input 100 aubio_sink_do(s, vec, hop_size+1); 101 // check write 0 frames 102 aubio_sink_do(s, vec, 0); 103 del_fvec(vec); 104 105 // check writing an oversized vector 106 vec = new_fvec(oversized_hop_size); 107 aubio_sink_do(s, vec, oversized_hop_size); 108 del_fvec(vec); 109 110 // test delete without closing 111 del_aubio_sink(s); 112 113 s = new_aubio_sink(sink_path, 0); 114 115 // preset channels first 116 if (aubio_sink_preset_channels(s, channels)) return 1; 117 if (aubio_sink_preset_samplerate(s, samplerate)) return 1; 118 119 if (aubio_sink_get_samplerate(s) != samplerate) return 1; 120 if (aubio_sink_get_channels(s) != channels) return 1; 121 122 mat = new_fmat(channels, hop_size); 123 // check writing a vector with valid length 124 aubio_sink_do_multi(s, mat, hop_size); 125 // check writing 0 frames 126 aubio_sink_do_multi(s, mat, 0); 127 // check writing more than in the input 128 aubio_sink_do_multi(s, mat, hop_size+1); 129 del_fmat(mat); 130 131 // check writing oversized input 132 mat = new_fmat(channels, oversized_hop_size); 133 aubio_sink_do_multi(s, mat, oversized_hop_size); 134 del_fmat(mat); 135 136 // check writing undersized input 137 mat = new_fmat(channels - 1, hop_size); 138 aubio_sink_do_multi(s, mat, hop_size); 139 del_fmat(mat); 140 141 aubio_sink_close(s); 142 // test closing twice 143 aubio_sink_close(s); 144 145 del_aubio_sink(s); 146 147 // delete temp file 148 close_temp_sink(sink_path, fd); 149 150 return run_on_default_source_and_sink(main); 151 } -
tests/src/io/test-sink_apple_audio.c
rf87e191 r868c6b8 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_sink_custom "apple_audio" 6 7 #ifdef HAVE_SINK_APPLE_AUDIO 8 #define HAVE_AUBIO_SINK_CUSTOM 9 #define aubio_sink_custom_t aubio_sink_apple_audio_t 10 #define new_aubio_sink_custom new_aubio_sink_apple_audio 11 #define del_aubio_sink_custom del_aubio_sink_apple_audio 12 #define aubio_sink_custom_do aubio_sink_apple_audio_do 13 #define aubio_sink_custom_do_multi aubio_sink_apple_audio_do_multi 14 #define aubio_sink_custom_close aubio_sink_apple_audio_close 15 #define aubio_sink_custom_preset_samplerate aubio_sink_apple_audio_preset_samplerate 16 #define aubio_sink_custom_preset_channels aubio_sink_apple_audio_preset_channels 17 #define aubio_sink_custom_get_samplerate aubio_sink_apple_audio_get_samplerate 18 #define aubio_sink_custom_get_channels aubio_sink_apple_audio_get_channels 19 #endif /* HAVE_SINK_APPLE_AUDIO */ 20 21 #include "base-sink_custom.h" 4 22 5 23 // this file uses the unstable aubio api, please use aubio_sink instead … … 8 26 int main (int argc, char **argv) 9 27 { 10 sint_t err = 0; 11 12 if (argc < 3) { 13 err = 2; 14 PRINT_ERR("not enough arguments\n"); 15 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]); 16 return err; 17 } 18 19 #ifdef HAVE_SINK_APPLE_AUDIO 20 uint_t samplerate = 0; 21 uint_t hop_size = 512; 22 uint_t n_frames = 0, read = 0; 23 24 char_t *source_path = argv[1]; 25 char_t *sink_path = argv[2]; 26 27 if ( argc >= 4 ) samplerate = atoi(argv[3]); 28 if ( argc >= 5 ) hop_size = atoi(argv[4]); 29 if ( argc >= 6 ) { 30 err = 2; 31 PRINT_ERR("too many arguments\n"); 32 return err; 33 } 34 35 fvec_t *vec = new_fvec(hop_size); 36 if (!vec) { err = 1; goto beach_fvec; } 37 38 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); 39 if (!i) { err = 1; goto beach_source; } 40 41 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); 42 43 aubio_sink_apple_audio_t *o = new_aubio_sink_apple_audio(sink_path, samplerate); 44 if (!o) { err = 1; goto beach_sink; } 45 46 do { 47 aubio_source_do(i, vec, &read); 48 aubio_sink_apple_audio_do(o, vec, read); 49 n_frames += read; 50 } while ( read == hop_size ); 51 52 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n", 53 n_frames, samplerate, n_frames / hop_size, 54 source_path, sink_path); 55 56 del_aubio_sink_apple_audio(o); 57 beach_sink: 58 del_aubio_source(i); 59 beach_source: 60 del_fvec(vec); 61 beach_fvec: 62 #else /* HAVE_SINK_APPLE_AUDIO */ 63 err = 3; 64 PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n"); 65 #endif /* HAVE_SINK_APPLE_AUDIO */ 66 return err; 28 return base_main(argc, argv); 67 29 } -
tests/src/io/test-sink_sndfile.c
rf87e191 r868c6b8 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_sink_custom "sndfile" 6 7 #ifdef HAVE_SNDFILE 8 #define HAVE_AUBIO_SINK_CUSTOM 9 #define aubio_sink_custom_t aubio_sink_sndfile_t 10 #define new_aubio_sink_custom new_aubio_sink_sndfile 11 #define del_aubio_sink_custom del_aubio_sink_sndfile 12 #define aubio_sink_custom_do aubio_sink_sndfile_do 13 #define aubio_sink_custom_do_multi aubio_sink_sndfile_do_multi 14 #define aubio_sink_custom_close aubio_sink_sndfile_close 15 #define aubio_sink_custom_preset_samplerate aubio_sink_sndfile_preset_samplerate 16 #define aubio_sink_custom_preset_channels aubio_sink_sndfile_preset_channels 17 #define aubio_sink_custom_get_samplerate aubio_sink_sndfile_get_samplerate 18 #define aubio_sink_custom_get_channels aubio_sink_sndfile_get_channels 19 #endif /* HAVE_SNDFILE */ 20 21 #include "base-sink_custom.h" 4 22 5 23 // this file uses the unstable aubio api, please use aubio_sink instead … … 8 26 int main (int argc, char **argv) 9 27 { 10 sint_t err = 0; 11 12 if (argc < 3) { 13 err = 2; 14 PRINT_ERR("not enough arguments\n"); 15 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]); 16 return err; 17 } 18 19 #ifdef HAVE_SNDFILE 20 uint_t samplerate = 0; 21 uint_t hop_size = 512; 22 uint_t n_frames = 0, read = 0; 23 24 char_t *source_path = argv[1]; 25 char_t *sink_path = argv[2]; 26 27 if ( argc >= 4 ) samplerate = atoi(argv[3]); 28 if ( argc >= 5 ) hop_size = atoi(argv[4]); 29 if ( argc >= 6 ) { 30 err = 2; 31 PRINT_ERR("too many arguments\n"); 32 return err; 33 } 34 35 fvec_t *vec = new_fvec(hop_size); 36 if (!vec) { err = 1; goto beach_fvec; } 37 38 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); 39 if (!i) { err = 1; goto beach_source; } 40 41 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); 42 43 aubio_sink_sndfile_t *o = new_aubio_sink_sndfile(sink_path, samplerate); 44 if (!o) { err = 1; goto beach_sink; } 45 46 do { 47 aubio_source_do(i, vec, &read); 48 aubio_sink_sndfile_do(o, vec, read); 49 n_frames += read; 50 } while ( read == hop_size ); 51 52 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n", 53 n_frames, samplerate, n_frames / hop_size, 54 source_path, sink_path); 55 56 del_aubio_sink_sndfile(o); 57 beach_sink: 58 del_aubio_source(i); 59 beach_source: 60 del_fvec(vec); 61 beach_fvec: 62 #else 63 err = 3; 64 PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n"); 65 #endif /* HAVE_SNDFILE */ 66 return err; 28 return base_main(argc, argv); 67 29 } -
tests/src/io/test-sink_wavwrite.c
rf87e191 r868c6b8 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_sink_custom "wavwrite" 6 7 #ifdef HAVE_WAVWRITE 8 #define HAVE_AUBIO_SINK_CUSTOM 9 #define aubio_sink_custom_t aubio_sink_wavwrite_t 10 #define new_aubio_sink_custom new_aubio_sink_wavwrite 11 #define del_aubio_sink_custom del_aubio_sink_wavwrite 12 #define aubio_sink_custom_do aubio_sink_wavwrite_do 13 #define aubio_sink_custom_do_multi aubio_sink_wavwrite_do_multi 14 #define aubio_sink_custom_close aubio_sink_wavwrite_close 15 #define aubio_sink_custom_preset_samplerate aubio_sink_wavwrite_preset_samplerate 16 #define aubio_sink_custom_preset_channels aubio_sink_wavwrite_preset_channels 17 #define aubio_sink_custom_get_samplerate aubio_sink_wavwrite_get_samplerate 18 #define aubio_sink_custom_get_channels aubio_sink_wavwrite_get_channels 19 #endif /* HAVE_WAVWRITE */ 20 21 #include "base-sink_custom.h" 4 22 5 23 // this file uses the unstable aubio api, please use aubio_sink instead … … 8 26 int main (int argc, char **argv) 9 27 { 10 sint_t err = 0; 11 12 if (argc < 3) { 13 err = 2; 14 PRINT_ERR("not enough arguments\n"); 15 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]); 16 return err; 17 } 18 19 #ifdef HAVE_WAVWRITE 20 uint_t samplerate = 0; 21 uint_t hop_size = 512; 22 uint_t n_frames = 0, read = 0; 23 24 char_t *source_path = argv[1]; 25 char_t *sink_path = argv[2]; 26 27 if ( argc >= 4 ) samplerate = atoi(argv[3]); 28 if ( argc >= 5 ) hop_size = atoi(argv[4]); 29 if ( argc >= 6 ) { 30 err = 2; 31 PRINT_ERR("too many arguments\n"); 32 return err; 33 } 34 35 fvec_t *vec = new_fvec(hop_size); 36 if (!vec) { err = 1; goto beach_fvec; } 37 38 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size); 39 if (!i) { err = 1; goto beach_source; } 40 41 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i); 42 43 aubio_sink_wavwrite_t *o = new_aubio_sink_wavwrite(sink_path, samplerate); 44 if (!o) { err = 1; goto beach_sink; } 45 46 do { 47 aubio_source_do(i, vec, &read); 48 aubio_sink_wavwrite_do(o, vec, read); 49 n_frames += read; 50 } while ( read == hop_size ); 51 52 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n", 53 n_frames, samplerate, n_frames / hop_size, 54 source_path, sink_path); 55 56 del_aubio_sink_wavwrite(o); 57 beach_sink: 58 del_aubio_source(i); 59 beach_source: 60 del_fvec(vec); 61 beach_fvec: 62 #else 63 err = 3; 64 PRINT_ERR("aubio was not compiled with aubio_sink_wavwrite\n"); 65 #endif /* HAVE_WAVWRITE */ 66 return err; 28 return base_main(argc, argv); 67 29 } -
tests/src/io/test-source.c
rf87e191 r868c6b8 2 2 #include "utils_tests.h" 3 3 4 int main (int argc, char **argv) 4 int test_wrong_params(void); 5 6 int main(int argc, char **argv) 5 7 { 6 8 uint_t err = 0; 7 9 if (argc < 2) { 8 err = 2;9 PRINT_ERR("not enough arguments\n");10 PRINT_ERR("not enough arguments, running tests\n"); 11 err = test_wrong_params(); 10 12 PRINT_MSG("read a wave file as a mono vector\n"); 11 13 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); … … 23 25 uint_t hop_size = 256; 24 26 uint_t n_frames = 0, read = 0; 25 if ( argc == 3 ) samplerate = atoi(argv[2]);26 if ( argc == 4 ) hop_size = atoi(argv[3]);27 if ( argc >= 3 ) samplerate = atoi(argv[2]); 28 if ( argc >= 4 ) hop_size = atoi(argv[3]); 27 29 28 30 char_t *source_path = argv[1]; 29 31 30 31 32 aubio_source_t* s = 32 33 new_aubio_source(source_path, samplerate, hop_size); 33 if (!s) { err = 1; goto beach; }34 34 fvec_t *vec = new_fvec(hop_size); 35 if (!s || !vec) { err = 1; goto beach; } 35 36 36 37 uint_t n_frames_expected = aubio_source_get_duration(s); … … 50 51 // close the file (optional) 51 52 aubio_source_close(s); 53 54 beach: 55 if (vec) 56 del_fvec(vec); 57 if (s) 58 del_aubio_source(s); 59 return err; 60 } 61 62 int test_wrong_params(void) 63 { 64 char_t *uri = DEFINEDSTRING(AUBIO_TESTS_SOURCE); 65 uint_t samplerate = 44100; 66 uint_t hop_size = 512; 67 uint_t channels, read = 0; 68 fvec_t *vec; 69 fmat_t *mat; 70 aubio_source_t *s; 71 72 if (new_aubio_source(0, samplerate, hop_size)) return 1; 73 if (new_aubio_source("\0", samplerate, hop_size)) return 1; 74 if (new_aubio_source(uri, -1, hop_size)) return 1; 75 if (new_aubio_source(uri, 0, 0)) return 1; 76 77 s = new_aubio_source(uri, samplerate, hop_size); 78 if (!s) return 1; 79 channels = aubio_source_get_channels(s); 80 81 // vector to read downmixed samples 82 vec = new_fvec(hop_size); 83 // matrix to read individual channels 84 mat = new_fmat(channels, hop_size); 85 86 if (aubio_source_get_samplerate(s) != samplerate) return 1; 87 88 // read first hop_size frames 89 aubio_source_do(s, vec, &read); 90 if (read != hop_size) return 1; 91 92 // seek to 0 93 if(aubio_source_seek(s, 0)) return 1; 94 95 // read again as multiple channels 96 aubio_source_do_multi(s, mat, &read); 97 if (read != hop_size) return 1; 98 99 // close the file (optional) 100 aubio_source_close(s); 52 101 // test closing the file a second time 53 102 aubio_source_close(s); 54 103 55 del_fvec (vec); 56 del_aubio_source (s); 57 beach: 58 return err; 104 del_aubio_source(s); 105 del_fmat(mat); 106 del_fvec(vec); 107 108 return run_on_default_source(main); 59 109 } -
tests/src/io/test-source_apple_audio.c
rf87e191 r868c6b8 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_source_custom "apple_audio" 6 7 #ifdef HAVE_SOURCE_APPLE_AUDIO 8 #define HAVE_AUBIO_SOURCE_CUSTOM 9 #define aubio_source_custom_t aubio_source_apple_audio_t 10 #define new_aubio_source_custom new_aubio_source_apple_audio 11 #define del_aubio_source_custom del_aubio_source_apple_audio 12 #define aubio_source_custom_get_samplerate aubio_source_apple_audio_get_samplerate 13 #define aubio_source_custom_get_duration aubio_source_apple_audio_get_duration 14 #define aubio_source_custom_do aubio_source_apple_audio_do 15 #define aubio_source_custom_do_multi aubio_source_apple_audio_do_multi 16 #define aubio_source_custom_seek aubio_source_apple_audio_seek 17 #define aubio_source_custom_close aubio_source_apple_audio_close 18 #define aubio_source_custom_get_channels aubio_source_apple_audio_get_channels 19 #define aubio_source_custom_get_samplerate aubio_source_apple_audio_get_samplerate 20 #endif /* HAVE_SOURCE_APPLE_AUDIO */ 21 22 #include "base-source_custom.h" 4 23 5 24 // this file uses the unstable aubio api, please use aubio_source instead … … 8 27 int main (int argc, char **argv) 9 28 { 10 uint_t err = 0; 11 if (argc < 2) { 12 err = 2; 13 PRINT_ERR("not enough arguments\n"); 14 PRINT_MSG("read a wave file as a mono vector\n"); 15 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 16 PRINT_MSG("examples:\n"); 17 PRINT_MSG(" - read file.wav at original samplerate\n"); 18 PRINT_MSG(" %s file.wav\n", argv[0]); 19 PRINT_MSG(" - read file.aif at 32000Hz\n"); 20 PRINT_MSG(" %s file.aif 32000\n", argv[0]); 21 PRINT_MSG(" - read file.mp3 at original samplerate with 4096 blocks\n"); 22 PRINT_MSG(" %s file.mp3 0 4096 \n", argv[0]); 23 return err; 24 } 25 26 #if HAVE_SOURCE_APPLE_AUDIO 27 uint_t samplerate = 0; 28 uint_t hop_size = 256; 29 uint_t n_frames = 0, read = 0; 30 if ( argc == 3 ) samplerate = atoi(argv[2]); 31 if ( argc == 4 ) hop_size = atoi(argv[3]); 32 33 char_t *source_path = argv[1]; 34 35 36 aubio_source_apple_audio_t * s = 37 new_aubio_source_apple_audio(source_path, samplerate, hop_size); 38 if (!s) { err = 1; goto beach; } 39 fvec_t *vec = new_fvec(hop_size); 40 41 uint_t n_frames_expected = aubio_source_apple_audio_get_duration(s); 42 43 samplerate = aubio_source_apple_audio_get_samplerate(s); 44 45 do { 46 aubio_source_apple_audio_do(s, vec, &read); 47 fvec_print (vec); 48 n_frames += read; 49 } while ( read == hop_size ); 50 51 PRINT_MSG("read %d frames (expected %d) at %dHz (%d blocks) from %s\n", 52 n_frames, n_frames_expected, samplerate, n_frames / hop_size, 53 source_path); 54 55 del_fvec (vec); 56 del_aubio_source_apple_audio (s); 57 beach: 58 #else /* HAVE_SOURCE_APPLE_AUDIO */ 59 err = 3; 60 PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n"); 61 #endif /* HAVE_SOURCE_APPLE_AUDIO */ 62 return err; 29 return base_main(argc, argv); 63 30 } -
tests/src/io/test-source_avcodec.c
rf87e191 r868c6b8 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_source_custom "avcodec" 6 7 #ifdef HAVE_LIBAV 8 #define HAVE_AUBIO_SOURCE_CUSTOM 9 #define aubio_source_custom_t aubio_source_avcodec_t 10 #define new_aubio_source_custom new_aubio_source_avcodec 11 #define del_aubio_source_custom del_aubio_source_avcodec 12 #define aubio_source_custom_get_samplerate aubio_source_avcodec_get_samplerate 13 #define aubio_source_custom_get_duration aubio_source_avcodec_get_duration 14 #define aubio_source_custom_do aubio_source_avcodec_do 15 #define aubio_source_custom_do_multi aubio_source_avcodec_do_multi 16 #define aubio_source_custom_seek aubio_source_avcodec_seek 17 #define aubio_source_custom_close aubio_source_avcodec_close 18 #define aubio_source_custom_get_channels aubio_source_avcodec_get_channels 19 #define aubio_source_custom_get_samplerate aubio_source_avcodec_get_samplerate 20 #endif /* HAVE_LIBAV */ 21 22 #include "base-source_custom.h" 4 23 5 24 // this file uses the unstable aubio api, please use aubio_source instead … … 8 27 int main (int argc, char **argv) 9 28 { 10 uint_t err = 0; 11 if (argc < 2) { 12 err = 2; 13 PRINT_ERR("not enough arguments\n"); 14 PRINT_MSG("read a wave file as a mono vector\n"); 15 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 16 PRINT_MSG("examples:\n"); 17 PRINT_MSG(" - read file.wav at original samplerate\n"); 18 PRINT_MSG(" %s file.wav\n", argv[0]); 19 PRINT_MSG(" - read file.wav at 32000Hz\n"); 20 PRINT_MSG(" %s file.aif 32000\n", argv[0]); 21 PRINT_MSG(" - read file.wav at original samplerate with 4096 blocks\n"); 22 PRINT_MSG(" %s file.wav 0 4096 \n", argv[0]); 23 return err; 24 } 25 26 #ifdef HAVE_LIBAV 27 uint_t samplerate = 0; 28 uint_t hop_size = 256; 29 uint_t n_frames = 0, read = 0; 30 if ( argc == 3 ) samplerate = atoi(argv[2]); 31 if ( argc == 4 ) hop_size = atoi(argv[3]); 32 33 char_t *source_path = argv[1]; 34 35 36 aubio_source_avcodec_t * s = 37 new_aubio_source_avcodec(source_path, samplerate, hop_size); 38 if (!s) { err = 1; goto beach; } 39 fvec_t *vec = new_fvec(hop_size); 40 41 uint_t n_frames_expected = aubio_source_avcodec_get_duration(s); 42 43 samplerate = aubio_source_avcodec_get_samplerate(s); 44 45 do { 46 aubio_source_avcodec_do(s, vec, &read); 47 fvec_print (vec); 48 n_frames += read; 49 } while ( read == hop_size ); 50 51 PRINT_MSG("read %d frames (expected %d) at %dHz (%d blocks) from %s\n", 52 n_frames, n_frames_expected, samplerate, n_frames / hop_size, 53 source_path); 54 55 del_fvec (vec); 56 del_aubio_source_avcodec (s); 57 beach: 58 #else /* HAVE_LIBAV */ 59 err = 3; 60 PRINT_ERR("aubio was not compiled with aubio_source_avcodec\n"); 61 #endif /* HAVE_LIBAV */ 62 return err; 29 return base_main(argc, argv); 63 30 } -
tests/src/io/test-source_sndfile.c
rf87e191 r868c6b8 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_source_custom "sndfile" 6 7 #ifdef HAVE_SNDFILE 8 #define HAVE_AUBIO_SOURCE_CUSTOM 9 #define aubio_source_custom_t aubio_source_sndfile_t 10 #define new_aubio_source_custom new_aubio_source_sndfile 11 #define del_aubio_source_custom del_aubio_source_sndfile 12 #define aubio_source_custom_get_samplerate aubio_source_sndfile_get_samplerate 13 #define aubio_source_custom_get_duration aubio_source_sndfile_get_duration 14 #define aubio_source_custom_do aubio_source_sndfile_do 15 #define aubio_source_custom_do_multi aubio_source_sndfile_do_multi 16 #define aubio_source_custom_seek aubio_source_sndfile_seek 17 #define aubio_source_custom_close aubio_source_sndfile_close 18 #define aubio_source_custom_get_channels aubio_source_sndfile_get_channels 19 #define aubio_source_custom_get_samplerate aubio_source_sndfile_get_samplerate 20 #endif /* HAVE_LIBAV */ 21 22 #include "base-source_custom.h" 4 23 5 24 // this file uses the unstable aubio api, please use aubio_source instead … … 8 27 int main (int argc, char **argv) 9 28 { 10 uint_t err = 0; 11 if (argc < 2) { 12 err = 2; 13 PRINT_ERR("not enough arguments\n"); 14 PRINT_MSG("read a wave file as a mono vector\n"); 15 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 16 PRINT_MSG("examples:\n"); 17 PRINT_MSG(" - read file.wav at original samplerate\n"); 18 PRINT_MSG(" %s file.wav\n", argv[0]); 19 PRINT_MSG(" - read file.wav at 32000Hz\n"); 20 PRINT_MSG(" %s file.aif 32000\n", argv[0]); 21 PRINT_MSG(" - read file.wav at original samplerate with 4096 blocks\n"); 22 PRINT_MSG(" %s file.wav 0 4096 \n", argv[0]); 23 return err; 24 } 25 26 #ifdef HAVE_SNDFILE 27 uint_t samplerate = 0; 28 uint_t hop_size = 256; 29 uint_t n_frames = 0, read = 0; 30 if ( argc == 3 ) samplerate = atoi(argv[2]); 31 if ( argc == 4 ) hop_size = atoi(argv[3]); 32 33 char_t *source_path = argv[1]; 34 35 36 aubio_source_sndfile_t * s = 37 new_aubio_source_sndfile(source_path, samplerate, hop_size); 38 if (!s) { err = 1; goto beach; } 39 fvec_t *vec = new_fvec(hop_size); 40 41 uint_t n_frames_expected = aubio_source_sndfile_get_duration(s); 42 43 samplerate = aubio_source_sndfile_get_samplerate(s); 44 45 do { 46 aubio_source_sndfile_do(s, vec, &read); 47 fvec_print (vec); 48 n_frames += read; 49 } while ( read == hop_size ); 50 51 PRINT_MSG("read %d frames (expected %d) at %dHz (%d blocks) from %s\n", 52 n_frames, n_frames_expected, samplerate, n_frames / hop_size, 53 source_path); 54 55 del_fvec (vec); 56 del_aubio_source_sndfile (s); 57 beach: 58 #else 59 err = 3; 60 PRINT_ERR("aubio was not compiled with aubio_source_sndfile\n"); 61 #endif /* HAVE_SNDFILE */ 62 return err; 29 return base_main(argc, argv); 63 30 } -
tests/src/io/test-source_wavread.c
rf87e191 r868c6b8 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 #define aubio_source_custom "wavread" 6 7 #ifdef HAVE_WAVREAD 8 #define HAVE_AUBIO_SOURCE_CUSTOM 9 #define aubio_source_custom_t aubio_source_wavread_t 10 #define new_aubio_source_custom new_aubio_source_wavread 11 #define del_aubio_source_custom del_aubio_source_wavread 12 #define aubio_source_custom_get_samplerate aubio_source_wavread_get_samplerate 13 #define aubio_source_custom_get_duration aubio_source_wavread_get_duration 14 #define aubio_source_custom_do aubio_source_wavread_do 15 #define aubio_source_custom_do_multi aubio_source_wavread_do_multi 16 #define aubio_source_custom_seek aubio_source_wavread_seek 17 #define aubio_source_custom_close aubio_source_wavread_close 18 #define aubio_source_custom_get_channels aubio_source_wavread_get_channels 19 #define aubio_source_custom_get_samplerate aubio_source_wavread_get_samplerate 20 #endif /* HAVE_WAVREAD */ 21 22 #include "base-source_custom.h" 4 23 5 24 // this file uses the unstable aubio api, please use aubio_source instead … … 8 27 int main (int argc, char **argv) 9 28 { 10 uint_t err = 0; 11 if (argc < 2) { 12 err = 2; 13 PRINT_ERR("not enough arguments\n"); 14 PRINT_MSG("read a wave file as a mono vector\n"); 15 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 16 PRINT_MSG("examples:\n"); 17 PRINT_MSG(" - read file.wav at original samplerate\n"); 18 PRINT_MSG(" %s file.wav\n", argv[0]); 19 PRINT_MSG(" - read file.wav at 32000Hz\n"); 20 PRINT_MSG(" %s file.aif 32000\n", argv[0]); 21 PRINT_MSG(" - read file.wav at original samplerate with 4096 blocks\n"); 22 PRINT_MSG(" %s file.wav 0 4096 \n", argv[0]); 23 return err; 24 } 25 26 #ifdef HAVE_WAVREAD 27 uint_t samplerate = 0; 28 uint_t hop_size = 256; 29 uint_t n_frames = 0, read = 0; 30 if ( argc == 3 ) samplerate = atoi(argv[2]); 31 if ( argc == 4 ) hop_size = atoi(argv[3]); 32 33 char_t *source_path = argv[1]; 34 35 36 aubio_source_wavread_t * s = 37 new_aubio_source_wavread(source_path, samplerate, hop_size); 38 39 if (!s) { err = 1; goto beach; } 40 fvec_t *vec = new_fvec(hop_size); 41 42 uint_t n_frames_expected = aubio_source_wavread_get_duration(s); 43 44 samplerate = aubio_source_wavread_get_samplerate(s); 45 46 do { 47 aubio_source_wavread_do(s, vec, &read); 48 fvec_print (vec); 49 n_frames += read; 50 } while ( read == hop_size ); 51 52 PRINT_MSG("read %d frames (expected %d) at %dHz (%d blocks) from %s\n", 53 n_frames, n_frames_expected, samplerate, n_frames / hop_size, 54 source_path); 55 56 del_fvec (vec); 57 del_aubio_source_wavread (s); 58 beach: 59 #else 60 err = 3; 61 PRINT_ERR("aubio was not compiled with aubio_source_wavread\n"); 62 #endif /* HAVE_WAVREAD */ 63 return err; 29 return base_main(argc, argv); 64 30 } -
tests/src/onset/test-onset.c
rf87e191 r868c6b8 10 10 err = 2; 11 11 PRINT_WRN("no arguments, running tests\n"); 12 if (test_wrong_params() != 0) { 13 PRINT_ERR("tests failed!\n"); 14 err = 1; 15 } else { 16 err = 0; 17 } 12 err = test_wrong_params(); 18 13 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 19 14 return err; … … 23 18 uint_t hop_size = win_s / 4; 24 19 uint_t n_frames = 0, read = 0; 25 if ( argc == 3 ) samplerate = atoi(argv[2]);26 if ( argc == 4 ) hop_size = atoi(argv[3]);20 if ( argc >= 3 ) samplerate = atoi(argv[2]); 21 if ( argc >= 4 ) hop_size = atoi(argv[3]); 27 22 28 23 char_t *source_path = argv[1]; … … 75 70 uint_t samplerate = 44100; 76 71 // hop_size < 1 77 if (new_aubio_onset("default", 5, 0, samplerate)) 78 return 1; 72 if (new_aubio_onset("default", 5, 0, samplerate)) return 1; 73 79 74 // buf_size < 2 80 if (new_aubio_onset("default", 1, 1, samplerate)) 81 return 1; 75 if (new_aubio_onset("default", 1, 1, samplerate)) return 1; 76 82 77 // buf_size < hop_size 83 if (new_aubio_onset("default", hop_size, win_size, samplerate)) 84 return 1; 78 if (new_aubio_onset("default", hop_size, win_size, samplerate)) return 1; 79 85 80 // samplerate < 1 86 if (new_aubio_onset("default", 1024, 512, 0)) 87 return 1; 81 if (new_aubio_onset("default", 1024, 512, 0)) return 1; 88 82 89 83 // specdesc creation failed 90 if (new_aubio_onset("abcd", win_size, win_size/2, samplerate)) 91 return 1; 92 // pv creation failed 93 if (new_aubio_onset("default", 5, 2, samplerate)) 94 return 1; 84 if (new_aubio_onset("abcd", win_size, win_size/2, samplerate)) return 1; 95 85 96 86 aubio_onset_t *o; 87 88 // pv creation might fail 89 o = new_aubio_onset("default", 5, 2, samplerate); 90 if (o) del_aubio_onset(o); 91 97 92 o = new_aubio_onset("default", win_size, hop_size, samplerate); 98 if (!aubio_onset_set_default_parameters(o, "wrong_type")) 99 return 1; 93 if (!aubio_onset_set_default_parameters(o, "wrong_type")) return 1; 100 94 del_aubio_onset(o); 101 95 102 return 0;96 return run_on_default_source(main); 103 97 } -
tests/src/pitch/test-pitch.c
rf87e191 r868c6b8 31 31 aubio_cleanup (); 32 32 33 if (new_aubio_pitch(0, win_s, hop_s, samplerate)) return 1; 34 if (new_aubio_pitch("unknown", win_s, hop_s, samplerate)) return 1; 35 if (new_aubio_pitch("default", win_s, 0, samplerate)) return 1; 36 if (new_aubio_pitch("default", 0, hop_s, samplerate)) return 1; 37 if (new_aubio_pitch("default", hop_s, win_s, samplerate)) return 1; 38 if (new_aubio_pitch("default", win_s, hop_s, 0)) return 1; 39 40 o = new_aubio_pitch("default", win_s, hop_s, samplerate); 41 42 if (aubio_pitch_set_unit(o, "freq")) return 1; 43 if (aubio_pitch_set_unit(o, "hertz")) return 1; 44 if (aubio_pitch_set_unit(o, "Hertz")) return 1; 45 if (aubio_pitch_set_unit(o, "Hz")) return 1; 46 if (aubio_pitch_set_unit(o, "f0")) return 1; 47 if (aubio_pitch_set_unit(o, "midi")) return 1; 48 if (aubio_pitch_set_unit(o, "cent")) return 1; 49 if (aubio_pitch_set_unit(o, "bin")) return 1; 50 if (!aubio_pitch_set_unit(o, "unknown")) return 1; 51 52 if (aubio_pitch_set_tolerance(o, 0.3)) return 1; 53 if (aubio_pitch_set_silence(o, 0)) return 1; 54 if (aubio_pitch_set_silence(o, -200)) return 1; 55 if (!aubio_pitch_set_silence(o, -300)) return 1; 56 del_aubio_pitch(o); 57 58 // fft based might fail with non power of 2 59 o = new_aubio_pitch("yinfft", win_s + 1, hop_s, samplerate); 60 if (o) del_aubio_pitch(o); 61 o = new_aubio_pitch("yinfast", win_s + 1, hop_s, samplerate); 62 if (o) del_aubio_pitch(o); 63 o = new_aubio_pitch("fcomb", win_s + 1, hop_s, samplerate); 64 if (o) del_aubio_pitch(o); 65 o = new_aubio_pitch("mcomb", win_s + 1, hop_s, samplerate); 66 if (o) del_aubio_pitch(o); 67 o = new_aubio_pitch("specacf", win_s + 1, hop_s, samplerate); 68 if (o) del_aubio_pitch(o); 69 33 70 return 0; 34 71 } -
tests/src/spectral/test-awhitening.c
rf87e191 r868c6b8 11 11 err = 2; 12 12 PRINT_WRN("no arguments, running tests\n"); 13 if (test_wrong_params() != 0) { 14 PRINT_ERR("tests failed!\n"); 15 err = 1; 16 } else { 17 err = 0; 18 } 13 err = test_wrong_params(); 19 14 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]); 20 15 return err; … … 31 26 if ( argc >= 4 ) samplerate = atoi(argv[3]); 32 27 if ( argc >= 5 ) hop_size = atoi(argv[4]); 33 if ( argc >= 6 ) {34 err = 2;35 PRINT_ERR("too many arguments\n");36 return err;37 }38 28 39 29 fvec_t *vec = new_fvec(hop_size); … … 52 42 53 43 aubio_pvoc_t *pv = new_aubio_pvoc(win_size, hop_size); 44 if (!pv) { err = 1; goto beach_pvoc; } 54 45 55 46 aubio_spectral_whitening_t *awhitening = 56 47 new_aubio_spectral_whitening (win_size, hop_size, samplerate); 48 if (!awhitening) { err = 1; goto beach_awhitening; } 57 49 58 50 aubio_spectral_whitening_set_relax_time(awhitening, 20.); … … 82 74 source_path, sink_path); 83 75 76 del_aubio_spectral_whitening(awhitening); 77 beach_awhitening: 78 del_aubio_pvoc(pv); 79 beach_pvoc: 84 80 del_aubio_sink(o); 85 81 beach_sink: … … 87 83 beach_source: 88 84 del_fvec(vec); 85 del_fvec(out); 86 del_fvec(scale); 87 del_cvec(fftgrain); 89 88 beach_fvec: 90 89 return err; … … 109 108 del_aubio_spectral_whitening(o); 110 109 111 return 0;110 return run_on_default_source_and_sink(main); 112 111 } -
tests/src/spectral/test-dct.c
rf87e191 r868c6b8 33 33 aubio_dct_rdo (dct, dctout, out); 34 34 for (j = 0; j < in->length; j++) { 35 if (fabsf(in->data[j] - out->data[j]) > 10.e-4) { 36 fprintf(stderr, "dct reconstruction failed\n"); 37 } 35 return_code += (fabsf(in->data[j] - out->data[j]) > 10.e-4); 38 36 } 39 37 } -
tests/src/spectral/test-mfcc.c
rf87e191 r868c6b8 1 1 #include <aubio.h> 2 #include "utils_tests.h" 2 3 3 int main (void) 4 int test_wrong_params(void); 5 6 int main (int argc, char** argv) 7 { 8 sint_t err = 0; 9 10 if (argc < 2) { 11 err = 2; 12 PRINT_WRN("no arguments, running tests\n"); 13 err = test_wrong_params(); 14 PRINT_MSG("usage: %s <input_path> [samplerate] [hop_size]\n", argv[0]); 15 return err; 16 } 17 18 uint_t win_s; // fft size 19 uint_t hop_s = 256; // block size 20 uint_t samplerate = 0; // samplerate 21 uint_t n_filters = 40; // number of filters 22 uint_t n_coeffs = 13; // number of coefficients 23 uint_t read = 0; 24 25 char_t *source_path = argv[1]; 26 27 if ( argc >= 3 ) samplerate = atoi(argv[2]); 28 if ( argc >= 4 ) hop_s = atoi(argv[3]); 29 30 win_s = 2 * hop_s; 31 32 aubio_source_t *source = 0; 33 aubio_pvoc_t *pv = 0; 34 aubio_mfcc_t *mfcc = 0; 35 36 fvec_t *in = new_fvec (win_s); // input buffer 37 cvec_t *fftgrain = new_cvec (win_s); // input buffer 38 fvec_t *out = new_fvec (n_coeffs); // output coefficients 39 40 if (!in || !fftgrain || !out) { err = 1; goto failure; } 41 42 // source 43 source = new_aubio_source(source_path, samplerate, hop_s); 44 if (!source) { err = 1; goto failure; } 45 if (samplerate == 0) samplerate = aubio_source_get_samplerate(source); 46 47 // phase vocoder 48 pv = new_aubio_pvoc(win_s, hop_s); 49 if (!pv) { err = 1; goto failure; } 50 51 // mfcc object 52 mfcc = new_aubio_mfcc (win_s, n_filters, n_coeffs, samplerate); 53 if (!mfcc) { err = 1; goto failure; } 54 55 // processing loop 56 do { 57 aubio_source_do(source, in, &read); 58 aubio_pvoc_do(pv, in, fftgrain); 59 aubio_mfcc_do(mfcc, fftgrain, out); 60 fvec_print(out); 61 } while (read == hop_s); 62 63 failure: 64 65 if (mfcc) 66 del_aubio_mfcc(mfcc); 67 if (pv) 68 del_aubio_pvoc(pv); 69 if (source) 70 del_aubio_source(source); 71 if (in) 72 del_fvec(in); 73 if (fftgrain) 74 del_cvec(fftgrain); 75 if (out) 76 del_fvec(out); 77 aubio_cleanup(); 78 return err; 79 } 80 81 int test_wrong_params() 4 82 { 5 83 uint_t win_s = 512; // fft size … … 7 85 uint_t n_coeffs = 13; // number of coefficients 8 86 smpl_t samplerate = 16000.; // samplerate 9 cvec_t *in = new_cvec (win_s); // input buffer10 fvec_t *out = new_fvec (n_coeffs); // output coefficients11 87 12 88 if (new_aubio_mfcc( 0, n_filters, n_coeffs, samplerate)) return 1; … … 15 91 if (new_aubio_mfcc(win_s, n_filters, n_coeffs, 0)) return 1; 16 92 17 // create mfcc object 18 aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coeffs, samplerate); 19 20 cvec_norm_set_all (in, 1.); 21 aubio_mfcc_do (o, in, out); 22 fvec_print (out); 23 24 cvec_norm_set_all (in, .5); 25 aubio_mfcc_do (o, in, out); 26 fvec_print (out); 27 28 // clean up 29 del_aubio_mfcc (o); 30 del_cvec (in); 31 del_fvec (out); 32 aubio_cleanup (); 33 34 return 0; 93 return run_on_default_source(main); 35 94 } -
tests/src/synth/test-sampler.c
rf87e191 r868c6b8 1 #include <string.h> // strncpy 2 #include <limits.h> // PATH_MAX 1 3 #include <aubio.h> 2 4 #include "utils_tests.h" … … 6 8 sint_t err = 0; 7 9 8 if (argc < 4) {9 err = 2;10 PRINT_ERR("not enough arguments\n");10 if (argc < 3) { 11 PRINT_ERR("not enough arguments, running tests\n"); 12 err = run_on_default_source_and_sink(main); 11 13 PRINT_MSG("usage: %s <input_path> <output_path> <sample_path> [samplerate]\n", argv[0]); 12 14 return err; … … 19 21 char_t *source_path = argv[1]; 20 22 char_t *sink_path = argv[2]; 21 char_t *sample_path = argv[3]; 22 if ( argc == 5 ) samplerate = atoi(argv[4]); 23 char_t sample_path[PATH_MAX]; 24 if ( argc >= 4 ) { 25 strncpy(sample_path, argv[3], PATH_MAX - 1); 26 } else { 27 // use input_path as sample 28 strncpy(sample_path, source_path, PATH_MAX - 1); 29 } 30 sample_path[PATH_MAX - 1] = '\0'; 31 if ( argc >= 5 ) samplerate = atoi(argv[4]); 23 32 24 33 fvec_t *vec = new_fvec(hop_size); -
tests/src/synth/test-wavetable.c
rf87e191 r868c6b8 7 7 8 8 if (argc < 2) { 9 err = 2;10 PRINT_ERR("not enough arguments\n");9 PRINT_ERR("not enough arguments, running tests\n"); 10 err = run_on_default_sink(main); 11 11 PRINT_MSG("usage: %s <output_path> [freq] [samplerate]\n", argv[0]); 12 12 return err; … … 18 18 19 19 char_t *sink_path = argv[1]; 20 if ( argc == 4 ) samplerate = atoi(argv[3]);21 if ( argc == 3 ) freq = atof(argv[2]);20 if ( argc >= 4 ) samplerate = atoi(argv[3]); 21 if ( argc >= 3 ) freq = atof(argv[2]); 22 22 23 23 fvec_t *vec = new_fvec(hop_size); -
tests/src/tempo/test-tempo.c
rf87e191 r868c6b8 8 8 uint_t err = 0; 9 9 if (argc < 2) { 10 err = 2;11 10 PRINT_WRN("no arguments, running tests\n"); 12 if (test_wrong_params() != 0) { 13 PRINT_ERR("tests failed!\n"); 14 err = 1; 15 } else { 16 err = 0; 17 } 11 err = test_wrong_params(); 18 12 PRINT_MSG("usage: %s <source_path> [samplerate] [win_size] [hop_size]\n", 19 13 argv[0]); … … 88 82 89 83 // test wrong method fails 90 if (new_aubio_tempo("unexisting_method", win_size, hop_size, samplerate)) 91 return 1; 84 if (new_aubio_tempo("undefined", win_size, hop_size, samplerate)) return 1; 92 85 93 86 // test hop > win fails 94 if (new_aubio_tempo("default", hop_size, win_size, samplerate)) 95 return 1; 87 if (new_aubio_tempo("default", hop_size, win_size, samplerate)) return 1; 96 88 97 89 // test null hop_size fails 98 if (new_aubio_tempo("default", win_size, 0, samplerate)) 99 return 1; 90 if (new_aubio_tempo("default", win_size, 0, samplerate)) return 1; 100 91 101 92 // test 1 buf_size fails 102 if (new_aubio_tempo("default", 1, 1, samplerate)) 103 return 1; 93 if (new_aubio_tempo("default", 1, 1, samplerate)) return 1; 104 94 105 95 // test null samplerate fails 106 if (new_aubio_tempo("default", win_size, hop_size, 0)) 107 return 1; 96 if (new_aubio_tempo("default", win_size, hop_size, 0)) return 1; 108 97 109 98 // test short sizes workaround 110 99 t = new_aubio_tempo("default", 2048, 2048, 500); 111 if (!t) 112 return 1; 100 if (!t) return 1; 113 101 114 102 del_aubio_tempo(t); 115 103 116 104 t = new_aubio_tempo("default", win_size, hop_size, samplerate); 117 if (!t) 118 return 1; 105 if (!t) return 1; 119 106 120 107 in = new_fvec(hop_size); … … 136 123 del_fvec(out); 137 124 138 return 0;125 return run_on_default_source(main); 139 126 } -
tests/src/temporal/test-filter.c
rf87e191 r868c6b8 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; … … 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; -
tests/src/test-mathutils.c
rf87e191 r868c6b8 101 101 fvec_set_window(window, "rectangle"); 102 102 fvec_print(window); 103 del_fvec(window); 103 104 104 105 window_size /= 2.; 105 window = new_aubio_window(" triangle", window_size);106 window = new_aubio_window("parzen", window_size); 106 107 fvec_print(window); 107 108 del_fvec(window); … … 117 118 test_miditofreq(); 118 119 test_freqtomidi(); 120 test_aubio_window(); 119 121 return 0; 120 122 } -
tests/src/utils/test-hist.c
rf87e191 r868c6b8 26 26 del_fvec(t); 27 27 } 28 if (new_aubio_hist(0, 1, 0)) return 1; 28 29 return 0; 29 30 }
Note: See TracChangeset
for help on using the changeset viewer.