cannam@26: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ cannam@25: cannam@26: /* cannam@26: QM DSP Library cannam@25: cannam@26: Centre for Digital Music, Queen Mary, University of London. cannam@26: This file copyright 2005 Nicolas Chetry, copyright 2008 QMUL. Chris@84: Chris@84: This program is free software; you can redistribute it and/or Chris@84: modify it under the terms of the GNU General Public License as Chris@84: published by the Free Software Foundation; either version 2 of the Chris@84: License, or (at your option) any later version. See the file Chris@84: COPYING included with this distribution for more information. cannam@26: */ cannam@25: cannam@26: #ifndef MFCC_H cannam@26: #define MFCC_H cannam@26: cannam@26: #include "base/Window.h" cannam@26: cannam@64: class FFTReal; cannam@64: cannam@26: struct MFCCConfig { cannam@26: int FS; cannam@26: int fftsize; cannam@26: int nceps; cannam@30: double logpower; cannam@26: bool want_c0; cannam@32: WindowType window; cannam@30: MFCCConfig(int _FS) : cannam@32: FS(_FS), fftsize(2048), nceps(19), cannam@32: logpower(1.0), want_c0(true), window(HammingWindow) { } cannam@26: }; cannam@26: cannam@26: class MFCC cannam@26: { cannam@26: public: cannam@26: MFCC(MFCCConfig config); cannam@26: virtual ~MFCC(); cannam@26: cannam@30: /** cannam@30: * Process time-domain input data. inframe must contain cannam@30: * getfftlength() samples. outceps must contain space for nceps cannam@30: * values, plus one if want_c0 is specified. cannam@30: */ cannam@30: int process(const double *inframe, double *outceps); cannam@30: cannam@30: /** cannam@30: * Process time-domain input data. real and imag must contain cannam@30: * getfftlength()/2+1 elements (i.e. the conjugate half of the FFT cannam@30: * is not expected). outceps must contain space for nceps values, cannam@30: * plus one if want_c0 is specified. cannam@30: */ cannam@30: int process(const double *real, const double *imag, double *outceps); cannam@26: cannam@26: int getfftlength() const { return fftSize; } cannam@26: cannam@26: private: cannam@26: /* Filter bank parameters */ cannam@26: double lowestFrequency; cannam@26: int linearFilters; cannam@26: double linearSpacing; cannam@26: int logFilters; cannam@26: double logSpacing; cannam@26: cannam@26: /* FFT length */ cannam@26: int fftSize; cannam@26: cannam@26: int totalFilters; cannam@30: double logPower; cannam@26: cannam@26: /* Misc. */ cannam@26: int samplingRate; cannam@26: int nceps; cannam@26: cannam@26: /* MFCC vector */ cannam@26: double *ceps; cannam@26: cannam@26: double **mfccDCTMatrix; cannam@26: double **mfccFilterWeights; cannam@26: cannam@26: /* The analysis window */ cannam@26: Window *window; cannam@26: cannam@26: /* For the FFT */ cannam@30: double *realOut; cannam@30: double *imagOut; cannam@30: double *fftMag; cannam@30: double *earMag; cannam@64: FFTReal *fft; cannam@30: cannam@26: /* Set if user want C0 */ cannam@26: int WANT_C0; cannam@26: }; cannam@26: cannam@25: cannam@25: #endif cannam@25: