2 #include "utils_tests.h"
4 int main (int argc, char **argv)
10 PRINT_ERR("not enough arguments\n");
11 PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
15 uint_t samplerate = 0;
16 uint_t win_size = 1024;
17 uint_t hop_size = 512;
18 uint_t n_frames = 0, read = 0;
20 char_t *source_path = argv[1];
21 char_t *sink_path = argv[2];
23 if ( argc >= 4 ) samplerate = atoi(argv[3]);
24 if ( argc >= 5 ) hop_size = atoi(argv[4]);
27 PRINT_ERR("too many arguments\n");
31 fvec_t *vec = new_fvec(hop_size);
32 fvec_t *out = new_fvec(hop_size); // output buffer
33 fvec_t *scale = new_fvec(hop_size);
34 cvec_t *fftgrain = new_cvec(win_size); // fft norm and phase
35 if (!vec) { err = 1; goto beach_fvec; }
37 aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
38 if (!i) { err = 1; goto beach_source; }
40 if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);
42 aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
43 if (!o) { err = 1; goto beach_sink; }
45 aubio_pvoc_t *pv = new_aubio_pvoc(win_size, hop_size);
47 aubio_spectral_whitening_t *awhitening =
48 new_aubio_spectral_whitening (win_size, hop_size, samplerate);
50 aubio_spectral_whitening_set_relax_time(awhitening, 20.);
51 fvec_set_all(scale, 3.);
53 PRINT_MSG("spectral whitening relaxation time is %f\n",
54 aubio_spectral_whitening_get_relax_time(awhitening));
57 aubio_source_do(i, vec, &read);
58 aubio_pvoc_do(pv, vec, fftgrain);
59 // apply spectral whitening
60 aubio_spectral_whitening_do(awhitening, fftgrain);
62 aubio_pvoc_rdo(pv, fftgrain, out);
64 fvec_weight(out, scale);
65 // make sure we dont saturate
68 aubio_sink_do(o, out, read);
70 } while ( read == hop_size );
72 PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
73 n_frames, samplerate, n_frames / hop_size,
74 source_path, sink_path);