Index: src/spectral/mfcc.c
===================================================================
--- src/spectral/mfcc.c	(revision e680926d170422fdcd1ee7266238c57a49a6c58b)
+++ src/spectral/mfcc.c	(revision db3eb5c0b4af15b5ce9c9875c76fd6603775abf6)
@@ -32,8 +32,4 @@
 #include "spectral/mfcc.h"
 
-#ifdef HAVE_NOOPT
-#define HAVE_SLOW_DCT 1
-#endif
-
 /** Internal structure for mfcc object */
 
@@ -46,10 +42,6 @@
   aubio_filterbank_t *fb;   /** filter bank */
   fvec_t *in_dct;           /** input buffer for dct * [fb->n_filters] */
-#if defined(HAVE_SLOW_DCT)
-  fmat_t *dct_coeffs;       /** DCT transform n_filters * n_coeffs */
-#else
-  aubio_dct_t *dct;
-  fvec_t *output;
-#endif
+  aubio_dct_t *dct;         /** dct object */
+  fvec_t *output;           /** dct output */
   smpl_t scale;
 };
@@ -63,9 +55,13 @@
   /* allocate space for mfcc object */
   aubio_mfcc_t *mfcc = AUBIO_NEW (aubio_mfcc_t);
-#if defined(HAVE_SLOW_DCT)
-  smpl_t scaling;
 
-  uint_t i, j;
-#endif
+  if ((sint_t)n_coefs <= 0) {
+    AUBIO_ERR("mfcc: n_coefs should be > 0, got %d\n", n_coefs);
+    goto failure;
+  }
+  if ((sint_t)samplerate <= 0) {
+    AUBIO_ERR("mfcc: samplerate should be > 0, got %d\n", samplerate);
+    goto failure;
+  }
 
   mfcc->win_s = win_s;
@@ -76,4 +72,8 @@
   /* filterbank allocation */
   mfcc->fb = new_aubio_filterbank (n_filters, mfcc->win_s);
+
+  if (!mfcc->fb)
+    goto failure;
+
   if (n_filters == 40)
     aubio_filterbank_set_mel_coeffs_slaney (mfcc->fb, samplerate);
@@ -85,25 +85,17 @@
   mfcc->in_dct = new_fvec (n_filters);
 
-#if defined(HAVE_SLOW_DCT)
-  mfcc->dct_coeffs = new_fmat (n_coefs, n_filters);
-
-  /* compute DCT transform dct_coeffs[j][i] as
-     cos ( j * (i+.5) * PI / n_filters ) */
-  scaling = 1. / SQRT (n_filters / 2.);
-  for (i = 0; i < n_filters; i++) {
-    for (j = 0; j < n_coefs; j++) {
-      mfcc->dct_coeffs->data[j][i] =
-          scaling * COS (j * (i + 0.5) * PI / n_filters);
-    }
-    mfcc->dct_coeffs->data[0][i] *= SQRT (2.) / 2.;
-  }
-#else
   mfcc->dct = new_aubio_dct (n_filters);
   mfcc->output = new_fvec (n_filters);
-#endif
+
+  if (!mfcc->in_dct || !mfcc->dct || !mfcc->output)
+    goto failure;
 
   mfcc->scale = 1.;
 
   return mfcc;
+
+failure:
+  del_aubio_mfcc(mfcc);
+  return NULL;
 }
 
@@ -111,18 +103,12 @@
 del_aubio_mfcc (aubio_mfcc_t * mf)
 {
-
-  /* delete filterbank */
-  del_aubio_filterbank (mf->fb);
-
-  /* delete buffers */
-  del_fvec (mf->in_dct);
-#if defined(HAVE_SLOW_DCT)
-  del_fmat (mf->dct_coeffs);
-#else
-  del_aubio_dct (mf->dct);
-  del_fvec (mf->output);
-#endif
-
-  /* delete mfcc object */
+  if (mf->fb)
+    del_aubio_filterbank (mf->fb);
+  if (mf->in_dct)
+    del_fvec (mf->in_dct);
+  if (mf->dct)
+    del_aubio_dct (mf->dct);
+  if (mf->output)
+    del_fvec (mf->output);
   AUBIO_FREE (mf);
 }
@@ -132,7 +118,5 @@
 aubio_mfcc_do (aubio_mfcc_t * mf, const cvec_t * in, fvec_t * out)
 {
-#ifndef HAVE_SLOW_DCT
   fvec_t tmp;
-#endif
 
   /* compute filterbank */
@@ -145,7 +129,4 @@
 
   /* compute mfccs */
-#if defined(HAVE_SLOW_DCT)
-  fmat_vecmul(mf->dct_coeffs, mf->in_dct, out);
-#else
   aubio_dct_do(mf->dct, mf->in_dct, mf->output);
   // copy only first n_coeffs elements
@@ -154,5 +135,4 @@
   tmp.length = out->length;
   fvec_copy(&tmp, out);
-#endif
 
   return;
Index: tests/src/spectral/test-mfcc.c
===================================================================
--- tests/src/spectral/test-mfcc.c	(revision e680926d170422fdcd1ee7266238c57a49a6c58b)
+++ tests/src/spectral/test-mfcc.c	(revision db3eb5c0b4af15b5ce9c9875c76fd6603775abf6)
@@ -5,11 +5,16 @@
   uint_t win_s = 512; // fft size
   uint_t n_filters = 40; // number of filters
-  uint_t n_coefs = 13; // number of coefficients
+  uint_t n_coeffs = 13; // number of coefficients
   smpl_t samplerate = 16000.; // samplerate
   cvec_t *in = new_cvec (win_s); // input buffer
-  fvec_t *out = new_fvec (n_coefs); // output coefficients
+  fvec_t *out = new_fvec (n_coeffs); // output coefficients
+
+  if (new_aubio_mfcc(    0, n_filters, n_coeffs, samplerate)) return 1;
+  if (new_aubio_mfcc(win_s,         0, n_coeffs, samplerate)) return 1;
+  if (new_aubio_mfcc(win_s, n_filters,        0, samplerate)) return 1;
+  if (new_aubio_mfcc(win_s, n_filters, n_coeffs,          0)) return 1;
 
   // create mfcc object
-  aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coefs, samplerate);
+  aubio_mfcc_t *o = new_aubio_mfcc (win_s, n_filters, n_coeffs, samplerate);
 
   cvec_norm_set_all (in, 1.);
