Changes in / [8a11e2f:bbfa9a4]
- Files:
-
- 1 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
VERSION
r8a11e2f rbbfa9a4 1 1 AUBIO_MAJOR_VERSION=0 2 2 AUBIO_MINOR_VERSION=4 3 AUBIO_PATCH_VERSION= 84 AUBIO_VERSION_STATUS=' '3 AUBIO_PATCH_VERSION=9 4 AUBIO_VERSION_STATUS='~alpha' 5 5 LIBAUBIO_LT_CUR=5 6 6 LIBAUBIO_LT_REV=4 -
python/tests/test_phasevoc.py
r8a11e2f rbbfa9a4 55 55 + 'This is expected when using fftw3 on powerpc.') 56 56 assert_equal ( r, 0.) 57 58 def test_no_overlap(self): 59 win_s, hop_s = 1024, 1024 60 f = pvoc (win_s, hop_s) 61 t = fvec (hop_s) 62 for _ in range(4): 63 s = f(t) 64 r = f.rdo(s) 65 assert_equal ( t, 0.) 57 66 58 67 resynth_noise_args = "hop_s, ratio" -
src/onset/onset.c
r8a11e2f rbbfa9a4 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;260 259 o->fftgrain = new_cvec(buf_size); 261 260 o->desc = new_fvec(1); 262 261 o->spectral_whitening = new_aubio_spectral_whitening(buf_size, hop_size, samplerate); 263 262 263 if (!o->pv || !o->pp || !o->od || !o->fftgrain 264 || !o->desc || !o->spectral_whitening) 265 goto beach; 266 264 267 /* initialize internal variables */ 265 268 aubio_onset_set_default_parameters (o, onset_mode); … … 268 271 return o; 269 272 270 beach_specdesc:271 del_aubio_peakpicker(o->pp);272 del_aubio_pvoc(o->pv);273 273 beach: 274 AUBIO_FREE(o);274 del_aubio_onset(o); 275 275 return NULL; 276 276 } … … 340 340 void del_aubio_onset (aubio_onset_t *o) 341 341 { 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); 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); 348 354 AUBIO_FREE(o); 349 355 } -
src/spectral/dct.c
r8a11e2f rbbfa9a4 82 82 aubio_dct_t* new_aubio_dct (uint_t size) { 83 83 aubio_dct_t * s = AUBIO_NEW(aubio_dct_t); 84 if ((sint_t)size <= 0) goto beach;85 84 #if defined(HAVE_ACCELERATE) 86 85 // vDSP supports sizes = f * 2 ** n, where n >= 4 and f in [1, 3, 5, 15] … … 89 88 uint_t radix = size; 90 89 uint_t order = 0; 91 while ((radix / 2) * 2 == radix) {90 while ((radix >= 1) && ((radix / 2) * 2 == radix)) { 92 91 radix /= 2; 93 92 order++; … … 113 112 return s; 114 113 } else { 115 AUBIO_WRN("dct: unex cepected error while creating dct_fftw with size %d",114 AUBIO_WRN("dct: unexpected error while creating dct_fftw with size %d\n", 116 115 size); 117 116 goto plain; … … 126 125 return s; 127 126 } else { 128 AUBIO_WRN("dct: unex cepected error while creating dct_ipp with size %d",127 AUBIO_WRN("dct: unexpected error while creating dct_ipp with size %d\n", 129 128 size); 130 129 goto plain; … … 144 143 #endif 145 144 // falling back to plain mode 146 AUBIO_WRN("dct: d no optimised implementation could be created for size %d",145 AUBIO_WRN("dct: no optimised implementation could be created for size %d\n", 147 146 size); 148 147 plain: … … 157 156 } 158 157 beach: 159 AUBIO_ERROR("dct: failed creating with size %d, should be > 0 ", size);160 AUBIO_FREE(s);158 AUBIO_ERROR("dct: failed creating with size %d, should be > 0\n", size); 159 del_aubio_dct(s); 161 160 return NULL; 162 161 } -
src/spectral/dct_fftw.c
r8a11e2f rbbfa9a4 64 64 aubio_dct_fftw_t * new_aubio_dct_fftw (uint_t size) { 65 65 aubio_dct_fftw_t * s = AUBIO_NEW(aubio_dct_fftw_t); 66 if (!s) { 66 if ((sint_t)size <= 0) { 67 AUBIO_ERR("dct_fftw: can only create with size > 0, requested %d\n", 68 size); 67 69 goto beach; 68 70 } -
src/spectral/dct_ooura.c
r8a11e2f rbbfa9a4 39 39 aubio_dct_ooura_t * new_aubio_dct_ooura (uint_t size) { 40 40 aubio_dct_ooura_t * s = AUBIO_NEW(aubio_dct_ooura_t); 41 if (aubio_is_power_of_two(size) != 1 ) {42 AUBIO_ERR("dct : can only create with sizes power of two, requested %d\n",41 if (aubio_is_power_of_two(size) != 1 || (sint_t)size <= 0) { 42 AUBIO_ERR("dct_ooura: can only create with sizes power of two, requested %d\n", 43 43 size); 44 44 goto beach; -
src/spectral/dct_plain.c
r8a11e2f rbbfa9a4 32 32 }; 33 33 34 void del_aubio_dct_plain (aubio_dct_plain_t *s); 35 34 36 aubio_dct_plain_t * new_aubio_dct_plain (uint_t size) { 35 37 aubio_dct_plain_t * s = AUBIO_NEW(aubio_dct_plain_t); … … 38 40 if (aubio_is_power_of_two (size) == 1 && size > 16) { 39 41 AUBIO_WRN("dct_plain: using plain dct but size %d is a power of two\n", size); 42 } 43 if ((sint_t)size <= 0) { 44 AUBIO_ERR("dct_plain: can only create with size > 0, requested %d\n", 45 size); 46 goto failure; 40 47 } 41 48 … … 69 76 } 70 77 return s; 78 failure: 79 del_aubio_dct_plain(s); 80 return NULL; 71 81 } 72 82 73 83 void del_aubio_dct_plain (aubio_dct_plain_t *s) { 74 del_fmat(s->dct_coeffs); 75 del_fmat(s->idct_coeffs); 84 if (s->dct_coeffs) 85 del_fmat(s->dct_coeffs); 86 if (s->idct_coeffs) 87 del_fmat(s->idct_coeffs); 76 88 AUBIO_FREE(s); 77 89 } … … 79 91 void aubio_dct_plain_do(aubio_dct_plain_t *s, const fvec_t *input, fvec_t *output) { 80 92 if (input->length != output->length || input->length != s->size) { 81 AUBIO_WRN("dct_plain: using input length %d, but output length = %d and size = %d ",93 AUBIO_WRN("dct_plain: using input length %d, but output length = %d and size = %d\n", 82 94 input->length, output->length, s->size); 83 95 } … … 87 99 void aubio_dct_plain_rdo(aubio_dct_plain_t *s, const fvec_t *input, fvec_t *output) { 88 100 if (input->length != output->length || input->length != s->size) { 89 AUBIO_WRN("dct_plain: using input length %d, but output length = %d and size = %d ",101 AUBIO_WRN("dct_plain: using input length %d, but output length = %d and size = %d\n", 90 102 input->length, output->length, s->size); 91 103 } -
src/spectral/filterbank.c
r8a11e2f rbbfa9a4 43 43 /* allocate space for filterbank object */ 44 44 aubio_filterbank_t *fb = AUBIO_NEW (aubio_filterbank_t); 45 46 if ((sint_t)n_filters <= 0) { 47 AUBIO_ERR("filterbank: n_filters should be > 0, got %d\n", n_filters); 48 goto fail; 49 } 50 if ((sint_t)win_s <= 0) { 51 AUBIO_ERR("filterbank: win_s should be > 0, got %d\n", win_s); 52 goto fail; 53 } 45 54 fb->win_s = win_s; 46 55 fb->n_filters = n_filters; … … 54 63 55 64 return fb; 65 fail: 66 AUBIO_FREE (fb); 67 return NULL; 56 68 } 57 69 -
src/spectral/mfcc.c
r8a11e2f rbbfa9a4 32 32 #include "spectral/mfcc.h" 33 33 34 #ifdef HAVE_NOOPT35 #define HAVE_SLOW_DCT 136 #endif37 38 34 /** Internal structure for mfcc object */ 39 35 … … 46 42 aubio_filterbank_t *fb; /** filter bank */ 47 43 fvec_t *in_dct; /** input buffer for dct * [fb->n_filters] */ 48 #if defined(HAVE_SLOW_DCT) 49 fmat_t *dct_coeffs; /** DCT transform n_filters * n_coeffs */ 50 #else 51 aubio_dct_t *dct; 52 fvec_t *output; 53 #endif 44 aubio_dct_t *dct; /** dct object */ 45 fvec_t *output; /** dct output */ 54 46 smpl_t scale; 55 47 }; … … 63 55 /* allocate space for mfcc object */ 64 56 aubio_mfcc_t *mfcc = AUBIO_NEW (aubio_mfcc_t); 65 #if defined(HAVE_SLOW_DCT)66 smpl_t scaling;67 57 68 uint_t i, j; 69 #endif 58 if ((sint_t)n_coefs <= 0) { 59 AUBIO_ERR("mfcc: n_coefs should be > 0, got %d\n", n_coefs); 60 goto failure; 61 } 62 if ((sint_t)samplerate <= 0) { 63 AUBIO_ERR("mfcc: samplerate should be > 0, got %d\n", samplerate); 64 goto failure; 65 } 70 66 71 67 mfcc->win_s = win_s; … … 76 72 /* filterbank allocation */ 77 73 mfcc->fb = new_aubio_filterbank (n_filters, mfcc->win_s); 74 75 if (!mfcc->fb) 76 goto failure; 77 78 78 if (n_filters == 40) 79 79 aubio_filterbank_set_mel_coeffs_slaney (mfcc->fb, samplerate); … … 85 85 mfcc->in_dct = new_fvec (n_filters); 86 86 87 #if defined(HAVE_SLOW_DCT)88 mfcc->dct_coeffs = new_fmat (n_coefs, n_filters);89 90 /* compute DCT transform dct_coeffs[j][i] as91 cos ( j * (i+.5) * PI / n_filters ) */92 scaling = 1. / SQRT (n_filters / 2.);93 for (i = 0; i < n_filters; i++) {94 for (j = 0; j < n_coefs; j++) {95 mfcc->dct_coeffs->data[j][i] =96 scaling * COS (j * (i + 0.5) * PI / n_filters);97 }98 mfcc->dct_coeffs->data[0][i] *= SQRT (2.) / 2.;99 }100 #else101 87 mfcc->dct = new_aubio_dct (n_filters); 102 88 mfcc->output = new_fvec (n_filters); 103 #endif 89 90 if (!mfcc->in_dct || !mfcc->dct || !mfcc->output) 91 goto failure; 104 92 105 93 mfcc->scale = 1.; 106 94 107 95 return mfcc; 96 97 failure: 98 del_aubio_mfcc(mfcc); 99 return NULL; 108 100 } 109 101 … … 111 103 del_aubio_mfcc (aubio_mfcc_t * mf) 112 104 { 113 114 /* delete filterbank */ 115 del_aubio_filterbank (mf->fb); 116 117 /* delete buffers */ 118 del_fvec (mf->in_dct); 119 #if defined(HAVE_SLOW_DCT) 120 del_fmat (mf->dct_coeffs); 121 #else 122 del_aubio_dct (mf->dct); 123 del_fvec (mf->output); 124 #endif 125 126 /* delete mfcc object */ 105 if (mf->fb) 106 del_aubio_filterbank (mf->fb); 107 if (mf->in_dct) 108 del_fvec (mf->in_dct); 109 if (mf->dct) 110 del_aubio_dct (mf->dct); 111 if (mf->output) 112 del_fvec (mf->output); 127 113 AUBIO_FREE (mf); 128 114 } … … 132 118 aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out) 133 119 { 134 #ifndef HAVE_SLOW_DCT135 120 fvec_t tmp; 136 #endif137 121 138 122 /* compute filterbank */ … … 145 129 146 130 /* compute mfccs */ 147 #if defined(HAVE_SLOW_DCT)148 fmat_vecmul(mf->dct_coeffs, mf->in_dct, out);149 #else150 131 aubio_dct_do(mf->dct, mf->in_dct, mf->output); 151 132 // copy only first n_coeffs elements … … 154 135 tmp.length = out->length; 155 136 fvec_copy(&tmp, out); 156 #endif157 137 158 138 return; -
src/spectral/specdesc.c
r8a11e2f rbbfa9a4 297 297 onset_type = aubio_onset_default; 298 298 else { 299 AUBIO_ERR("unknown spectral descriptor type %s\n", onset_mode); 299 AUBIO_ERR("specdesc: unknown spectral descriptor type '%s'\n", 300 onset_mode); 300 301 AUBIO_FREE(o); 301 302 return NULL; -
src/tempo/tempo.c
r8a11e2f rbbfa9a4 129 129 130 130 uint_t aubio_tempo_set_delay_ms(aubio_tempo_t * o, smpl_t delay) { 131 o->delay = 1000. * delay * o->samplerate; 132 return AUBIO_OK; 131 return aubio_tempo_set_delay_s(o, delay / 1000.); 133 132 } 134 133 … … 142 141 143 142 smpl_t aubio_tempo_get_delay_ms(aubio_tempo_t * o) { 144 return o->delay / (smpl_t)(o->samplerate) /1000.;143 return aubio_tempo_get_delay_s(o) * 1000.; 145 144 } 146 145 … … 169 168 { 170 169 aubio_tempo_t * o = AUBIO_NEW(aubio_tempo_t); 171 char_t specdesc_func[ 20];170 char_t specdesc_func[PATH_MAX]; 172 171 o->samplerate = samplerate; 173 172 // check parameters are valid … … 204 203 aubio_peakpicker_set_threshold (o->pp, o->threshold); 205 204 if ( strcmp(tempo_mode, "default") == 0 ) { 206 str cpy(specdesc_func, "specflux");205 strncpy(specdesc_func, "specflux", PATH_MAX - 1); 207 206 } else { 208 strcpy(specdesc_func, tempo_mode); 207 strncpy(specdesc_func, tempo_mode, PATH_MAX - 1); 208 specdesc_func[PATH_MAX - 1] = '\0'; 209 209 } 210 210 o->od = new_aubio_specdesc(specdesc_func,buf_size); … … 216 216 onset2 = new_fvec(1); 217 217 }*/ 218 if (!o->dfframe || !o->fftgrain || !o->out || !o->pv || 219 !o->pp || !o->od || !o->of || !o->bt || !o->onset) { 220 AUBIO_ERR("tempo: failed creating tempo object\n"); 221 goto beach; 222 } 218 223 o->last_tatum = 0; 219 224 o->tatum_signature = 4; … … 221 226 222 227 beach: 223 AUBIO_FREE(o);228 del_aubio_tempo(o); 224 229 return NULL; 225 230 } … … 278 283 void del_aubio_tempo (aubio_tempo_t *o) 279 284 { 280 del_aubio_specdesc(o->od); 281 del_aubio_beattracking(o->bt); 282 del_aubio_peakpicker(o->pp); 283 del_aubio_pvoc(o->pv); 284 del_fvec(o->out); 285 del_fvec(o->of); 286 del_cvec(o->fftgrain); 287 del_fvec(o->dfframe); 288 del_fvec(o->onset); 285 if (o->od) 286 del_aubio_specdesc(o->od); 287 if (o->bt) 288 del_aubio_beattracking(o->bt); 289 if (o->pp) 290 del_aubio_peakpicker(o->pp); 291 if (o->pv) 292 del_aubio_pvoc(o->pv); 293 if (o->out) 294 del_fvec(o->out); 295 if (o->of) 296 del_fvec(o->of); 297 if (o->fftgrain) 298 del_cvec(o->fftgrain); 299 if (o->dfframe) 300 del_fvec(o->dfframe); 301 if (o->onset) 302 del_fvec(o->onset); 289 303 AUBIO_FREE(o); 290 return; 291 } 304 } -
tests/src/onset/test-onset.c
r8a11e2f rbbfa9a4 1 1 #include <aubio.h> 2 2 #include "utils_tests.h" 3 4 int test_wrong_params(void); 3 5 4 6 int main (int argc, char **argv) … … 7 9 if (argc < 2) { 8 10 err = 2; 9 PRINT_ERR("not enough arguments\n"); 10 PRINT_MSG("read a wave file as a mono vector\n"); 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 } 11 18 PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]); 12 19 return err; … … 61 68 return err; 62 69 } 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 < 1 77 if (new_aubio_onset("default", 5, 0, samplerate)) 78 return 1; 79 // buf_size < 2 80 if (new_aubio_onset("default", 1, 1, samplerate)) 81 return 1; 82 // buf_size < hop_size 83 if (new_aubio_onset("default", hop_size, win_size, samplerate)) 84 return 1; 85 // samplerate < 1 86 if (new_aubio_onset("default", 1024, 512, 0)) 87 return 1; 88 89 // 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; 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 } -
tests/src/spectral/test-awhitening.c
r8a11e2f rbbfa9a4 1 1 #include <aubio.h> 2 2 #include "utils_tests.h" 3 4 int test_wrong_params(void); 3 5 4 6 int main (int argc, char **argv) … … 8 10 if (argc < 3) { 9 11 err = 2; 10 PRINT_ERR("not enough arguments\n"); 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 } 11 19 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]); 12 20 return err; … … 83 91 } 84 92 93 int test_wrong_params(void) 94 { 95 uint_t buf_size = 512; 96 uint_t hop_size = 256; 97 uint_t samplerate = 44100; 98 aubio_spectral_whitening_t *o; 99 100 if (new_aubio_spectral_whitening( 0, hop_size, samplerate)) return 1; 101 if (new_aubio_spectral_whitening(buf_size, 0, samplerate)) return 1; 102 if (new_aubio_spectral_whitening(buf_size, hop_size, 0)) return 1; 103 104 o = new_aubio_spectral_whitening(buf_size, hop_size, samplerate); 105 106 aubio_spectral_whitening_get_relax_time(o); 107 aubio_spectral_whitening_get_floor(o); 108 109 del_aubio_spectral_whitening(o); 110 111 return 0; 112 } -
tests/src/spectral/test-dct.c
r8a11e2f rbbfa9a4 10 10 // create dct object 11 11 aubio_dct_t * dct = new_aubio_dct(win_s); 12 aubio_dct_t * tmp; 13 14 if (new_aubio_dct(0)) return 1; 12 15 13 16 fvec_t * in = new_fvec (win_s); // input buffer 14 17 fvec_t * dctout = new_fvec (win_s); // output buffer 15 18 fvec_t * out = new_fvec (win_s); // input buffer 19 20 if ((tmp = new_aubio_dct(1)) == 0) return 1; 21 //aubio_dct_do(tmp, dctout, out); 22 //aubio_dct_rdo(tmp, dctout, out); 23 del_aubio_dct(tmp); 16 24 17 25 if (!dct || !in || !dctout) { -
tests/src/spectral/test-filterbank.c
r8a11e2f rbbfa9a4 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 11 if (new_aubio_filterbank(0, win_s)) return 1; 12 if (new_aubio_filterbank(n_filters, 0)) return 1; 10 13 11 14 // create filterbank object -
tests/src/spectral/test-mfcc.c
r8a11e2f rbbfa9a4 5 5 uint_t win_s = 512; // fft size 6 6 uint_t n_filters = 40; // number of filters 7 uint_t n_coef s = 13; // number of coefficients7 uint_t n_coeffs = 13; // number of coefficients 8 8 smpl_t samplerate = 16000.; // samplerate 9 9 cvec_t *in = new_cvec (win_s); // input buffer 10 fvec_t *out = new_fvec (n_coefs); // output coefficients 10 fvec_t *out = new_fvec (n_coeffs); // output coefficients 11 12 if (new_aubio_mfcc( 0, n_filters, n_coeffs, samplerate)) return 1; 13 if (new_aubio_mfcc(win_s, 0, n_coeffs, samplerate)) return 1; 14 if (new_aubio_mfcc(win_s, n_filters, 0, samplerate)) return 1; 15 if (new_aubio_mfcc(win_s, n_filters, n_coeffs, 0)) return 1; 11 16 12 17 // create mfcc object 13 aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coef s, samplerate);18 aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coeffs, samplerate); 14 19 15 20 cvec_norm_set_all (in, 1.); -
tests/src/spectral/test-phasevoc.c
r8a11e2f rbbfa9a4 13 13 // allocate fft and other memory space 14 14 aubio_pvoc_t * pv = new_aubio_pvoc(win_s,hop_s); 15 16 if (new_aubio_pvoc(win_s, 0)) return 1; 17 18 if (aubio_pvoc_get_win(pv) != win_s) return 1; 19 if (aubio_pvoc_get_hop(pv) != hop_s) return 1; 20 21 if (aubio_pvoc_set_window(pv, "hanningz") != 0) return 1; 15 22 16 23 // fill input with some data -
tests/src/spectral/test-tss.c
r8a11e2f rbbfa9a4 35 35 } 36 36 37 aubio_tss_set_alpha(tss, 4.); 38 aubio_tss_set_beta(tss, 3.); 39 aubio_tss_set_threshold(tss, 3.); 40 37 41 del_aubio_pvoc(pv); 38 42 del_aubio_pvoc(pvt); -
tests/src/tempo/test-tempo.c
r8a11e2f rbbfa9a4 1 1 #include <aubio.h> 2 2 #include "utils_tests.h" 3 4 int test_wrong_params(void); 3 5 4 6 int main (int argc, char **argv) … … 7 9 if (argc < 2) { 8 10 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] [win_size] [hop_size]\n", argv[0]); 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 } 18 PRINT_MSG("usage: %s <source_path> [samplerate] [win_size] [hop_size]\n", 19 argv[0]); 12 20 return err; 13 21 } … … 21 29 22 30 char_t *source_path = argv[1]; 23 aubio_source_t * source = new_aubio_source(source_path, samplerate, hop_size); 31 aubio_source_t * source = new_aubio_source(source_path, samplerate, 32 hop_size); 24 33 if (!source) { err = 1; goto beach; } 25 34 … … 31 40 32 41 // create tempo object 33 aubio_tempo_t * o = new_aubio_tempo("default", win_size, hop_size, samplerate); 42 aubio_tempo_t * o = new_aubio_tempo("default", win_size, hop_size, 43 samplerate); 44 45 if (!o) { err = 1; goto beach_tempo; } 34 46 35 47 do { … … 40 52 // do something with the beats 41 53 if (out->data[0] != 0) { 42 PRINT_MSG("beat at %.3fms, %.3fs, frame %d, %.2fbpm with confidence %.2f\n", 54 PRINT_MSG("beat at %.3fms, %.3fs, frame %d, %.2f bpm " 55 "with confidence %.2f\n", 43 56 aubio_tempo_get_last_ms(o), aubio_tempo_get_last_s(o), 44 aubio_tempo_get_last(o), aubio_tempo_get_bpm(o), aubio_tempo_get_confidence(o)); 57 aubio_tempo_get_last(o), aubio_tempo_get_bpm(o), 58 aubio_tempo_get_confidence(o)); 45 59 } 46 60 n_frames += read; … … 54 68 // clean up memory 55 69 del_aubio_tempo(o); 70 beach_tempo: 56 71 del_fvec(in); 57 72 del_fvec(out); … … 62 77 return err; 63 78 } 79 80 int test_wrong_params(void) 81 { 82 uint_t win_size = 1024; 83 uint_t hop_size = 256; 84 uint_t samplerate = 44100; 85 aubio_tempo_t *t; 86 fvec_t* in, *out; 87 uint_t i; 88 89 // test wrong method fails 90 if (new_aubio_tempo("unexisting_method", win_size, hop_size, samplerate)) 91 return 1; 92 93 // test hop > win fails 94 if (new_aubio_tempo("default", hop_size, win_size, samplerate)) 95 return 1; 96 97 // test null hop_size fails 98 if (new_aubio_tempo("default", win_size, 0, samplerate)) 99 return 1; 100 101 // test 1 buf_size fails 102 if (new_aubio_tempo("default", 1, 1, samplerate)) 103 return 1; 104 105 // test null samplerate fails 106 if (new_aubio_tempo("default", win_size, hop_size, 0)) 107 return 1; 108 109 // test short sizes workaround 110 t = new_aubio_tempo("default", 2048, 2048, 500); 111 if (!t) 112 return 1; 113 114 del_aubio_tempo(t); 115 116 t = new_aubio_tempo("default", win_size, hop_size, samplerate); 117 if (!t) 118 return 1; 119 120 in = new_fvec(hop_size); 121 out = new_fvec(1); 122 123 // up to step = (next_power_of_two(5.8 * samplerate / hop_size ) / 4 ) 124 for (i = 0; i < 256 + 1; i++) 125 { 126 aubio_tempo_do(t,in,out); 127 PRINT_MSG("beat at %.3fms, %.3fs, frame %d, %.2f bpm " 128 "with confidence %.2f, was tatum %d\n", 129 aubio_tempo_get_last_ms(t), aubio_tempo_get_last_s(t), 130 aubio_tempo_get_last(t), aubio_tempo_get_bpm(t), 131 aubio_tempo_get_confidence(t), aubio_tempo_was_tatum(t)); 132 } 133 134 del_aubio_tempo(t); 135 del_fvec(in); 136 del_fvec(out); 137 138 return 0; 139 }
Note: See TracChangeset
for help on using the changeset viewer.