Changeset 3a96d3d
- Timestamp:
- Dec 6, 2018, 11:32:11 AM (6 years ago)
- Branches:
- feature/cnn, feature/crepe, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
- Children:
- dec789b
- Parents:
- 283a619a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/src/effects/test-pitchshift.c
r283a619a r3a96d3d 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"); 12 PRINT_MSG("usage: %s <input_path> <output_path> <transpose> [mode] [hop_size] [samplerate]\n", argv[0]); 13 PRINT_MSG(" with <transpose> a number of semi tones in the range [-24, 24]\n"); 14 PRINT_MSG(" and [mode] in 'default', 'crispness:0', ..., 'crispness:6'\n"); 11 if (argc < 3) { 12 PRINT_ERR("not enough arguments, running tests\n"); 13 err = test_wrong_params(); 14 PRINT_MSG("usage: %s <input_path> <output_path> [transpose] ", argv[0]); 15 PRINT_MSG("[mode] [hop_size] [samplerate]\n"); 16 PRINT_MSG(" with [transpose] a number of semi tones in the range " 17 " [-24, 24], and [mode] in 'default', 'crispness:0'," 18 " 'crispness:1', ... 'crispness:6'\n"); 15 19 return err; 16 20 } … … 25 29 char_t *mode = "default"; 26 30 27 transpose = atof(argv[3]);31 transpose = 0.; 28 32 33 if ( argc >= 4 ) transpose = atof(argv[3]); 29 34 if ( argc >= 5 ) mode = argv[4]; 30 35 if ( argc >= 6 ) hop_size = atoi(argv[5]); 31 36 if ( argc >= 7 ) samplerate = atoi(argv[6]); 32 if ( argc >= 8 ) {33 err = 2;34 PRINT_ERR("too many arguments\n");35 return err;36 }37 37 38 38 fvec_t *vec = new_fvec(hop_size); … … 48 48 if (!o) { err = 1; goto beach_sink; } 49 49 50 aubio_pitchshift_t *ps = new_aubio_pitchshift(mode, transpose, hop_size, samplerate); 50 aubio_pitchshift_t *ps = 51 new_aubio_pitchshift(mode, transpose, hop_size, samplerate); 51 52 if (!ps) { err = 1; goto beach_pitchshift; } 52 53 … … 59 60 } while ( read == hop_size ); 60 61 61 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",62 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", 62 63 n_frames, samplerate, n_frames / hop_size, 63 source_path, sink_path); 64 source_path); 65 PRINT_MSG("wrote to %s with hop_size: %d, samplerate: %d, latency %d\n", 66 sink_path, hop_size, samplerate, aubio_pitchshift_get_latency(ps)); 64 67 65 68 del_aubio_pitchshift(ps); … … 74 77 return err; 75 78 } 79 80 int test_wrong_params(void) 81 { 82 const char_t *mode = "default"; 83 smpl_t transpose = 0.; 84 uint_t hop_size = 256; 85 uint_t samplerate = 44100; 86 87 if (new_aubio_pitchshift("??", transpose, hop_size, samplerate)) return 1; 88 if (new_aubio_pitchshift(mode, 28., hop_size, samplerate)) return 1; 89 if (new_aubio_pitchshift(mode, transpose, 0, samplerate)) return 1; 90 if (new_aubio_pitchshift(mode, transpose, hop_size, 0)) return 1; 91 92 aubio_pitchshift_t *p = new_aubio_pitchshift(mode, transpose, 93 hop_size, samplerate); 94 if (!p) return 1; 95 if (!aubio_pitchshift_set_pitchscale(p, 0.1)) return 1; 96 if (!aubio_pitchshift_set_transpose(p, -30)) return 1; 97 del_aubio_pitchshift(p); 98 99 return run_on_default_source_and_sink(main); 100 }
Note: See TracChangeset
for help on using the changeset viewer.