diff dsp/mfcc/MFCC.h @ 251:c3600d3cfe5c

* Add timbral (MFCC) feature option to segmenter
author Chris Cannam <c.cannam@qmul.ac.uk>
date Thu, 10 Jan 2008 16:41:33 +0000
parents a106e551e9a4
children a251fb0de594
line wrap: on
line diff
--- a/dsp/mfcc/MFCC.h	Thu Jan 10 15:16:08 2008 +0000
+++ b/dsp/mfcc/MFCC.h	Thu Jan 10 16:41:33 2008 +0000
@@ -1,51 +1,70 @@
-#ifndef _LIB_MFCC_H
-#define _LIB_MFCC_H
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
 
-#define MFCC    6
+/*
+    QM DSP Library
 
-typedef struct mfcc_t {
-	
-	/* Filter bank parameters */
-	double  lowestFrequency; 
-	int     linearFilters; 
-	double  linearSpacing;
-	int     logFilters;
-	double  logSpacing;
-	
-	/* FFT length */
-	int     fftSize;
-	
-	/* Analysis window length*/
-	int     windowSize;
-	
-	int     totalFilters;
-	
-	/* Misc. */
-	int     samplingRate;
-	int     nceps;
-	
-	/* MFCC vector */
-	double  *ceps;
-	
-	double  **mfccDCTMatrix;
-	double  **mfccFilterWeights;
-	
-	/* The analysis window */
-	double  *window;
-	
-	/* For the FFT */
-	double* imagIn;		// always zero
-	double* realOut;
-	double* imagOut;
-	
-	/* Set if user want C0 */
-	int WANT_C0;
-	
-} mfcc_t;
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2005 Nicolas Chetry, copyright 2008 QMUL.
+    All rights reserved.
+*/
 
-extern mfcc_t* init_mfcc(int fftSize, int nceps , int samplingRate, int WANT_C0);
-extern int     do_mfcc(mfcc_t* mfcc_p, double* frame, int length);
-extern void    close_mfcc(mfcc_t* mfcc_p);
+#ifndef MFCC_H
+#define MFCC_H
+
+#include "base/Window.h"
+
+struct MFCCConfig {
+    int FS;
+    int fftsize;
+    int nceps;
+    bool want_c0;
+};
+
+class MFCC
+{
+public:
+    MFCC(MFCCConfig config);
+    virtual ~MFCC();
+
+    int process(int length, double *inframe, double *outceps);
+
+    int getfftlength() const { return fftSize; }
+
+private:
+    /* Filter bank parameters */
+    double  lowestFrequency; 
+    int     linearFilters; 
+    double  linearSpacing;
+    int     logFilters;
+    double  logSpacing;
+    
+    /* FFT length */
+    int     fftSize;
+    
+    int     totalFilters;
+    
+    /* Misc. */
+    int     samplingRate;
+    int     nceps;
+    
+    /* MFCC vector */
+    double  *ceps;
+    
+    double  **mfccDCTMatrix;
+    double  **mfccFilterWeights;
+    
+    /* The analysis window */
+    Window<double> *window;
+    
+    /* For the FFT */
+    double* imagIn;		// always zero
+    double* realOut;
+    double* imagOut;
+    
+    /* Set if user want C0 */
+    int WANT_C0;
+};
+
 
 #endif