- Timestamp:
- Oct 27, 2013, 12:44:29 PM (11 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- 8247249
- Parents:
- dd15573 (diff), 7fc5ba2 (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:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/src/io/test-source_multi.c
rdd15573 rdc467b5d 17 17 PRINT_MSG(" - read file.wav at original samplerate with 4096 blocks\n"); 18 18 PRINT_MSG(" %s file.wav 0 4096 \n", argv[0]); 19 PRINT_MSG(" - read file.wav at original samplerate with 256 frames blocks, mono\n"); 20 PRINT_MSG(" %s file.wav 0 4096 1\n", argv[0]); 19 21 return err; 20 22 } … … 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 uint_t n_channels = 0; 28 if ( argc >= 3 ) samplerate = atoi(argv[2]); 29 if ( argc >= 4 ) hop_size = atoi(argv[3]); 30 if ( argc >= 5 ) n_channels = atoi(argv[4]); 27 31 28 32 char_t *source_path = argv[1]; … … 31 35 if (!s) { err = -1; goto beach; } 32 36 33 if ( samplerate == 0 ) samplerate = aubio_source_get_samplerate(s);37 if ( samplerate == 0 ) samplerate = aubio_source_get_samplerate(s); 34 38 35 fmat_t *mat = new_fmat(hop_size, aubio_source_get_channels(s) ); 39 if ( n_channels == 0 ) n_channels = aubio_source_get_channels(s); 40 41 fmat_t *mat = new_fmat(hop_size, n_channels); 36 42 37 43 do { … … 41 47 } while ( read == hop_size ); 42 48 43 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", n_frames, samplerate,44 n_frames / hop_size, source_path);49 PRINT_MSG("read %d frames in %d channels at %dHz (%d blocks) from %s\n", 50 n_frames, n_channels, samplerate, n_frames / hop_size, source_path); 45 51 46 52 del_fmat (mat); -
tests/src/io/test-source_seek.c
rdd15573 rdc467b5d 23 23 uint_t hop_size = 256; 24 24 uint_t n_frames = 0, read = 0; 25 uint_t old_n_frames ;25 uint_t old_n_frames_1, old_n_frames_2, old_n_frames_3; 26 26 if ( argc == 3 ) samplerate = atoi(argv[2]); 27 27 if ( argc == 4 ) hop_size = atoi(argv[3]); … … 42 42 } while ( read == hop_size ); 43 43 44 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", n_frames, samplerate, 45 n_frames / hop_size, source_path); 44 PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n", 45 n_frames * 1. / samplerate, 46 n_frames, samplerate, 47 n_frames / hop_size, source_path); 48 49 old_n_frames_1 = n_frames; 46 50 47 51 aubio_source_seek (s, 0); 48 49 old_n_frames = n_frames;50 52 51 53 n_frames = 0; … … 56 58 } while ( read == hop_size ); 57 59 58 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", n_frames, samplerate, 59 n_frames / hop_size, source_path); 60 PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n", 61 n_frames * 1. / samplerate, 62 n_frames, samplerate, 63 n_frames / hop_size, source_path); 64 65 old_n_frames_2 = n_frames; 66 67 aubio_source_seek (s, n_frames / 2); 68 69 n_frames = 0; 70 do { 71 aubio_source_do(s, vec, &read); 72 //fvec_print (vec); 73 n_frames += read; 74 } while ( read == hop_size ); 75 76 PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n", 77 n_frames * 1. / samplerate, 78 n_frames, samplerate, 79 n_frames / hop_size, source_path); 80 81 old_n_frames_3 = n_frames; 60 82 61 83 del_aubio_source (s); … … 63 85 del_fvec (vec); 64 86 65 assert ( n_frames == old_n_frames ); 87 assert ( old_n_frames_2 == old_n_frames_1 ); 88 assert ( old_n_frames_3 == (uint_t)floor(old_n_frames_1 / 2. + .5) ); 66 89 return err; 67 90 } -
tests/src/onset/test-onset.c
rdd15573 rdc467b5d 1 1 #include <aubio.h> 2 #include "utils_tests.h" 2 3 3 int main ( )4 int main (int argc, char **argv) 4 5 { 5 // 1. allocate some memory 6 uint_t n = 0; // frame counter 6 uint_t err = 0; 7 if (argc < 2) { 8 err = 2; 9 PRINT_ERR("not enough arguments\n"); 10 PRINT_MSG("read a wave file as a mono vector\n"); 11 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 12 return err; 13 } 14 uint_t samplerate = 0; 7 15 uint_t win_s = 1024; // window size 8 uint_t hop_s = win_s / 4; // hop size 9 uint_t samplerate = 44100; // samplerate 16 uint_t hop_size = win_s / 4; 17 uint_t n_frames = 0, read = 0; 18 if ( argc == 3 ) samplerate = atoi(argv[2]); 19 if ( argc == 4 ) hop_size = atoi(argv[3]); 20 21 char_t *source_path = argv[1]; 22 aubio_source_t * source = new_aubio_source(source_path, samplerate, hop_size); 23 if (!source) { err = 1; goto beach; } 24 25 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(source); 26 10 27 // create some vectors 11 fvec_t * input = new_fvec (win_s/4); // input buffer 12 fvec_t * out = new_fvec (2); // input buffer 28 fvec_t * in = new_fvec (hop_size); // input audio buffer 29 fvec_t * out = new_fvec (2); // output position 30 13 31 // create onset object 14 aubio_onset_t * o nset = new_aubio_onset("complex", win_s, hop_s, samplerate);32 aubio_onset_t * o = new_aubio_onset("default", win_s, hop_size, samplerate); 15 33 16 // 2. do something with it 17 while (n < 10) { 18 // get `hop_s` new samples into `input` 19 // ... 20 // exectute onset detection 21 aubio_onset_do (onset, input, out); 22 // do something with output candidates 23 // ... 24 n++; 25 }; 34 do { 35 // put some fresh data in input vector 36 aubio_source_do(source, in, &read); 37 // execute onset 38 aubio_onset_do(o,in,out); 39 // do something with the onsets 40 if (out->data[0] != 0) { 41 PRINT_MSG("onset at %.3fms, %.3fs, frame %d\n", 42 aubio_onset_get_last_ms(o), aubio_onset_get_last_s(o), 43 aubio_onset_get_last(o)); 44 } 45 n_frames += read; 46 } while ( read == hop_size ); 26 47 27 // 3. clean up memory 28 del_aubio_onset(onset); 29 del_fvec(input); 48 PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n", 49 n_frames * 1. / samplerate, 50 n_frames, samplerate, 51 n_frames / hop_size, source_path); 52 53 // clean up memory 54 del_aubio_onset(o); 55 del_fvec(in); 30 56 del_fvec(out); 57 beach: 31 58 aubio_cleanup(); 32 59 33 return 0;60 return err; 34 61 } -
tests/src/spectral/test-filterbank.c
rdd15573 rdc467b5d 8 8 cvec_t *in_spec = new_cvec (win_s); // input vector of samples 9 9 fvec_t *out_filters = new_fvec (n_filters); // per-band outputs 10 fmat_t *coeffs; // pointer to the coefficients11 10 12 11 // create filterbank object 13 12 aubio_filterbank_t *o = new_aubio_filterbank (n_filters, win_s); 14 13 14 // apply filterbank ten times 15 uint_t n = 10; 16 while (n) { 17 aubio_filterbank_do (o, in_spec, out_filters); 18 n--; 19 } 20 21 // print out filterbank coeffs 22 fmat_t *coeffs; // pointer to the coefficients 15 23 coeffs = aubio_filterbank_get_coeffs (o); 24 fmat_print (coeffs); 16 25 17 aubio_filterbank_do (o, in_spec,out_filters);26 //fvec_print (out_filters); 18 27 19 // fmat_print (coeffs); 20 // cvec_print(in_spec); 21 // fvec_print(out_filters); 22 28 // clean up 23 29 del_aubio_filterbank (o); 24 30 del_cvec (in_spec); -
tests/src/spectral/test-filterbank_mel.c
rdd15573 rdc467b5d 9 9 cvec_t *in_spec = new_cvec (win_s); // input vector of samples 10 10 fvec_t *out_filters = new_fvec (n_filters); // per-band outputs 11 fmat_t *coeffs; // pointer to the coefficients12 11 13 12 // create filterbank object … … 17 16 aubio_filterbank_set_mel_coeffs_slaney (o, samplerate); 18 17 18 // apply filterbank ten times 19 uint_t n = 10; 20 while (n) { 21 aubio_filterbank_do (o, in_spec, out_filters); 22 n--; 23 } 24 25 // print out filter coefficients 26 fmat_t *coeffs; // pointer to the coefficients 19 27 coeffs = aubio_filterbank_get_coeffs (o); 28 fmat_print (coeffs); 20 29 21 aubio_filterbank_do (o, in_spec, out_filters); 22 23 // fmat_print (coeffs); 24 // cvec_print(in_spec); 25 // fvec_print(out_filters); 30 //fvec_print (out_filters); 26 31 27 32 del_aubio_filterbank (o); -
tests/src/tempo/test-tempo.c
rdd15573 rdc467b5d 1 1 #include <aubio.h> 2 #include "utils_tests.h" 2 3 3 int main ( )4 int main (int argc, char **argv) 4 5 { 5 uint_t i = 0; 6 uint_t err = 0; 7 if (argc < 2) { 8 err = 2; 9 PRINT_ERR("not enough arguments\n"); 10 PRINT_MSG("read a wave file as a mono vector\n"); 11 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 12 return err; 13 } 14 uint_t samplerate = 0; 6 15 uint_t win_s = 1024; // window size 7 fvec_t * in = new_fvec (win_s); // input vector 8 fvec_t * out = new_fvec (2); // output beat position 16 uint_t hop_size = win_s / 4; 17 uint_t n_frames = 0, read = 0; 18 if ( argc == 3 ) samplerate = atoi(argv[2]); 19 if ( argc == 4 ) hop_size = atoi(argv[3]); 20 21 char_t *source_path = argv[1]; 22 aubio_source_t * source = new_aubio_source(source_path, samplerate, hop_size); 23 if (!source) { err = 1; goto beach; } 24 25 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(source); 26 27 // create some vectors 28 fvec_t * in = new_fvec (hop_size); // input audio buffer 29 fvec_t * out = new_fvec (2); // output position 9 30 10 31 // create tempo object 11 aubio_tempo_t * o = new_aubio_tempo(" complex", win_s, win_s/4, 44100.);32 aubio_tempo_t * o = new_aubio_tempo("default", win_s, hop_size, samplerate); 12 33 13 smpl_t bpm, confidence; 14 15 while (i < 1000) { 34 do { 16 35 // put some fresh data in input vector 17 // ... 18 36 aubio_source_do(source, in, &read); 19 37 // execute tempo 20 38 aubio_tempo_do(o,in,out); 21 39 // do something with the beats 22 // ... 40 if (out->data[0] != 0) { 41 PRINT_MSG("beat at %.3fms, %.3fs, frame %d, %.2fbpm with confidence %.2f\n", 42 aubio_tempo_get_last_ms(o), aubio_tempo_get_last_s(o), 43 aubio_tempo_get_last(o), aubio_tempo_get_bpm(o), aubio_tempo_get_confidence(o)); 44 } 45 n_frames += read; 46 } while ( read == hop_size ); 23 47 24 // get bpm and confidence 25 bpm = aubio_tempo_get_bpm(o); 26 confidence = aubio_tempo_get_confidence(o); 48 PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n", 49 n_frames * 1. / samplerate, 50 n_frames, samplerate, 51 n_frames / hop_size, source_path); 27 52 28 i++; 29 }; 30 53 // clean up memory 31 54 del_aubio_tempo(o); 32 55 del_fvec(in); 33 56 del_fvec(out); 57 del_aubio_source(source); 58 beach: 34 59 aubio_cleanup(); 35 60 36 return 0;61 return err; 37 62 } -
tests/src/temporal/test-filter.c
rdd15573 rdc467b5d 3 3 int main () 4 4 { 5 uint_t win_s = 32; // window size 5 uint_t win_s = 16; // window size 6 uint_t impulse_at = win_s / 2; 6 7 fvec_t *in = new_fvec (win_s); // input buffer 7 8 fvec_t *out = new_fvec (win_s); // input buffer 8 9 9 10 aubio_filter_t *o = new_aubio_filter_c_weighting (44100); 10 in->data[ 12] = 0.5;11 in->data[impulse_at] = 0.5; 11 12 fvec_print (in); 12 13 aubio_filter_do (o, in); … … 15 16 16 17 o = new_aubio_filter_a_weighting (32000); 17 in->data[ 12] = 0.5;18 in->data[impulse_at] = 0.5; 18 19 fvec_print (in); 19 20 aubio_filter_do_outplace (o, in, out); … … 21 22 22 23 aubio_filter_set_a_weighting (o, 32000); 23 in->data[ 12] = 0.5;24 in->data[impulse_at] = 0.5; 24 25 fvec_print (in); 25 26 aubio_filter_do_filtfilt (o, in, out); -
tests/src/test-delnull.c
rdd15573 rdc467b5d 1 1 #include <stdlib.h> 2 2 #include <aubio.h> 3 4 // Because aubio does not check for double free, this program will crash. 5 // Programs that call these functions should check for null pointers. 3 6 4 7 int main () -
tests/src/test-fmat.c
rdd15573 rdc467b5d 18 18 } 19 19 } 20 fvec_t channel_onstack; 21 fvec_t *channel = &channel_onstack; 22 fmat_get_channel(mat, 1, channel); 23 fvec_print (channel); 20 24 // print out matrix 21 25 fmat_print(mat);
Note: See TracChangeset
for help on using the changeset viewer.