qm-dsp  1.8
MFCC.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     QM DSP Library
00005 
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2005 Nicolas Chetry, copyright 2008 QMUL.
00008 
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef MFCC_H
00017 #define MFCC_H
00018 
00019 #include "base/Window.h"
00020 
00021 class FFTReal;
00022 
00023 struct MFCCConfig {
00024     int FS;
00025     int fftsize;
00026     int nceps;
00027     double logpower;
00028     bool want_c0;
00029     WindowType window;
00030     MFCCConfig(int _FS) :
00031         FS(_FS), fftsize(2048), nceps(19),
00032         logpower(1.0), want_c0(true), window(HammingWindow) { }
00033 };
00034 
00035 class MFCC
00036 {
00037 public:
00038     MFCC(MFCCConfig config);
00039     virtual ~MFCC();
00040 
00046     int process(const double *inframe, double *outceps);
00047 
00054     int process(const double *real, const double *imag, double *outceps);
00055 
00056     int getfftlength() const { return fftSize; }
00057 
00058 private:
00059     /* Filter bank parameters */
00060     double  lowestFrequency; 
00061     int     linearFilters; 
00062     double  linearSpacing;
00063     int     logFilters;
00064     double  logSpacing;
00065     
00066     /* FFT length */
00067     int     fftSize;
00068     
00069     int     totalFilters;
00070     double  logPower;
00071     
00072     /* Misc. */
00073     int     samplingRate;
00074     int     nceps;
00075     
00076     /* MFCC vector */
00077     double  *ceps;
00078     
00079     double  **mfccDCTMatrix;
00080     double  **mfccFilterWeights;
00081     
00082     /* The analysis window */
00083     Window<double> *window;
00084     
00085     /* For the FFT */
00086     double *realOut;
00087     double *imagOut;
00088     double *fftMag;
00089     double *earMag;
00090     FFTReal *fft;
00091 
00092     /* Set if user want C0 */
00093     int WANT_C0;
00094 };
00095 
00096 
00097 #endif
00098