--- /dev/null
- //uint_t n_filters = 40;
- //uint_t n_coefs = 15;
-
+ /*
+ Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu>
+ and Paul Brossier <piem@piem.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+ #include "utils.h"
+
+ /* mfcc objects */
+ fvec_t * mfcc_out;
+ aubio_mfcc_t * mfcc;
+
+ uint_t n_filters = 20;
+ uint_t n_coefs = 11;
+
+ unsigned int pos = 0; /*frames%dspblocksize*/
+ uint_t usepitch = 0;
+
+ int aubio_process(float **input, float **output, int nframes);
+ int aubio_process(float **input, float **output, int nframes) {
+ unsigned int i; /*channels*/
+ unsigned int j; /*frames*/
+
+ for (j=0;j<(unsigned)nframes;j++) {
+ if(usejack) {
+ for (i=0;i<channels;i++) {
+ /* write input to datanew */
+ fvec_write_sample(ibuf, input[i][j], i, pos);
+ /* put synthnew in output */
+ output[i][j] = fvec_read_sample(obuf, i, pos);
+ }
+ }
+ /*time for fft*/
+ if (pos == overlap_size-1) {
+ /* block loop */
+
+ //compute mag spectrum
+ aubio_pvoc_do (pv,ibuf, fftgrain);
+
+ //compute mfccs
+ aubio_mfcc_do(mfcc, fftgrain, mfcc_out);
+
+ /* end of block loop */
+ pos = -1; /* so it will be zero next j loop */
+ }
+ pos++;
+ }
+ return 1;
+ }
+
+ void process_print (void);
+ void process_print (void) {
+ /* output times in seconds
+ write extracted mfccs
+ */
+
+ uint_t coef_cnt;
+ if (output_filename == NULL) {
+ // if(frames >= 4) {
+ // outmsg("%f\t",(frames-4)*overlap_size/(float)samplerate);
+ // }
+ // else if (frames < 4) {
+ // outmsg("%f\t",0.);
+ // }
+ //outmsg("%f ",mfcc_out->data[0][0]);
+
+ /*for (coef_cnt = 0; coef_cnt < n_coefs; coef_cnt++) {
+ outmsg("%f ",mfcc_out->data[0][coef_cnt]);
+ }
+ outmsg("\n");/*/
+ }
+ }
+
+ int main(int argc, char **argv) {
+ // params
-
++
+ examples_common_init(argc,argv);
+ smpl_t lowfreq = 133.333f;
+ smpl_t highfreq = 44100.f;
+ mfcc_out = new_fvec(n_coefs,channels);
+
+ //populating the filter
+ mfcc = new_aubio_mfcc(buffer_size, samplerate, n_filters, n_coefs , lowfreq, highfreq, channels);
++ dump_filterbank(mfcc);
++
+ //process
+ examples_common_process(aubio_process,process_print);
+
+ //destroying mfcc
+ del_aubio_mfcc(mfcc);
+ del_fvec(mfcc_out);
+
+ examples_common_del();
+ debug("End of program.\n");
+ fflush(stderr);
+
+ return 0;
+ }
+
--- /dev/null
- uint_t writelog=1;
+ /*
+ Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu>
+ and Paul Brossier <piem@piem.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ */
+
+ /* part of this mfcc implementation were inspired from LibXtract
+ http://libxtract.sourceforge.net/
+ */
+
+ #include "aubio_priv.h"
+ #include "sample.h"
+ #include "filterbank.h"
+
+ #include "stdio.h"
+
+ #define USE_EQUAL_GAIN 1
+ #define VERY_SMALL_NUMBER 2e-42
+
+ /** \brief A structure to store a set of n_filters filters of lenghts win_s */
+ struct aubio_filterbank_t_ {
+ uint_t win_s;
+ uint_t n_filters;
+ fvec_t **filters;
+ };
+
+ aubio_filterbank_t * new_aubio_filterbank(uint_t n_filters, uint_t win_s){
+ /** allocating space for filterbank object */
+ aubio_filterbank_t * fb = AUBIO_NEW(aubio_filterbank_t);
+ uint_t filter_cnt;
+ fb->win_s=win_s;
+ fb->n_filters=n_filters;
+
+ /** allocating filter tables */
+ fb->filters=AUBIO_ARRAY(fvec_t*,n_filters);
+ for (filter_cnt=0; filter_cnt<n_filters; filter_cnt++)
+ /* considering one-channel filters */
+ fb->filters[filter_cnt]=new_fvec(win_s, 1);
+
+ return fb;
+ }
+
+ aubio_filterbank_t * new_aubio_filterbank_mfcc(uint_t n_filters, uint_t win_s, smpl_t samplerate, smpl_t freq_min, smpl_t freq_max){
+
- FILE * mlog;
- if(writelog==1) mlog=fopen("filterbank.txt","w");
++ smpl_t nyquist = samplerate/2.;
++ uint_t style = 1;
++ aubio_filterbank_t * fb = new_aubio_filterbank(n_filters, win_s);
+
- if(writelog){
- //dumping filter values
- smpl_t area_tmp=0.f;
- for(k = 0; k < fb->win_s; k++){
- fprintf(mlog,"%f ",fb->filters[n]->data[0][k]);
- }
- fprintf(mlog,"\n");
- }
++ uint_t n, i, k, *fft_peak, M, next_peak;
++ smpl_t norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val,
++ freq_bw_mel, *mel_peak, *height_norm, *lin_peak;
++
++ mel_peak = height_norm = lin_peak = NULL;
++ fft_peak = NULL;
++ norm = 1;
++
++ mel_freq_max = 1127 * log(1 + freq_max / 700);
++ mel_freq_min = 1127 * log(1 + freq_min / 700);
++ freq_bw_mel = (mel_freq_max - mel_freq_min) / fb->n_filters;
++
++ mel_peak = (smpl_t *)malloc((fb->n_filters + 2) * sizeof(smpl_t));
++ /* +2 for zeros at start and end */
++ lin_peak = (smpl_t *)malloc((fb->n_filters + 2) * sizeof(smpl_t));
++ fft_peak = (uint_t *)malloc((fb->n_filters + 2) * sizeof(uint_t));
++ height_norm = (smpl_t *)malloc(fb->n_filters * sizeof(smpl_t));
++
++ if(mel_peak == NULL || height_norm == NULL ||
++ lin_peak == NULL || fft_peak == NULL)
++ return NULL;
++
++ M = fb->win_s >> 1;
++
++ mel_peak[0] = mel_freq_min;
++ lin_peak[0] = 700 * (exp(mel_peak[0] / 1127) - 1);
++ fft_peak[0] = lin_peak[0] / nyquist * M;
++
++ for (n = 1; n <= fb->n_filters; n++){
++ /*roll out peak locations - mel, linear and linear on fft window scale */
++ mel_peak[n] = mel_peak[n - 1] + freq_bw_mel;
++ lin_peak[n] = 700 * (exp(mel_peak[n] / 1127) -1);
++ fft_peak[n] = lin_peak[n] / nyquist * M;
++ }
++
++ for (n = 0; n < fb->n_filters; n++){
++ /*roll out normalised gain of each peak*/
++ if (style == USE_EQUAL_GAIN){
++ height = 1;
++ norm_fact = norm;
++ }
++ else{
++ height = 2 / (lin_peak[n + 2] - lin_peak[n]);
++ norm_fact = norm / (2 / (lin_peak[2] - lin_peak[0]));
++ }
++ height_norm[n] = height * norm_fact;
++ }
++
++ i = 0;
++
++ for(n = 0; n < fb->n_filters; n++){
++
++ /*calculate the rise increment*/
++ if(n > 0)
++ inc = height_norm[n] / (fft_peak[n] - fft_peak[n - 1]);
++ else
++ inc = height_norm[n] / fft_peak[n];
++ val = 0;
++
++ /*zero the start of the array*/
++ for(k = 0; k < i; k++)
++ fb->filters[n]->data[0][k]=0.f;
++
++ /*fill in the rise */
++ for(; i <= fft_peak[n]; i++){
++ fb->filters[n]->data[0][k]=val;
++ val += inc;
++ }
++
++ /*calculate the fall increment */
++ inc = height_norm[n] / (fft_peak[n + 1] - fft_peak[n]);
++
++ val = 0;
++ next_peak = fft_peak[n + 1];
++
++ /*reverse fill the 'fall' */
++ for(i = next_peak; i > fft_peak[n]; i--){
++ fb->filters[n]->data[0][k]=val;
++ val += inc;
++ }
++
++ /*zero the rest of the array*/
++ for(k = next_peak + 1; k < fb->win_s; k++)
++ fb->filters[n]->data[0][k]=0.f;
++
++
++ }
++
++ free(mel_peak);
++ free(lin_peak);
++ free(height_norm);
++ free(fft_peak);
++
++
++ return fb;
++
++}
++
++
++aubio_filterbank_t * new_aubio_filterbank_mfcc2(uint_t n_filters, uint_t win_s, smpl_t samplerate, smpl_t freq_min, smpl_t freq_max){
++
++ //slaney params
++ smpl_t lowestFrequency = 133.3333;
++ smpl_t linearSpacing = 66.66666666;
++ smpl_t logSpacing = 1.0711703;
++
++ uint_t linearFilters = 13;
++ uint_t logFilters = 27;
++ uint_t allFilters = linearFilters + logFilters;
+
++ //buffers for computing filter frequencies
++ fvec_t * freqs=new_fvec( allFilters +2 , 1);
++ fvec_t * lower_freqs=new_fvec( allFilters, 1);
++ fvec_t * upper_freqs=new_fvec( allFilters, 1);
++ fvec_t * center_freqs=new_fvec( allFilters, 1);
++ fvec_t * triangle_heights=new_fvec( allFilters, 1);
++ //lookup table of each bin frequency in hz
++ fvec_t * fft_freqs=(win_s, 1);
++
++ uint_t filter_cnt, bin_cnt;
++
++ //first: filling all the linear filter frequencies
++ for(filter_cnt=0; filter_cnt<linearFilters; filter_cnt++){
++ freqs[0][filter_cnt]=lowestFrequency+ filter_cnt*linearSpacing;
++ }
++ smpl_t lastlinearCF=freqs[0][filter_cnt-1];
++
++ //second: filling all the log filter frequencies
++ for(filter_cnt=0; filter_cnt<logFilters+2; filter_cnt++){
++ freqs[filter_cnt+linearFilters]=lastlinearCF*(pow(logSpacing,filter_cnt+1));
++ }
++ //TODO: check if the referencing above works!
++ lower_freqs->data=freqs->data;
++ center_freqs->data=&(freqs->data[1]);
++ upper_freqs->data=&(freqs->data[2]);
++
++ //computing triangle heights so that each triangle has unit area
++ for(filter_cnt=0; filter_cnt<allFilters; filter_cnt++){
++ triangle_heights[filter_cnt]=2./(upper_freqs[filter_cnt]-lower_freqs[filter_cnt]);
++ }
+
++ //filling the lookup table, which assign the frequency in hz to each bin
++ for(bin_cnt=0; bin_cnt<win_s; bin_cnt++){
++ //TODO: check the formula!
++ fft_freqs[bin_cnt]=((smpl_t) bin_cnt/(smpl_t) win_s)* (smpl_t) samplerate;
++ }
++
++ //building each filter
++ for(filter_cnt=0; filter_cnt<allFilters; filter_cnt++){
++ //finding bins corresponding to lower, center, and upper frequencies
++
++ for(bin_cnt=0; bin_cnt<; bin_cnt++)
++ fb->filters[filter_cnt]->data[0][bin_cnt]=0.f;
++ }
++
++ // xtract
+ smpl_t nyquist = samplerate/2.;
+ uint_t style = 1;
+ aubio_filterbank_t * fb = new_aubio_filterbank(n_filters, win_s);
+
+ uint_t n, i, k, *fft_peak, M, next_peak;
+ smpl_t norm, mel_freq_max, mel_freq_min, norm_fact, height, inc, val,
+ freq_bw_mel, *mel_peak, *height_norm, *lin_peak;
+
+ mel_peak = height_norm = lin_peak = NULL;
+ fft_peak = NULL;
+ norm = 1;
+
+ mel_freq_max = 1127 * log(1 + freq_max / 700);
+ mel_freq_min = 1127 * log(1 + freq_min / 700);
+ freq_bw_mel = (mel_freq_max - mel_freq_min) / fb->n_filters;
+
+ mel_peak = (smpl_t *)malloc((fb->n_filters + 2) * sizeof(smpl_t));
+ /* +2 for zeros at start and end */
+ lin_peak = (smpl_t *)malloc((fb->n_filters + 2) * sizeof(smpl_t));
+ fft_peak = (uint_t *)malloc((fb->n_filters + 2) * sizeof(uint_t));
+ height_norm = (smpl_t *)malloc(fb->n_filters * sizeof(smpl_t));
+
+ if(mel_peak == NULL || height_norm == NULL ||
+ lin_peak == NULL || fft_peak == NULL)
+ return NULL;
+
+ M = fb->win_s >> 1;
+
+ mel_peak[0] = mel_freq_min;
+ lin_peak[0] = 700 * (exp(mel_peak[0] / 1127) - 1);
+ fft_peak[0] = lin_peak[0] / nyquist * M;
+
+ for (n = 1; n <= fb->n_filters; n++){
+ /*roll out peak locations - mel, linear and linear on fft window scale */
+ mel_peak[n] = mel_peak[n - 1] + freq_bw_mel;
+ lin_peak[n] = 700 * (exp(mel_peak[n] / 1127) -1);
+ fft_peak[n] = lin_peak[n] / nyquist * M;
+ }
+
+ for (n = 0; n < fb->n_filters; n++){
+ /*roll out normalised gain of each peak*/
+ if (style == USE_EQUAL_GAIN){
+ height = 1;
+ norm_fact = norm;
+ }
+ else{
+ height = 2 / (lin_peak[n + 2] - lin_peak[n]);
+ norm_fact = norm / (2 / (lin_peak[2] - lin_peak[0]));
+ }
+ height_norm[n] = height * norm_fact;
+ }
+
+ i = 0;
+
+ for(n = 0; n < fb->n_filters; n++){
+
+ /*calculate the rise increment*/
+ if(n > 0)
+ inc = height_norm[n] / (fft_peak[n] - fft_peak[n - 1]);
+ else
+ inc = height_norm[n] / fft_peak[n];
+ val = 0;
+
+ /*zero the start of the array*/
+ for(k = 0; k < i; k++)
+ fb->filters[n]->data[0][k]=0.f;
+
+ /*fill in the rise */
+ for(; i <= fft_peak[n]; i++){
+ fb->filters[n]->data[0][k]=val;
+ val += inc;
+ }
+
+ /*calculate the fall increment */
+ inc = height_norm[n] / (fft_peak[n + 1] - fft_peak[n]);
+
+ val = 0;
+ next_peak = fft_peak[n + 1];
+
+ /*reverse fill the 'fall' */
+ for(i = next_peak; i > fft_peak[n]; i--){
+ fb->filters[n]->data[0][k]=val;
+ val += inc;
+ }
+
+ /*zero the rest of the array*/
+ for(k = next_peak + 1; k < fb->win_s; k++)
+ fb->filters[n]->data[0][k]=0.f;
+
- if(mlog) fclose(mlog);
+
+ }
+
+ free(mel_peak);
+ free(lin_peak);
+ free(height_norm);
+ free(fft_peak);
+
+
+ return fb;
+
+ }
+
++void aubio_dump_filterbank(aubio_filterbank_t * fb){
++
++ FILE * mlog;
++ mlog=fopen("filterbank.txt","w");
++
++ int k,n;
++ //dumping filter values
++ //smpl_t area_tmp=0.f;
++ for(n = 0; n < fb->n_filters; n++){
++ for(k = 0; k < fb->win_s; k++){
++ fprintf(mlog,"%f ",fb->filters[n]->data[0][k]);
++ }
++ fprintf(mlog,"\n");
++ }
++
++ if(mlog) fclose(mlog);
++}
+
+ void del_aubio_filterbank(aubio_filterbank_t * fb){
+ uint_t filter_cnt;
+ /** deleting filter tables first */
+ for (filter_cnt=0; filter_cnt<fb->n_filters; filter_cnt++)
+ del_fvec(fb->filters[filter_cnt]);
+ AUBIO_FREE(fb->filters);
+ AUBIO_FREE(fb);
+ }
+
+ void aubio_filterbank_do(aubio_filterbank_t * f, cvec_t * in, fvec_t *out) {
+ uint_t n, filter_cnt;
+ for(filter_cnt = 0; (filter_cnt < f->n_filters)
+ && (filter_cnt < out->length); filter_cnt++){
+ out->data[0][filter_cnt] = 0.f;
+ for(n = 0; n < in->length; n++){
+ out->data[0][filter_cnt] += in->norm[0][n]
+ * f->filters[filter_cnt]->data[0][n];
+ }
+ out->data[0][filter_cnt] =
+ LOG(out->data[0][filter_cnt] < VERY_SMALL_NUMBER ?
+ VERY_SMALL_NUMBER : out->data[0][filter_cnt]);
+ }
+
+ return;
+ }
--- /dev/null
- \param nyquist nyquist frequency, i.e. half of the sampling rate
- \param style libxtract style
- \param freqmin lowest filter frequency
- \param freqmax highest filter frequency
+ /*
+ Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu>
+ and Paul Brossier <piem@piem.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+ /** \file
+
+ Filterbank object
+
+ General-purpose spectral filterbank object. Comes with mel-filter initialization function.
+
+ */
+
+ #ifndef FILTERBANK_H
+ #define FILTERBANK_H
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+ typedef struct aubio_filterbank_t_ aubio_filterbank_t;
+
+ /** create filterbank object
+
+ \param win_s size of analysis buffer (and length the FFT transform)
+ \param n_filters number of filters to create
+
+ */
+
+ aubio_filterbank_t * new_aubio_filterbank(uint_t n_filters, uint_t win_s);
+
+ /** filterbank initialization for mel filters
+
++
++ \param n_filters number of filters
++ \param win_s window size
++ \param samplerate
++ \param freq_min lowest filter frequency
++ \param freq_max highest filter frequency
+
+ */
+ aubio_filterbank_t * new_aubio_filterbank_mfcc(uint_t n_filters, uint_t win_s, smpl_t samplerate, smpl_t freq_min, smpl_t freq_max);
+
++/** filterbank initialization for mel filters
++
++ \param n_filters number of filters
++ \param win_s window size
++ \param samplerate
++ \param freq_min lowest filter frequency
++ \param freq_max highest filter frequency
++
++*/
++aubio_filterbank_t * new_aubio_filterbank_mfcc_2(uint_t n_filters, uint_t win_s, smpl_t samplerate, smpl_t freq_min, smpl_t freq_max);
++
+
+ /** destroy filterbank object
+
+ \param fb filterbank, as returned by new_aubio_filterbank method
+
+ */
+ void del_aubio_filterbank(aubio_filterbank_t * fb);
+
+ /** compute filterbank
+
+ */
+ void aubio_filterbank_do(aubio_filterbank_t * fb, cvec_t * in, fvec_t *out);
+
++/** dump filterbank filter tables in a txt file
++
++*/
++void aubio_dump_filterbank(aubio_filterbank_t * fb);
++
+ #ifdef __cplusplus
+ }
+ #endif
+
+ #endif // FILTERBANK_H
--- /dev/null
+ /*
+ Copyright (C) 2006 Amaury Hazan
+ Ported to aubio from LibXtract
+ http://libxtract.sourceforge.net/
+
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ */
+
+ #include "aubio_priv.h"
+ #include "sample.h"
+ #include "fft.h"
+ #include "filterbank.h"
+ #include "mfcc.h"
+ #include "math.h"
+
+ /** Internal structure for mfcc object **/
+
+ struct aubio_mfcc_t_{
+ uint_t win_s; /** grain length */
+ uint_t samplerate; /** sample rate (needed?) */
+ uint_t channels; /** number of channels */
+ uint_t n_filters; /** number of *filters */
+ uint_t n_coefs; /** number of coefficients (<= n_filters/2 +1) */
+ smpl_t lowfreq; /** lowest frequency for filters */
+ smpl_t highfreq; /** highest frequency for filters */
+ aubio_filterbank_t * fb; /** filter bank */
+ fvec_t * in_dct; /** input buffer for dct * [fb->n_filters] */
+ aubio_mfft_t * fft_dct; /** fft object for dct */
+ cvec_t * fftgrain_dct; /** output buffer for dct */
+ };
+
+
+ aubio_mfcc_t * new_aubio_mfcc (uint_t win_s, uint_t samplerate, uint_t n_filters, uint_t n_coefs, smpl_t lowfreq, smpl_t highfreq, uint_t channels){
+ /** allocating space for mfcc object */
+ aubio_mfcc_t * mfcc = AUBIO_NEW(aubio_mfcc_t);
+
+ //we need (n_coefs-1)*2 filters to obtain n_coefs coefficients after dct
+ //uint_t n_filters = (n_coefs-1)*2;
+
+ mfcc->win_s=win_s;
+ mfcc->samplerate=samplerate;
+ mfcc->channels=channels;
+ mfcc->n_filters=n_filters;
+ mfcc->n_coefs=n_coefs;
+ mfcc->lowfreq=lowfreq;
+ mfcc->highfreq=highfreq;
+
+ /** filterbank allocation */
+ mfcc->fb = new_aubio_filterbank_mfcc(n_filters, mfcc->win_s, samplerate, lowfreq, highfreq);
+
+ /** allocating space for fft object (used for dct) */
+ mfcc->fft_dct=new_aubio_mfft(n_filters, 1);
+
+ /** allocating buffers */
+ mfcc->in_dct=new_fvec(mfcc->win_s, 1);
+
+ mfcc->fftgrain_dct=new_cvec(n_filters, 1);
+
+ return mfcc;
+ };
+
+ void del_aubio_mfcc(aubio_mfcc_t *mf){
+ /** deleting filterbank */
+ del_aubio_filterbank(mf->fb);
+ /** deleting mfft object */
+ del_aubio_mfft(mf->fft_dct);
+ /** deleting buffers */
+ del_fvec(mf->in_dct);
+ del_cvec(mf->fftgrain_dct);
+
+ /** deleting mfcc object */
+ AUBIO_FREE(mf);
+ }
+
+ void aubio_mfcc_do(aubio_mfcc_t * mf, cvec_t *in, fvec_t *out){
+ // compute filterbank
+ aubio_filterbank_do(mf->fb, in, mf->in_dct);
+ //TODO: check that zero padding
+ // the following line seems useless since the in_dct buffer has the correct size
+ //for(n = filter + 1; n < N; n++) result[n] = 0;
+
+ aubio_dct_do(mf, mf->in_dct, out);
+
+ return;
+ }
+
+ void aubio_dct_do(aubio_mfcc_t * mf, fvec_t *in, fvec_t *out){
+ uint_t i;
+ //compute mag spectrum
+ aubio_mfft_do (mf->fft_dct, in, mf->fftgrain_dct);
+ //extract real part of fft grain
+ for(i=0; i<mf->n_coefs ;i++){
+ //for(i=0; i<out->length;i++){
+ out->data[0][i]= mf->fftgrain_dct->norm[0][i]
+ *COS(mf->fftgrain_dct->phas[0][i]);
+ }
+ return;
+ }
+
++//a bit a kludge
++void dump_filterbank(aubio_mfcc_t * mf){
++ aubio_dump_filterbank(mf->fb);
++
++}
++
--- /dev/null
+ /*
+ Copyright (C) 2007 Amaury Hazan <ahazan@iua.upf.edu>
+ and Paul Brossier <piem@piem.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ */
+
+ /* part of this mfcc implementation were inspired from LibXtract
+ http://libxtract.sourceforge.net/
+ */
+
+ #ifndef MFCC_H
+ #define MFCC_H
+
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+
+ #include "sample.h"
+ #include "filterbank.h"
+
+ typedef struct aubio_mfcc_t_ aubio_mfcc_t;
+
+ /** create mfcc object
+
+ \param win_s size of analysis buffer (and length the FFT transform)
+ \param samplerate
+ \param n_coefs: number of desired coefs
+ \param lowfreq: lowest frequency to use in filterbank
+ \param highfreq highest frequency to use in filterbank
+ \param channels number of channels
+
+ */
+ aubio_mfcc_t * new_aubio_mfcc (uint_t win_s, uint_t samplerate, uint_t n_filters, uint_t n_coefs, smpl_t lowfreq, smpl_t highfreq, uint_t channels);
+ /** delete mfcc object
+
+ \param mf mfcc object as returned by new_aubio_mfcc
+
+ */
+ void del_aubio_mfcc(aubio_mfcc_t *mf);
+ /** mfcc object processing
+
+ \param mf mfcc object as returned by new_aubio_mfcc
+ \param in input spectrum (win_s long)
+ \param out output mel coefficients buffer (n_filters/2 +1 long)
+
+ */
+ void aubio_mfcc_do(aubio_mfcc_t * mf, cvec_t *in, fvec_t *out);
+
+ /** intermediate dct involved in aubio_mfcc_do
+
+ \param mf mfcc object as returned by new_aubio_mfcc
+ \param in input spectrum (n_filters long)
+ \param out output mel coefficients buffer (n_filters/2 +1 long)
+
+ */
+ void aubio_dct_do(aubio_mfcc_t * mf, fvec_t *in, fvec_t *out);
+
++/** dump filterbank to log file
++
++ \param mf mfcc object as returned by new_aubio_mfcc
++
++*/
++void dump_filterbank(aubio_mfcc_t * mf);
++
+ #ifdef __cplusplus
+ }
+ #endif
+
+ #endif // MFCC_H