Changes in / [ce323e4:1cf031a]
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/onset/onset.c
rce323e4 r1cf031a 257 257 o->pp = new_aubio_peakpicker(); 258 258 o->od = new_aubio_specdesc(onset_mode,buf_size); 259 if (o->od == NULL) goto beach_specdesc; 259 260 o->fftgrain = new_cvec(buf_size); 260 261 o->desc = new_fvec(1); 261 262 o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate); 262 263 263 if (!o->pv || !o->pp || !o->od || !o->fftgrain264 || !o->desc || !o->spectral_whitening)265 goto beach;266 267 264 /* initialize internal variables */ 268 265 aubio_onset_set_default_parameters (o, onset_mode); … … 271 268 return o; 272 269 270 beach_specdesc: 271 del_aubio_peakpicker(o->pp); 272 del_aubio_pvoc(o->pv); 273 273 beach: 274 del_aubio_onset(o);274 AUBIO_FREE(o); 275 275 return NULL; 276 276 } … … 340 340 void del_aubio_onset (aubio_onset_t *o) 341 341 { 342 if (o->spectral_whitening) 343 del_aubio_spectral_whitening(o->spectral_whitening); 344 if (o->od) 345 del_aubio_specdesc(o->od); 346 if (o->pp) 347 del_aubio_peakpicker(o->pp); 348 if (o->pv) 349 del_aubio_pvoc(o->pv); 350 if (o->desc) 351 del_fvec(o->desc); 352 if (o->fftgrain) 353 del_cvec(o->fftgrain); 342 del_aubio_spectral_whitening(o->spectral_whitening); 343 del_aubio_specdesc(o->od); 344 del_aubio_peakpicker(o->pp); 345 del_aubio_pvoc(o->pv); 346 del_fvec(o->desc); 347 del_cvec(o->fftgrain); 354 348 AUBIO_FREE(o); 355 349 } -
tests/src/onset/test-onset.c
rce323e4 r1cf031a 1 1 #include <aubio.h> 2 2 #include "utils_tests.h" 3 4 int test_wrong_params(void);5 3 6 4 int main (int argc, char **argv) … … 9 7 if (argc < 2) { 10 8 err = 2; 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 } 9 PRINT_ERR("not enough arguments\n"); 10 PRINT_MSG("read a wave file as a mono vector\n"); 18 11 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 19 12 return err; … … 68 61 return err; 69 62 } 70 71 int test_wrong_params(void)72 {73 uint_t win_size = 1024;74 uint_t hop_size = win_size / 2;75 uint_t samplerate = 44100;76 // hop_size < 177 if (new_aubio_onset("default", 5, 0, samplerate))78 return 1;79 // buf_size < 280 if (new_aubio_onset("default", 1, 1, samplerate))81 return 1;82 // buf_size < hop_size83 if (new_aubio_onset("default", hop_size, win_size, samplerate))84 return 1;85 // samplerate < 186 if (new_aubio_onset("default", 1024, 512, 0))87 return 1;88 89 // specdesc creation failed90 if (new_aubio_onset("abcd", win_size, win_size/2, samplerate))91 return 1;92 // pv creation failed93 if (new_aubio_onset("default", 5, 2, samplerate))94 return 1;95 96 aubio_onset_t *o;97 o = new_aubio_onset("default", win_size, hop_size, samplerate);98 if (!aubio_onset_set_default_parameters(o, "wrong_type"))99 return 1;100 del_aubio_onset(o);101 102 return 0;103 }
Note: See TracChangeset
for help on using the changeset viewer.