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