Index: examples/aubiomfcc.c
===================================================================
--- examples/aubiomfcc.c	(revision 71b1b4befa9ad78856e7cd0b5d52e4b97064a74b)
+++ examples/aubiomfcc.c	(revision 7c6c806dda27c76b03afac7bfeecdaa88371a0ed)
@@ -27,8 +27,4 @@
   unsigned int j;       /*frames*/
   
-  // declare the mel filter bank
-  // TODO: should be done only once
-  aubio_mfcc_init(int N, NYQUIST, int style, float freq_min, float freq_max, int freq_bands, float **fft_tables);
-
   for (j=0;j<(unsigned)nframes;j++) {
     if(usejack) {
@@ -47,16 +43,16 @@
       aubio_pvoc_do (pv,ibuf, fftgrain);
      
+      uint_t n_coefs= n_filters/2 +1;
       uint_t coef_cnt;
-      uint_t n_filters=20;
-      smpl_t outbuf[20];
+       
 
-      for (coef_cnt=0; coef_cnt<n_filters ; coef_cnt++)
-        outbuf[coef_cnt]=0.f;
+      for (coef_cnt=0; coef_cnt<n_coefs ; coef_cnt++)
+        mfcc_outbuf[coef_cnt]=0.f;
        
       //compute mfccs
-      aubio_mffc_do(fftgrain->norm, nframes, mf, outbuf);
+      aubio_mffc_do(fftgrain->norm, nframes, mf, mfcc_outbuf, fft_dct, fftgrain_dct);
       
-      for (coef_cnt=0; coef_cnt<n_filters ; coef_cnt++)
-        outmsg("%f ",outbuf[coef_cnt]);
+      for (coef_cnt=0; coef_cnt<n_coefs ; coef_cnt++)
+        outmsg("%f ",mfcc_outbuf[coef_cnt]);
       outmsg("\n");
       
@@ -90,11 +86,9 @@
   
   //allocate and initialize mel filter bank
-  uint_t n_filters=20;
-  uint_t nyquist= samplerate / 2.; 
-  smpl_t lowfreq=80.f;
-  smpl_t highfreq=18000.f;
+  
 
+  //allocating global mf (in utils.c)
   uint_t banksize = (uint) ( sizeof(aubio_mel_filter));
-  aubio_mel_filter * mf = (aubio_mel_filter *)getbytes(banksize);
+  mf = (aubio_mel_filter *)getbytes(banksize);
 
   mf->n_filters = 20;
Index: examples/utils.c
===================================================================
--- examples/utils.c	(revision 71b1b4befa9ad78856e7cd0b5d52e4b97064a74b)
+++ examples/utils.c	(revision 7c6c806dda27c76b03afac7bfeecdaa88371a0ed)
@@ -60,4 +60,18 @@
 int isonset = 0;
 aubio_pickpeak_t * parms;
+
+/* mfcc objects */
+//parameters
+uint_t n_filters=20;
+uint_t nyquist= samplerate / 2.; 
+smpl_t lowfreq=80.f;
+smpl_t highfreq=18000.f;
+// filterbank object
+aubio_mel_filter * mf;
+
+// DCT mfft and result storage
+aubio_mfft * fft_dct;
+cvec_t * fftgrain_dct;
+smpl_t mfcc_outbuf[11];
 
 
@@ -301,4 +315,7 @@
   fftgrain  = new_cvec(buffer_size, channels);
 
+  //init for mfcc process
+  fftgrain_dct= new_cvec(n_filters, channels);
+
   if (usepitch) {
     pitchdet = new_aubio_pitchdetection(buffer_size*4, 
@@ -313,4 +330,9 @@
   /* phase vocoder */
   pv = new_aubio_pvoc(buffer_size, overlap_size, channels);
+  
+  // dct phase vocoder
+  //TODO: check size
+  fft_dct = new_aubio_mfft(n_filters, channels);
+
   /* onsets */
   parms = new_aubio_peakpicker(threshold);
@@ -346,4 +368,9 @@
   del_fvec(onset);
   del_fvec(woodblock);
+  
+  //mffc related
+  del_aubio_mfft(fft_dct);
+  del_cvec(fftgrain_dct);
+  
   aubio_cleanup();
 }
Index: examples/utils.h
===================================================================
--- examples/utils.h	(revision 71b1b4befa9ad78856e7cd0b5d52e4b97064a74b)
+++ examples/utils.h	(revision 7c6c806dda27c76b03afac7bfeecdaa88371a0ed)
@@ -98,4 +98,16 @@
 extern aubio_pickpeak_t * parms;
 
+/* mfcc objects */
+// params
+extern uint_t n_filters;
+extern uint_t nyquist; 
+extern smpl_t lowfreq;
+extern smpl_t highfreq;
+// filterbank object
+extern aubio_mel_filter * mf;
+// DCT pvoc and result storage
+extern aubio_mfft_t * fft_dct;
+extern cvec_t * fftgrain_dct;
+extern smpl_t mfcc_outbuf[20];
 
 /* pitch objects */
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 71b1b4befa9ad78856e7cd0b5d52e4b97064a74b)
+++ src/Makefile.am	(revision 7c6c806dda27c76b03afac7bfeecdaa88371a0ed)
@@ -22,5 +22,6 @@
 	onset.h \
 	tempo.h \
-	filter.h 
+	filter.h \
+	mfcc.h
 
 nodist_pkginclude_HEADERS = config.h
@@ -71,4 +72,6 @@
 	filter.c \
 	filter.h \
+	mfcc.h \
+	mfcc.c 
 
 AM_CFLAGS = @AUBIO_CFLAGS@ @FFTWLIB_CFLAGS@ @SAMPLERATE_CFLAGS@
Index: src/filterbank.c
===================================================================
--- src/filterbank.c	(revision 71b1b4befa9ad78856e7cd0b5d52e4b97064a74b)
+++ src/filterbank.c	(revision 7c6c806dda27c76b03afac7bfeecdaa88371a0ed)
@@ -21,5 +21,15 @@
 */
 
+#include "aubio_priv.h"
 #include "filterbank.h"
+
+
+// Struct Declaration
+
+/** \brief A structure to store a set of n_filters Mel filters */
+typedef struct aubio_mel_filter_ {
+    int n_filters;
+    smpl_t **filters;
+};
 
 // Initialization
Index: src/filterbank.h
===================================================================
--- src/filterbank.h	(revision 71b1b4befa9ad78856e7cd0b5d52e4b97064a74b)
+++ src/filterbank.h	(revision 7c6c806dda27c76b03afac7bfeecdaa88371a0ed)
@@ -23,12 +23,11 @@
 #define AUBIOFILTERBANK_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
-// Struct Declaration
 
-/** \brief A structure to store a set of n_filters Mel filters */
-typedef struct aubio_mel_filter_ {
-    int n_filters;
-    smpl_t **filters;
-} aubio_mel_filter;
+
+typedef struct aubio_mel_filter_ aubio_mel_filter;
 
 // Initialization
@@ -38,5 +37,9 @@
  * It is up to the caller to pass in a pointer to memory allocated for freq_bands arrays of length N. This function populates these arrays with magnitude coefficients representing the mel filterbank on a linear scale 
  */
-int aubio_mfcc_init(int N, float nyquist, int style, float freq_min, float freq_max, int freq_bands, smpl_t ** fft_tables);
+int aubio_mfcc_init(int N, smpl_t nyquist, int style, smpl_t freq_min, smpl_t freq_max, int freq_bands, smpl_t ** fft_tables);
+
+#ifdef __cplusplus
+}
+#endif
 
 #endif
Index: src/mfcc.c
===================================================================
--- src/mfcc.c	(revision 71b1b4befa9ad78856e7cd0b5d52e4b97064a74b)
+++ src/mfcc.c	(revision 7c6c806dda27c76b03afac7bfeecdaa88371a0ed)
@@ -21,10 +21,22 @@
 */
 
+#include "aubio_priv.h"
+#include "sample.h"
+#include "fft.h"
+#include "mfcc.h"
+#include "math.h"
 
-#include "mffc.h"
+/*
+new_aubio_mfcc
+aubio_mfcc_do
+del_aubio_mfcc
+*/
 
 // Computation
+// Added last two arguments to be able to pass from example
 
-int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result){
+
+
+int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t * fft_dct, cvec_t * fftgrain_dct){
 
     aubio_mel_filter *f;
@@ -38,16 +50,18 @@
             result[filter] += data[n] * f->filters[filter][n];
         }
-        result[filter] = log(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]);
+        result[filter] = LOG(result[filter] < XTRACT_LOG_LIMIT ? XTRACT_LOG_LIMIT : result[filter]);
     }
 
-    //TODO: check that zero padding
+    //TODO: check that zero padding 
     for(n = filter + 1; n < N; n++) result[n] = 0; 
     
-    aubio_dct_do(result, f->n_filters, NULL, result);
+    aubio_dct_do(result, f->n_filters, NULL, result, fft_dct, fftgrain_dct);
     
     return XTRACT_SUCCESS;
 }
 
-int aubio_dct_do(const float *data, const int N, const void *argv, float *result){
+// Added last two arguments to be able to pass from example
+
+int aubio_dct_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t * fft_dct, cvec_t * fftgrain_dct){
     
     
@@ -56,21 +70,16 @@
     //TODO: fvec as input? Remove data length, N?
 
+    fvec_t * momo = new_fvec(20, 1);
+    momo->data = data;
+    
     //compute mag spectrum
-    aubio_pvoc_do (pv,data, fftgrain);
+    aubio_mfft_do (fft_dct, data, fftgrain_dct);
 
     int i;
     //extract real part of fft grain
     for(i=0; i<N ;i++){
-      result[i]= fftgrain->norm[i]*cos(fftgrain->phase[i]);
+      result[i]= fftgrain_dct->norm[0][i]*COS(fftgrain_dct->phas[0][i]);
     }
-    
-    /*
-    fftwf_plan plan;
-    
-    plan = 
-        fftwf_plan_r2r_1d(N, (float *) data, result, FFTW_REDFT00, FFTW_ESTIMATE);
-    
-    fftwf_execute(plan);
-    fftwf_destroy_plan(plan);*/
+
 
     return XTRACT_SUCCESS;
Index: src/mfcc.h
===================================================================
--- src/mfcc.h	(revision 71b1b4befa9ad78856e7cd0b5d52e4b97064a74b)
+++ src/mfcc.h	(revision 7c6c806dda27c76b03afac7bfeecdaa88371a0ed)
@@ -24,8 +24,37 @@
 #define MFCC_H 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include "filterbank.h"
 
-//libXtract enums
+//libXtract constants and enums
 // TODO: remove them 
+
+#define XTRACT_SQ(a) ((a) * (a))
+#define XTRACT_MIN(a, b) ((a) < (b) ? (a) : (b))
+#define XTRACT_MAX(a, b) ((a) > (b) ? (a) : (b))
+#define XTRACT_NEEDS_FFTW printf("LibXtract must be compiled with fftw support to use this function.\n")
+#define XTRACT_VERY_SMALL_NUMBER 2e-42
+#define XTRACT_LOG_LIMIT XTRACT_VERY_SMALL_NUMBER
+#define XTRACT_LOG_LIMIT_DB -96.0
+#define XTRACT_DB_SCALE_OFFSET 96.0
+#define XTRACT_VERY_BIG_NUMBER 2e42
+#define XTRACT_SR_UPPER_LIMIT 192000.0
+#define XTRACT_SR_LOWER_LIMIT 22050.0
+#define XTRACT_SR_DEFAULT 44100.0
+#define XTRACT_FUNDAMENTAL_DEFAULT 440.0
+#define XTRACT_CHECK_nyquist if(!nyquist) nyquist = XTRACT_SR_DEFAULT / 2
+#define XTRACT_CHECK_q if(!q) q = XTRACT_SR_DEFAULT / N
+#define XTRACT_IS_ODD(x) (x % 2 != 0 ? 1 : 0) 
+#define XTRACT_SR_LIMIT SR_UPPER_LIMIT
+#define XTRACT_FFT_BANDS_MIN 16
+#define XTRACT_FFT_BANDS_MAX 65536
+#define XTRACT_FFT_BANDS_DEF 1024
+#define XTRACT_SPEC_BW_MIN 0.168 /* Minimum spectral bandwidth \
+            (= SR_LOWER_LIMIT / FFT_BANDS_MAX*/ 
+#define XTRACT_SPEC_BW_MAX 12000.0 /* SR_UPPER_LIMIT / FFT_BANDS_MIN */
+#define XTRACT_SPEC_BW_DEF 43.066 /* SR_DEFAULT / FFT_BANDS_DEF */
 
 /** \brief Enumeration of feature initialisation functions */
@@ -132,5 +161,7 @@
  * The data structure pointed to by *argv must be obtained by first calling xtract_init_mfcc
  */
-int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result);
+
+
+int aubio_mfcc_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t *fft_dct, cvec_t *fftgrain_dct);
 
 /** \brief Extract the Discrete Cosine transform of a time domain signal
@@ -140,6 +171,9 @@
  * \param *result: a pointer to an array containing resultant dct coefficients
  */
-int aubio_dct_do(const float *data, const int N, const void *argv, float *result);
+int aubio_dct_do(const float *data, const int N, const void *argv, float *result, aubio_mfft_t *fft_dct, cvec_t *fftgrain_dct);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif
