Index: src/spectral/fft.c
===================================================================
--- src/spectral/fft.c	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
+++ src/spectral/fft.c	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
@@ -0,0 +1,194 @@
+/*
+   Copyright (C) 2003 Paul Brossier
+
+   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 "fvec.h"
+#include "cvec.h"
+#include "mathutils.h"
+#include "spectral/fft.h"
+
+#if FFTW3F_SUPPORT
+#define fftw_malloc            fftwf_malloc
+#define fftw_free              fftwf_free
+#define fftw_execute           fftwf_execute
+#define fftw_plan_dft_r2c_1d   fftwf_plan_dft_r2c_1d
+#define fftw_plan_dft_c2r_1d   fftwf_plan_dft_c2r_1d
+#define fftw_plan_r2r_1d       fftwf_plan_r2r_1d
+#define fftw_plan              fftwf_plan
+#define fftw_destroy_plan      fftwf_destroy_plan
+#endif
+
+#if FFTW3F_SUPPORT
+#define real_t smpl_t
+#else
+#define real_t lsmp_t
+#endif
+
+struct _aubio_fft_t {
+  uint_t winsize;
+  uint_t channels;
+  uint_t fft_size;
+  real_t *in, *out;
+  fftw_plan pfw, pbw;
+  fft_data_t * specdata;     /* complex spectral data */
+  fvec_t * compspec;
+};
+
+aubio_fft_t * new_aubio_fft(uint_t winsize, uint_t channels) {
+  aubio_fft_t * s = AUBIO_NEW(aubio_fft_t);
+  s->winsize  = winsize;
+  s->channels = channels;
+  /* allocate memory */
+  s->in       = AUBIO_ARRAY(real_t,winsize);
+  s->out      = AUBIO_ARRAY(real_t,winsize);
+  s->compspec = new_fvec(winsize,channels);
+  /* create plans */
+#ifdef HAVE_COMPLEX_H
+  s->fft_size = winsize/2 + 1;
+  s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s->fft_size);
+  s->pfw = fftw_plan_dft_r2c_1d(winsize, s->in,  s->specdata, FFTW_ESTIMATE);
+  s->pbw = fftw_plan_dft_c2r_1d(winsize, s->specdata, s->out, FFTW_ESTIMATE);
+#else
+  s->fft_size = winsize;
+  s->specdata = (fft_data_t*)fftw_malloc(sizeof(fft_data_t)*s->fft_size);
+  s->pfw = fftw_plan_r2r_1d(winsize, s->in,  s->specdata, FFTW_R2HC, FFTW_ESTIMATE);
+  s->pbw = fftw_plan_r2r_1d(winsize, s->specdata, s->out, FFTW_HC2R, FFTW_ESTIMATE);
+#endif
+  return s;
+}
+
+void del_aubio_fft(aubio_fft_t * s) {
+  /* destroy data */
+  del_fvec(s->compspec);
+  fftw_destroy_plan(s->pfw);
+  fftw_destroy_plan(s->pbw);
+  fftw_free(s->specdata);
+  AUBIO_FREE(s->out);
+  AUBIO_FREE(s->in );
+  AUBIO_FREE(s);
+}
+
+void aubio_fft_do(aubio_fft_t * s, fvec_t * input, cvec_t * spectrum) {
+  aubio_fft_do_complex(s, input, s->compspec);
+  aubio_fft_get_spectrum(s->compspec, spectrum);
+}
+
+void aubio_fft_rdo(aubio_fft_t * s, cvec_t * spectrum, fvec_t * output) {
+  aubio_fft_get_realimag(spectrum, s->compspec);
+  aubio_fft_rdo_complex(s, s->compspec, output);
+}
+
+void aubio_fft_do_complex(aubio_fft_t * s, fvec_t * input, fvec_t * compspec) {
+  uint_t i, j;
+  for (i = 0; i < s->channels; i++) {
+    for (j=0; j < s->winsize; j++) {
+      s->in[j] = input->data[i][j];
+    }
+    fftw_execute(s->pfw);
+#ifdef HAVE_COMPLEX_H
+    compspec->data[i][0] = REAL(s->specdata[0]);
+    for (j = 1; j < s->fft_size -1 ; j++) {
+      compspec->data[i][j] = REAL(s->specdata[j]);
+      compspec->data[i][compspec->length - j] = IMAG(s->specdata[j]);
+    }
+    compspec->data[i][s->fft_size-1] = REAL(s->specdata[s->fft_size-1]);
+#else
+    for (j = 0; j < s->fft_size; j++) {
+      compspec->data[i][j] = s->specdata[j];
+    }
+#endif
+  }
+}
+
+void aubio_fft_rdo_complex(aubio_fft_t * s, fvec_t * compspec, fvec_t * output) {
+  uint_t i, j;
+  const smpl_t renorm = 1./(smpl_t)s->winsize;
+  for (i = 0; i < compspec->channels; i++) {
+#ifdef HAVE_COMPLEX_H
+    s->specdata[0] = compspec->data[i][0];
+    for (j=1; j < s->fft_size - 1; j++) {
+      s->specdata[j] = compspec->data[i][j] + 
+        I * compspec->data[i][compspec->length - j];
+    }
+    s->specdata[s->fft_size - 1] = compspec->data[i][s->fft_size - 1];
+#else
+    for (j=0; j < s->fft_size; j++) {
+      s->specdata[j] = compspec->data[i][j];
+    }
+#endif
+    fftw_execute(s->pbw);
+    for (j = 0; j < output->length; j++) {
+      output->data[i][j] = s->out[j]*renorm;
+    }
+  }
+}
+
+void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum) {
+  aubio_fft_get_phas(compspec, spectrum);
+  aubio_fft_get_norm(compspec, spectrum);
+}
+
+void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec) {
+  aubio_fft_get_imag(spectrum, compspec);
+  aubio_fft_get_real(spectrum, compspec);
+}
+
+void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum) {
+  uint_t i, j;
+  for (i = 0; i < spectrum->channels; i++) {
+    spectrum->phas[i][0] = 0.;
+    for (j=1; j < spectrum->length - 1; j++) {
+      spectrum->phas[i][j] = atan2f(compspec->data[i][compspec->length-j],
+          compspec->data[i][j]);
+    }
+    spectrum->phas[i][spectrum->length-1] = 0.;
+  }
+}
+
+void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum) {
+  uint_t i, j = 0;
+  for (i = 0; i < spectrum->channels; i++) {
+    spectrum->norm[i][0] = compspec->data[i][0];
+    for (j=1; j < spectrum->length - 1; j++) {
+      spectrum->norm[i][j] = SQRT(SQR(compspec->data[i][j]) 
+          + SQR(compspec->data[i][compspec->length - j]) );
+    }
+    spectrum->norm[i][spectrum->length-1] = compspec->data[i][compspec->length/2];
+  }
+}
+
+void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec) {
+  uint_t i, j;
+  for (i = 0; i < compspec->channels; i++) {
+    for (j = 1; j < compspec->length / 2 + 1; j++) {
+      compspec->data[i][compspec->length - j] =
+        spectrum->norm[i][j]*SIN(spectrum->phas[i][j]);
+    }
+  }
+}
+
+void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec) {
+  uint_t i, j;
+  for (i = 0; i < compspec->channels; i++) {
+    for (j = 0; j< compspec->length / 2 + 1; j++) {
+      compspec->data[i][j] = 
+        spectrum->norm[i][j]*COS(spectrum->phas[i][j]);
+    }
+  }
+}
Index: src/spectral/fft.h
===================================================================
--- src/spectral/fft.h	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
+++ src/spectral/fft.h	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
@@ -0,0 +1,163 @@
+/*
+   Copyright (C) 2003 Paul Brossier
+
+   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 
+
+  Fast Fourier Transform object
+
+*/
+
+#ifndef FFT_H_
+#define FFT_H_
+
+/* note that <complex.h> is not included here but only in aubio_priv.h, so that
+ * c++ projects can still use their own complex definition. */
+#include <fftw3.h>
+
+#ifdef HAVE_COMPLEX_H
+#if FFTW3F_SUPPORT
+#define FFTW_TYPE fftwf_complex
+#else
+#define FFTW_TYPE fftw_complex
+#endif
+#else
+#if FFTW3F_SUPPORT
+/** fft data type */
+#define FFTW_TYPE float
+#else
+/** fft data type */
+#define FFTW_TYPE double
+#endif
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** fft data type */
+typedef FFTW_TYPE fft_data_t;
+
+/** FFT object
+ 
+  This object computes forward and backward FFTs, using the complex type to
+  store the results. The phase vocoder or aubio_mfft_t objects should be
+  preferred to using directly aubio_fft_t. The FFT are computed using FFTW3
+  (although support for another library could be added).
+
+*/
+typedef struct _aubio_fft_t aubio_fft_t;
+
+/** create new FFT computation object
+
+  \param size length of the FFT
+  \param channels number of channels
+
+*/
+aubio_fft_t * new_aubio_fft(uint_t size, uint_t channels);
+/** delete FFT object 
+
+  \param s fft object as returned by new_aubio_fft
+
+*/
+void del_aubio_fft(aubio_fft_t * s);
+
+/** compute forward FFT
+
+  \param s fft object as returned by new_aubio_fft
+  \param input input signal 
+  \param spectrum output spectrum 
+
+*/
+void aubio_fft_do (aubio_fft_t *s, fvec_t * input, cvec_t * spectrum);
+/** compute backward (inverse) FFT
+
+  \param s fft object as returned by new_aubio_fft
+  \param spectrum input spectrum 
+  \param output output signal 
+
+*/
+void aubio_fft_rdo (aubio_fft_t *s, cvec_t * spectrum, fvec_t * output);
+
+/** compute forward FFT
+
+  \param s fft object as returned by new_aubio_fft
+  \param input real input signal 
+  \param compspec complex output fft real/imag
+
+*/
+void aubio_fft_do_complex (aubio_fft_t *s, fvec_t * input, fvec_t * compspec);
+/** compute backward (inverse) FFT from real/imag
+
+  \param s fft object as returned by new_aubio_fft
+  \param compspec real/imag input fft array 
+  \param output real output array 
+
+*/
+void aubio_fft_rdo_complex (aubio_fft_t *s, fvec_t * compspec, fvec_t * output);
+
+/** convert real/imag spectrum to norm/phas spectrum 
+
+  \param compspec real/imag input fft array 
+  \param spectrum cvec norm/phas output array 
+
+*/
+void aubio_fft_get_spectrum(fvec_t * compspec, cvec_t * spectrum);
+/** convert real/imag spectrum to norm/phas spectrum 
+
+  \param compspec real/imag input fft array 
+  \param spectrum cvec norm/phas output array 
+
+*/
+void aubio_fft_get_realimag(cvec_t * spectrum, fvec_t * compspec);
+
+/** compute phas spectrum from real/imag parts 
+
+  \param compspec real/imag input fft array 
+  \param spectrum cvec norm/phas output array 
+
+*/
+void aubio_fft_get_phas(fvec_t * compspec, cvec_t * spectrum);
+/** compute imaginary part from the norm/phas cvec 
+
+  \param spectrum norm/phas input array 
+  \param compspec real/imag output fft array 
+
+*/
+void aubio_fft_get_imag(cvec_t * spectrum, fvec_t * compspec);
+
+/** compute norm component from real/imag parts 
+
+  \param compspec real/imag input fft array 
+  \param spectrum cvec norm/phas output array 
+
+*/
+void aubio_fft_get_norm(fvec_t * compspec, cvec_t * spectrum);
+/** compute real part from norm/phas components 
+
+  \param spectrum norm/phas input array 
+  \param compspec real/imag output fft array 
+
+*/
+void aubio_fft_get_real(cvec_t * spectrum, fvec_t * compspec);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // FFT_H_
Index: src/spectral/filterbank.c
===================================================================
--- src/spectral/filterbank.c	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
+++ src/spectral/filterbank.c	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
@@ -0,0 +1,218 @@
+/*
+   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 "aubio_priv.h"
+#include "sample.h"
+#include "spectral/filterbank.h"
+#include "mathutils.h"
+
+#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;
+}
+
+/*
+FB initialization based on Slaney's auditory toolbox
+TODO:
+  *solve memory leak problems while
+  *solve quantization issues when constructing signal:
+    *bug for win_s=512
+    *corrections for win_s=1024 -> why even filters with smaller amplitude
+
+*/
+
+aubio_filterbank_t * new_aubio_filterbank_mfcc(uint_t n_filters, uint_t win_s, uint_t samplerate, smpl_t freq_min, smpl_t freq_max){
+  
+  aubio_filterbank_t * fb = new_aubio_filterbank(n_filters, win_s);
+  
+  
+  //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=new_fvec(win_s, 1);
+
+  uint_t filter_cnt, bin_cnt;
+  
+  //first step: filling all the linear filter frequencies
+  for(filter_cnt=0; filter_cnt<linearFilters; filter_cnt++){
+    freqs->data[0][filter_cnt]=lowestFrequency+ filter_cnt*linearSpacing;
+  }
+  smpl_t lastlinearCF=freqs->data[0][filter_cnt-1];
+  
+  //second step: filling all the log filter frequencies
+  for(filter_cnt=0; filter_cnt<logFilters+2; filter_cnt++){
+    freqs->data[0][filter_cnt+linearFilters] = 
+      lastlinearCF*(pow(logSpacing,filter_cnt+1));
+  }
+
+  //Option 1. copying interesting values to lower_freqs, center_freqs and upper freqs arrays
+  //TODO: would be nicer to have a reference to freqs->data, anyway we do not care in this init step
+    
+  for(filter_cnt=0; filter_cnt<allFilters; filter_cnt++){
+    lower_freqs->data[0][filter_cnt]=freqs->data[0][filter_cnt];
+    center_freqs->data[0][filter_cnt]=freqs->data[0][filter_cnt+1];
+    upper_freqs->data[0][filter_cnt]=freqs->data[0][filter_cnt+2];
+  }
+
+  //computing triangle heights so that each triangle has unit area
+  for(filter_cnt=0; filter_cnt<allFilters; filter_cnt++){
+    triangle_heights->data[0][filter_cnt] = 2./(upper_freqs->data[0][filter_cnt] 
+      - lower_freqs->data[0][filter_cnt]);
+  }
+  
+  //AUBIO_DBG("filter tables frequencies\n");
+  //for(filter_cnt=0; filter_cnt<allFilters; filter_cnt++)
+  //  AUBIO_DBG("filter n. %d %f %f %f %f\n",
+  //    filter_cnt, lower_freqs->data[0][filter_cnt], 
+  //    center_freqs->data[0][filter_cnt], upper_freqs->data[0][filter_cnt], 
+  //    triangle_heights->data[0][filter_cnt]);
+
+  //filling the fft_freqs lookup table, which assigns the frequency in hz to each bin
+  for(bin_cnt=0; bin_cnt<win_s; bin_cnt++){
+    fft_freqs->data[0][bin_cnt]= aubio_bintofreq(bin_cnt, samplerate, win_s);
+  }
+
+  //building each filter table
+  for(filter_cnt=0; filter_cnt<allFilters; filter_cnt++){
+
+    //TODO:check special case : lower freq =0
+    //calculating rise increment in mag/Hz
+    smpl_t riseInc= triangle_heights->data[0][filter_cnt]/(center_freqs->data[0][filter_cnt]-lower_freqs->data[0][filter_cnt]);
+    
+    //zeroing begining of filter
+    for(bin_cnt=0; bin_cnt<win_s-1; bin_cnt++){
+      fb->filters[filter_cnt]->data[0][bin_cnt]=0.f;
+      if( fft_freqs->data[0][bin_cnt]  <= lower_freqs->data[0][filter_cnt] &&
+          fft_freqs->data[0][bin_cnt+1] > lower_freqs->data[0][filter_cnt]) {
+        break;
+      }
+    }
+    bin_cnt++;
+    
+    //positive slope
+    for(; bin_cnt<win_s-1; bin_cnt++){
+      fb->filters[filter_cnt]->data[0][bin_cnt]=(fft_freqs->data[0][bin_cnt]-lower_freqs->data[0][filter_cnt])*riseInc;
+      //if(fft_freqs->data[0][bin_cnt]<= center_freqs->data[0][filter_cnt] && fft_freqs->data[0][bin_cnt+1]> center_freqs->data[0][filter_cnt])
+      if(fft_freqs->data[0][bin_cnt+1]> center_freqs->data[0][filter_cnt])
+        break;
+    }
+    //bin_cnt++;
+    
+    //negative slope
+    for(; bin_cnt<win_s-1; bin_cnt++){
+      
+      //checking whether last value is less than 0...
+      smpl_t val=triangle_heights->data[0][filter_cnt]-(fft_freqs->data[0][bin_cnt]-center_freqs->data[0][filter_cnt])*riseInc;
+      if(val>=0)
+        fb->filters[filter_cnt]->data[0][bin_cnt]=val;
+      else fb->filters[filter_cnt]->data[0][bin_cnt]=0.f;
+      
+      //if(fft_freqs->data[0][bin_cnt]<= upper_freqs->data[0][bin_cnt] && fft_freqs->data[0][bin_cnt+1]> upper_freqs->data[0][filter_cnt])
+      //TODO: CHECK whether bugfix correct
+      if(fft_freqs->data[0][bin_cnt+1]> upper_freqs->data[0][filter_cnt])
+        break;
+    }
+    //bin_cnt++;
+    
+    //zeroing tail
+    for(; bin_cnt<win_s; bin_cnt++)
+      fb->filters[filter_cnt]->data[0][bin_cnt]=0.f;
+
+  }
+  
+  
+  del_fvec(freqs);
+  del_fvec(lower_freqs);
+  del_fvec(upper_freqs);
+  del_fvec(center_freqs);
+
+  del_fvec(triangle_heights);
+  del_fvec(fft_freqs);
+
+  return fb;
+
+}
+
+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;
+}
+
+fvec_t * aubio_filterbank_getchannel(aubio_filterbank_t * f, uint_t channel) {
+  if ( (channel < f->n_filters) ) { return f->filters[channel]; }
+  else { return NULL; }
+}
Index: src/spectral/filterbank.h
===================================================================
--- src/spectral/filterbank.h	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
+++ src/spectral/filterbank.h	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
@@ -0,0 +1,80 @@
+/*
+   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
+
+/** filterbank object */
+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, uint_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);
+
+/** return the vector containing the filter coefficients of one channel
+
+ */
+fvec_t * aubio_filterbank_getchannel(aubio_filterbank_t * f, uint_t channel);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // FILTERBANK_H
Index: src/spectral/mfcc.c
===================================================================
--- src/spectral/mfcc.c	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
+++ src/spectral/mfcc.c	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
@@ -0,0 +1,123 @@
+/*
+   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 "spectral/fft.h"
+#include "spectral/filterbank.h"
+#include "spectral/mfcc.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_fft_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_fft(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 fft object */
+  del_aubio_fft(mf->fft_dct);
+  /** deleting buffers */
+  del_fvec(mf->in_dct);
+  del_cvec(mf->fftgrain_dct);
+  
+  /** deleting mfcc object */
+  AUBIO_FREE(mf);
+}
+
+
+/** 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);
+
+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_fft_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;
+}
+
Index: src/spectral/mfcc.h
===================================================================
--- src/spectral/mfcc.h	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
+++ src/spectral/mfcc.h	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
@@ -0,0 +1,64 @@
+/*
+   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
+
+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);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // MFCC_H
Index: src/spectral/phasevoc.c
===================================================================
--- src/spectral/phasevoc.c	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
+++ src/spectral/phasevoc.c	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
@@ -0,0 +1,150 @@
+/*
+   Copyright (C) 2003 Paul Brossier
+
+   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 "fvec.h"
+#include "cvec.h"
+#include "mathutils.h"
+#include "spectral/fft.h"
+#include "spectral/phasevoc.h"
+
+/** phasevocoder internal object */
+struct _aubio_pvoc_t {
+  uint_t win_s;       /** grain length */
+  uint_t hop_s;       /** overlap step */
+  uint_t channels;    /** number of channels */
+  aubio_fft_t * fft;  /** fft object */
+  fvec_t * synth;     /** cur output grain [win_s] */
+  fvec_t * synthold;  /** last input frame [win_s-hop_s] */
+  fvec_t * data;      /** current input grain [win_s] */
+  fvec_t * dataold;   /** last input frame [win_s-hop_s] */
+  smpl_t * w;         /** grain window [win_s] */
+};
+
+
+/** returns data and dataold slided by hop_s */
+static void aubio_pvoc_swapbuffers(smpl_t * data, smpl_t * dataold, const
+    smpl_t * datanew, uint_t win_s, uint_t hop_s);
+
+/** do additive synthesis from 'old' and 'cur' */
+static void aubio_pvoc_addsynth(const smpl_t * synth, smpl_t * synthold,
+    smpl_t * synthnew, uint_t win_s, uint_t hop_s);
+
+void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t * datanew, cvec_t *fftgrain) {
+  uint_t i,j;
+  for (i=0; i<pv->channels; i++) {
+    /* slide  */
+    aubio_pvoc_swapbuffers(pv->data->data[i],pv->dataold->data[i],
+        datanew->data[i],pv->win_s,pv->hop_s);
+    /* windowing */
+    for (j=0; j<pv->win_s; j++) pv->data->data[i][j] *= pv->w[j];
+  }
+  /* shift */
+  vec_shift(pv->data);
+  /* calculate fft */
+  aubio_fft_do (pv->fft,pv->data,fftgrain);
+}
+
+void aubio_pvoc_rdo(aubio_pvoc_t *pv,cvec_t * fftgrain, fvec_t * synthnew) {
+  uint_t i;
+  /* calculate rfft */
+  aubio_fft_rdo(pv->fft,fftgrain,pv->synth);
+  /* unshift */
+  vec_shift(pv->synth);
+  for (i=0; i<pv->channels; i++) {
+    aubio_pvoc_addsynth(pv->synth->data[i],pv->synthold->data[i],
+        synthnew->data[i],pv->win_s,pv->hop_s);
+  }
+}
+
+aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels) {
+  aubio_pvoc_t * pv = AUBIO_NEW(aubio_pvoc_t);
+
+  if (win_s < 2*hop_s) {
+    AUBIO_ERR("Hop size bigger than half the window size!\n");
+    AUBIO_ERR("Resetting hop size to half the window size.\n");
+    hop_s = win_s / 2;
+  }
+
+  if (hop_s < 1) {
+    AUBIO_ERR("Hop size is smaller than 1!\n");
+    AUBIO_ERR("Resetting hop size to half the window size.\n");
+    hop_s = win_s / 2;
+  }
+
+  pv->fft      = new_aubio_fft(win_s,channels);
+
+  /* remember old */
+  pv->data     = new_fvec (win_s, channels);
+  pv->synth    = new_fvec (win_s, channels);
+
+  /* new input output */
+  pv->dataold  = new_fvec  (win_s-hop_s, channels);
+  pv->synthold = new_fvec (win_s-hop_s, channels);
+  pv->w        = AUBIO_ARRAY(smpl_t,win_s);
+  aubio_window(pv->w,win_s,aubio_win_hanningz);
+
+  pv->channels = channels;
+  pv->hop_s    = hop_s;
+  pv->win_s    = win_s;
+
+  return pv;
+}
+
+void del_aubio_pvoc(aubio_pvoc_t *pv) {
+  del_fvec(pv->data);
+  del_fvec(pv->synth);
+  del_fvec(pv->dataold);
+  del_fvec(pv->synthold);
+  del_aubio_fft(pv->fft);
+  AUBIO_FREE(pv->w);
+  AUBIO_FREE(pv);
+}
+
+static void aubio_pvoc_swapbuffers(smpl_t * data, smpl_t * dataold, 
+    const smpl_t * datanew, uint_t win_s, uint_t hop_s)
+{
+  uint_t i;
+  for (i=0;i<win_s-hop_s;i++)
+    data[i] = dataold[i];
+  for (i=0;i<hop_s;i++)
+    data[win_s-hop_s+i] = datanew[i];
+  for (i=0;i<win_s-hop_s;i++)
+    dataold[i] = data[i+hop_s];
+}
+
+static void aubio_pvoc_addsynth(const smpl_t * synth, smpl_t * synthold, 
+                smpl_t * synthnew, uint_t win_s, uint_t hop_s)
+{
+  uint_t i;
+  smpl_t scale = 2*hop_s/(win_s+.0);
+  /* add new synth to old one and put result in synthnew */
+  for (i=0;i<hop_s;i++)
+    synthnew[i] = synthold[i]+synth[i]*scale;
+  /* shift synthold */
+  for (i=0;i<win_s-2*hop_s;i++)
+    synthold[i] = synthold[i+hop_s];
+  /* erase last frame in synthold */
+  for (i=win_s-hop_s;i<win_s;i++)
+    synthold[i-hop_s]=0.;
+  /* additive synth */
+  for (i=0;i<win_s-hop_s;i++)
+    synthold[i] += synth[i+hop_s]*scale;
+}
+
Index: src/spectral/phasevoc.h
===================================================================
--- src/spectral/phasevoc.h	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
+++ src/spectral/phasevoc.h	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
@@ -0,0 +1,106 @@
+/*
+   Copyright (C) 2003 Paul Brossier
+
+   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
+
+  Phase vocoder object
+
+  This object implements a phase vocoder. The spectral frames are computed
+  using a HanningZ window and a swapped version of the signal to simplify the
+  phase relationships across frames. The window sizes and overlap are specified
+  at creation time. Multiple channels are fully supported.
+
+*/
+
+#ifndef _PHASEVOC_H
+#define _PHASEVOC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** phasevocoder object */
+typedef struct _aubio_pvoc_t aubio_pvoc_t;
+
+/** create phase vocoder object
+
+  \param win_s size of analysis buffer (and length the FFT transform)
+  \param hop_s step size between two consecutive analysis
+  \param channels number of channels
+
+*/
+aubio_pvoc_t * new_aubio_pvoc (uint_t win_s, uint_t hop_s, uint_t channels);
+/** delete phase vocoder object
+
+  \param pv phase vocoder object as returned by new_aubio_pvoc
+
+*/
+void del_aubio_pvoc(aubio_pvoc_t *pv);
+
+/** compute spectral frame
+  
+  This function accepts an input vector of size [channels]x[hop_s]. The
+  analysis buffer is rotated and filled with the new data. After windowing of
+  this signal window, the Fourier transform is computed and returned in
+  fftgrain as two vectors, magnitude and phase.
+
+  \param pv phase vocoder object as returned by new_aubio_pvoc
+  \param in new input signal (hop_s long) 
+  \param fftgrain output spectral frame
+
+*/
+void aubio_pvoc_do(aubio_pvoc_t *pv, fvec_t *in, cvec_t * fftgrain);
+/** compute signal from spectral frame
+
+  This function takes an input spectral frame fftgrain of size
+  [channels]x[buf_s] and computes its inverse Fourier transform. Overlap-add
+  synthesis is then computed using the previously synthetised frames, and the
+  output stored in out.
+  
+  \param pv phase vocoder object as returned by new_aubio_pvoc
+  \param fftgrain input spectral frame
+  \param out output signal (hop_s long) 
+
+*/
+void aubio_pvoc_rdo(aubio_pvoc_t *pv, cvec_t * fftgrain, fvec_t *out);
+
+/** get window size
+
+  \param pv phase vocoder to get the window size from
+
+*/
+uint_t aubio_pvoc_get_win(aubio_pvoc_t* pv);
+/** get hop size
+
+  \param pv phase vocoder to get the hop size from
+
+*/
+uint_t aubio_pvoc_get_hop(aubio_pvoc_t* pv);
+/** get channel number
+ 
+  \param pv phase vocoder to get the number of channels from
+
+*/
+uint_t aubio_pvoc_get_channels(aubio_pvoc_t* pv);
+
+#ifdef __cplusplus
+}
+#endif 
+
+#endif
Index: src/spectral/tss.c
===================================================================
--- src/spectral/tss.c	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
+++ src/spectral/tss.c	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
@@ -0,0 +1,127 @@
+/*
+   Copyright (C) 2003 Paul Brossier
+
+   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.
+
+*/
+
+/* default values : alfa=4, beta=3, threshold=0.25 */
+
+#include "aubio_priv.h"
+#include "sample.h"
+#include "mathutils.h"
+#include "spectral/tss.h"
+
+struct _aubio_tss_t 
+{
+  smpl_t thrs;
+  smpl_t alfa;
+  smpl_t beta;
+  smpl_t parm;
+  smpl_t thrsfact;
+  fvec_t *theta1;
+  fvec_t *theta2;
+  fvec_t *oft1;
+  fvec_t *oft2;
+  fvec_t *dev;
+};
+
+void aubio_tss_do(aubio_tss_t *o, cvec_t * input, 
+    cvec_t * trans, cvec_t * stead)
+{
+  uint_t i,j;
+  uint_t test;	
+  uint_t nbins     = input->length;
+  uint_t channels  = input->channels;
+  smpl_t alfa      = o->alfa;
+  smpl_t beta      = o->beta;
+  smpl_t parm      = o->parm;
+  smpl_t ** dev    = (smpl_t **)o->dev->data;
+  smpl_t ** oft1   = (smpl_t **)o->oft1->data;
+  smpl_t ** oft2   = (smpl_t **)o->oft2->data;
+  smpl_t ** theta1 = (smpl_t **)o->theta1->data;
+  smpl_t ** theta2 = (smpl_t **)o->theta2->data;
+  /* second phase derivative */
+  for (i=0;i<channels; i++){
+    for (j=0;j<nbins; j++){
+      dev[i][j] = aubio_unwrap2pi(input->phas[i][j]
+          -2.0*theta1[i][j]+theta2[i][j]);
+      theta2[i][j] = theta1[i][j];
+      theta1[i][j] = input->phas[i][j];
+    }
+
+    for (j=0;j<nbins; j++){
+      /* transient analysis */
+      test = (ABS(dev[i][j]) > parm*oft1[i][j]);
+      trans->norm[i][j] = input->norm[i][j] * test;
+      trans->phas[i][j] = input->phas[i][j] * test;
+    }
+
+    for (j=0;j<nbins; j++){
+      /* steady state analysis */
+      test = (ABS(dev[i][j]) < parm*oft2[i][j]);
+      stead->norm[i][j] = input->norm[i][j] * test;
+      stead->phas[i][j] = input->phas[i][j] * test;
+
+      /*increase sstate probability for sines */
+      test = (trans->norm[i][j]==0.);
+      oft1[i][j]  = test;
+      test = (stead->norm[i][j]==0.);
+      oft2[i][j]  = test;
+      test = (trans->norm[i][j]>0.);
+      oft1[i][j] += alfa*test;
+      test = (stead->norm[i][j]>0.);
+      oft2[i][j] += alfa*test;
+      test = (oft1[i][j]>1. && trans->norm[i][j]>0.);
+      oft1[i][j] += beta*test;
+      test = (oft2[i][j]>1. && stead->norm[i][j]>0.);
+      oft2[i][j] += beta*test;
+    }
+  }
+}
+
+void aubio_tss_set_thres(aubio_tss_t *o, smpl_t thrs){
+	o->thrs = thrs;
+  	o->parm = thrs*o->thrsfact;
+}
+
+aubio_tss_t * new_aubio_tss(smpl_t thrs, smpl_t alfa, smpl_t beta, 
+    uint_t size, uint_t overlap,uint_t channels)
+{
+  aubio_tss_t * o = AUBIO_NEW(aubio_tss_t);
+  uint_t rsize = size/2+1;
+  o->thrs = thrs;
+  o->thrsfact = TWO_PI*overlap/rsize;
+  o->alfa = alfa;	
+  o->beta = beta;	
+  o->parm = thrs*o->thrsfact;
+  o->theta1 = new_fvec(rsize,channels);
+  o->theta2 = new_fvec(rsize,channels);
+  o->oft1 = new_fvec(rsize,channels);
+  o->oft2 = new_fvec(rsize,channels);
+  o->dev = new_fvec(rsize,channels);
+  return o;
+}
+
+void del_aubio_tss(aubio_tss_t *s)
+{
+  free(s->theta1);
+  free(s->theta2);
+  free(s->oft1);
+  free(s->oft2);
+  free(s->dev);
+  free(s);
+}
+
Index: src/spectral/tss.h
===================================================================
--- src/spectral/tss.h	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
+++ src/spectral/tss.h	(revision 32d69586108e1d0e451655e0a0da51bbea9169d4)
@@ -0,0 +1,84 @@
+/*
+	 Copyright (C) 2003 Paul Brossier
+
+	 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
+
+  Transient / Steady-state Separation (TSS)
+
+  This file implement a Transient / Steady-state Separation (TSS) as described
+  in:
+
+  Christopher Duxbury, Mike E. Davies, and Mark B. Sandler. Separation of
+  transient information in musical audio using multiresolution analysis
+  techniques. In Proceedings of the Digital Audio Effects Conference, DAFx-01,
+  pages 1­5, Limerick, Ireland, 2001.
+
+*/
+
+#ifndef TSS_H
+#define TSS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** TSS object */
+typedef struct _aubio_tss_t aubio_tss_t;
+
+/** create tss object
+
+  \param thrs separation threshold
+  \param alfa alfa parameter
+  \param beta beta parameter
+  \param size buffer size
+  \param overlap step size
+  \param channels number of input channels
+
+*/
+aubio_tss_t * new_aubio_tss(smpl_t thrs, smpl_t alfa, smpl_t beta, 
+    uint_t size, uint_t overlap,uint_t channels);
+/** delete tss object
+
+  \param s tss object as returned by new_aubio_tss
+
+*/
+void del_aubio_tss(aubio_tss_t *s);
+
+/** set transient / steady state separation threshold 
+ 
+  \param tss tss object as returned by new_aubio_tss
+  \param thrs new threshold value
+
+*/
+void aubio_tss_set_thres(aubio_tss_t *tss, smpl_t thrs);
+/** split input into transient and steady states components
+ 
+  \param s tss object as returned by new_aubio_tss
+  \param input input spectral frame
+  \param trans output transient components
+  \param stead output steady state components
+
+*/
+void aubio_tss_do(aubio_tss_t *s, cvec_t * input, cvec_t * trans, cvec_t * stead);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*TSS_H*/
