source: examples/aubiomfcc.c @ f72ceeb

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since f72ceeb was f72ceeb, checked in by Amaury Hazan <mahmoudax@gmail.com>, 17 years ago

aubiomfcc.c: added a dump filterbank funcion
filterbank: written mfcc filterbank init according to slaney auditory toolbox (90%)
plotfb.py: added x log scale option
#some hacks and debug test

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[88199ce]1/*
[53a7576]2   Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu>
3                  and Paul Brossier <piem@piem.org>
[88199ce]4
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.
9
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.
14
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.
18*/
19
20#include "utils.h"
21
[3e7c408]22/* mfcc objects */
[2a77ff0]23fvec_t * mfcc_out;
[3e7c408]24aubio_mfcc_t * mfcc;
25
[f72ceeb]26uint_t n_filters = 40;
27uint_t n_coefs = 20;
[7a46bf6]28
[88199ce]29unsigned int pos = 0; /*frames%dspblocksize*/
30uint_t usepitch = 0;
31
32int aubio_process(float **input, float **output, int nframes);
33int aubio_process(float **input, float **output, int nframes) {
34  unsigned int i;       /*channels*/
35  unsigned int j;       /*frames*/
[dcc649c]36 
[88199ce]37  for (j=0;j<(unsigned)nframes;j++) {
38    if(usejack) {
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);
44      }
45    }
46    /*time for fft*/
47    if (pos == overlap_size-1) {         
48      /* block loop */
49     
50      //compute mag spectrum
51      aubio_pvoc_do (pv,ibuf, fftgrain);
[71d3bf0]52     
[88199ce]53      //compute mfccs
[2a77ff0]54      aubio_mfcc_do(mfcc, fftgrain, mfcc_out);
[f72ceeb]55     
56      uint_t coef_cnt;
57      for (coef_cnt = 0; coef_cnt < n_coefs; coef_cnt++) {
58          outmsg("%f ",mfcc_out->data[0][coef_cnt]);
59      }
60      outmsg("\n");
61     
[88199ce]62      /* end of block loop */
63      pos = -1; /* so it will be zero next j loop */
64    }
65    pos++;
66  }
67  return 1;
68}
69
70void process_print (void);
71void process_print (void) {
72      /* output times in seconds
73         write extracted mfccs
74      */
75     
[7a46bf6]76      uint_t coef_cnt;
[88199ce]77      if (output_filename == NULL) {
[7a46bf6]78//         if(frames >= 4) {
79//           outmsg("%f\t",(frames-4)*overlap_size/(float)samplerate);
80//         }
81//         else if (frames < 4) {
82//           outmsg("%f\t",0.);
83//         }
84        //outmsg("%f ",mfcc_out->data[0][0]);
85       
[f72ceeb]86       
[88199ce]87      }
88}
89
90int main(int argc, char **argv) {
[3e7c408]91  // params
[ef1c3b7]92 
[88199ce]93  examples_common_init(argc,argv);
[7a46bf6]94  smpl_t lowfreq = 133.333f;
95  smpl_t highfreq = 44100.f;
96  mfcc_out = new_fvec(n_coefs,channels);
[fe28ff3]97 
[f72ceeb]98 
[fe28ff3]99  //populating the filter
[7a46bf6]100  mfcc = new_aubio_mfcc(buffer_size, samplerate, n_filters, n_coefs , lowfreq, highfreq, channels);
[ef1c3b7]101  dump_filterbank(mfcc);
102 
[f72ceeb]103 
[fe28ff3]104  //process
[88199ce]105  examples_common_process(aubio_process,process_print);
[fe28ff3]106 
[3e7c408]107  //destroying mfcc
108  del_aubio_mfcc(mfcc);
[2a77ff0]109  del_fvec(mfcc_out);
[38837b1]110
[88199ce]111  examples_common_del();
112  debug("End of program.\n");
113  fflush(stderr);
[fe28ff3]114 
[88199ce]115  return 0;
116}
117
Note: See TracBrowser for help on using the repository browser.