2 Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu>
3 and Paul Brossier <piem@piem.org>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 uint_t n_filters = 40;
29 unsigned int pos = 0; /*frames%dspblocksize*/
32 int aubio_process(float **input, float **output, int nframes);
33 int aubio_process(float **input, float **output, int nframes) {
34 unsigned int i; /*channels*/
35 unsigned int j; /*frames*/
37 for (j=0;j<(unsigned)nframes;j++) {
39 for (i=0;i<channels;i++) {
40 /* write input to datanew */
41 fvec_write_sample(ibuf, input[i][j], i, pos);
42 /* put synthnew in output */
43 output[i][j] = fvec_read_sample(obuf, i, pos);
47 if (pos == overlap_size-1) {
50 //compute mag spectrum
51 aubio_pvoc_do (pv,ibuf, fftgrain);
54 aubio_mfcc_do(mfcc, fftgrain, mfcc_out);
57 for (coef_cnt = 0; coef_cnt < n_coefs; coef_cnt++) {
58 outmsg("%f ",mfcc_out->data[0][coef_cnt]);
62 /* end of block loop */
63 pos = -1; /* so it will be zero next j loop */
70 void process_print (void);
71 void process_print (void) {
72 /* output times in seconds
77 if (output_filename == NULL) {
79 // outmsg("%f\t",(frames-4)*overlap_size/(float)samplerate);
81 // else if (frames < 4) {
84 //outmsg("%f ",mfcc_out->data[0][0]);
90 int main(int argc, char **argv) {
93 examples_common_init(argc,argv);
94 smpl_t lowfreq = 133.333f;
95 smpl_t highfreq = 44100.f;
96 mfcc_out = new_fvec(n_coefs,channels);
99 //populating the filter
100 mfcc = new_aubio_mfcc(buffer_size, samplerate, n_filters, n_coefs , lowfreq, highfreq, channels);
101 dump_filterbank(mfcc);
105 examples_common_process(aubio_process,process_print);
108 del_aubio_mfcc(mfcc);
111 examples_common_del();
112 debug("End of program.\n");