2 #include "utils_tests.h"
4 int test_wrong_params(void);
6 int main (int argc, char** argv)
12 PRINT_WRN("no arguments, running tests\n");
13 err = test_wrong_params();
14 PRINT_MSG("usage: %s <input_path> [samplerate] [hop_size]\n", argv[0]);
18 uint_t win_s; // fft size
19 uint_t hop_s = 256; // block size
20 uint_t samplerate = 0; // samplerate
21 uint_t n_filters = 40; // number of filters
22 uint_t n_coeffs = 13; // number of coefficients
25 char_t *source_path = argv[1];
27 if ( argc >= 3 ) samplerate = atoi(argv[2]);
28 if ( argc >= 4 ) hop_s = atoi(argv[3]);
32 aubio_source_t *source = 0;
34 aubio_mfcc_t *mfcc = 0;
36 fvec_t *in = new_fvec (win_s); // input buffer
37 cvec_t *fftgrain = new_cvec (win_s); // input buffer
38 fvec_t *out = new_fvec (n_coeffs); // output coefficients
40 if (!in || !fftgrain || !out) { err = 1; goto failure; }
43 source = new_aubio_source(source_path, samplerate, hop_s);
44 if (!source) { err = 1; goto failure; }
45 if (samplerate == 0) samplerate = aubio_source_get_samplerate(source);
48 pv = new_aubio_pvoc(win_s, hop_s);
49 if (!pv) { err = 1; goto failure; }
52 mfcc = new_aubio_mfcc (win_s, n_filters, n_coeffs, samplerate);
53 if (!mfcc) { err = 1; goto failure; }
57 aubio_source_do(source, in, &read);
58 aubio_pvoc_do(pv, in, fftgrain);
59 aubio_mfcc_do(mfcc, fftgrain, out);
61 } while (read == hop_s);
70 del_aubio_source(source);
81 int test_wrong_params()
83 uint_t win_s = 512; // fft size
84 uint_t n_filters = 40; // number of filters
85 uint_t n_coeffs = 13; // number of coefficients
86 smpl_t samplerate = 16000.; // samplerate
88 if (new_aubio_mfcc( 0, n_filters, n_coeffs, samplerate)) return 1;
89 if (new_aubio_mfcc(win_s, 0, n_coeffs, samplerate)) return 1;
90 if (new_aubio_mfcc(win_s, n_filters, 0, samplerate)) return 1;
91 if (new_aubio_mfcc(win_s, n_filters, n_coeffs, 0)) return 1;
93 return run_on_default_source(main);