Changeset 9d8cedf5
- Timestamp:
- Dec 7, 2018, 12:17:55 PM (6 years ago)
- Branches:
- feature/cnn, feature/crepe, feature/timestretch, fix/ffmpeg5, master
- Children:
- 97a5ac08
- Parents:
- 4bb2e74
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/src/effects/test-timestretch.c
r4bb2e74 r9d8cedf5 2 2 #include <aubio.h> 3 3 #include "utils_tests.h" 4 5 int test_wrong_params(void); 4 6 5 7 int main (int argc, char **argv) … … 7 9 sint_t err = 0; 8 10 9 if (argc < 4) {10 err = 2;11 PRINT_ERR("not enough arguments\n");11 if (argc < 3 || argc >= 9) { 12 PRINT_ERR("wrong number of arguments, running tests\n"); 13 err = test_wrong_params(); 12 14 PRINT_MSG("usage: %s <input_path> <output_path> <stretch> [transpose] [mode] [hop_size] [samplerate]\n", argv[0]); 13 15 PRINT_MSG(" with <stretch> a time stretching ratio in the range [0.025, 10.]\n"); … … 17 19 } 18 20 19 uint_t samplerate = 0; 21 #ifdef HAVE_RUBBERBAND 22 uint_t samplerate = 0; // using source samplerate 20 23 uint_t hop_size = 64; 21 24 smpl_t transpose = 0.; … … 28 31 char_t *mode = "default"; 29 32 30 stretch = atof(argv[3]); 31 33 if ( argc >= 4 ) stretch = atof(argv[3]); 32 34 if ( argc >= 5 ) transpose = atof(argv[4]); 33 35 if ( argc >= 6 ) mode = argv[5]; 34 36 if ( argc >= 7 ) hop_size = atoi(argv[6]); 35 37 if ( argc >= 8 ) samplerate = atoi(argv[7]); 36 if ( argc >= 9 ) {37 err = 2;38 PRINT_ERR("too many arguments\n");39 return err;40 }41 38 42 39 uint_t source_hopsize = 2048; … … 97 94 del_aubio_source(s); 98 95 beach_source: 96 #else 97 err = 0; 98 PRINT_ERR("aubio was not compiled with rubberband\n"); 99 #endif 99 100 return err; 100 101 } 102 103 int test_wrong_params(void) 104 { 105 const char_t *mode = "default"; 106 smpl_t stretch = 1.; 107 uint_t hop_size = 256; 108 uint_t samplerate = 44100; 109 110 if (new_aubio_timestretch("??", stretch, hop_size, samplerate)) return 1; 111 if (new_aubio_timestretch(mode, 41., hop_size, samplerate)) return 1; 112 if (new_aubio_timestretch(mode, stretch, 0, samplerate)) return 1; 113 if (new_aubio_timestretch(mode, stretch, hop_size, 0)) return 1; 114 115 aubio_timestretch_t *p = new_aubio_timestretch(mode, stretch, hop_size, 116 samplerate); 117 #ifdef HAVE_RUBBERBAND 118 if (!p) return 1; 119 120 if (aubio_timestretch_get_latency(p) == 0) return 1; 121 122 aubio_timestretch_reset(p); 123 124 if (aubio_timestretch_get_transpose(p) != 0) return 1; 125 if (aubio_timestretch_set_transpose(p, 2.)) return 1; 126 if (fabsf(aubio_timestretch_get_transpose(p) - 2.) >= 1e-6) return 1; 127 if (!aubio_timestretch_set_transpose(p, 200.)) return 1; 128 if (!aubio_timestretch_set_transpose(p, -200.)) return 1; 129 if (aubio_timestretch_set_transpose(p, 0.)) return 1; 130 131 if (aubio_timestretch_get_pitchscale(p) != 1) return 1; 132 if (aubio_timestretch_set_pitchscale(p, 2.)) return 1; 133 if (fabsf(aubio_timestretch_get_pitchscale(p) - 2.) >= 1e-6) return 1; 134 if (!aubio_timestretch_set_pitchscale(p, 0.)) return 1; 135 if (!aubio_timestretch_set_pitchscale(p, 6.)) return 1; 136 137 if (aubio_timestretch_get_stretch(p) != stretch) return 1; 138 if (aubio_timestretch_set_stretch(p, 2.)) return 1; 139 if (fabsf(aubio_timestretch_get_stretch(p) - 2.) >= 1e-6) return 1; 140 if (!aubio_timestretch_set_stretch(p, 0.)) return 1; 141 if (!aubio_timestretch_set_stretch(p, 41.)) return 1; 142 143 del_aubio_timestretch(p); 144 #else 145 if (p) return 1; 146 #endif 147 148 return run_on_default_source_and_sink(main); 149 }
Note: See TracChangeset
for help on using the changeset viewer.