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@251: All rights reserved. c@251: */ c@250: c@251: #ifndef MFCC_H c@251: #define MFCC_H c@251: c@251: #include "base/Window.h" c@251: 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@255: MFCCConfig(int _FS) : c@255: FS(_FS), fftsize(2048), nceps(19), logpower(1.0), want_c0(true) { } 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 *imagIn; // always zero c@255: double *realOut; c@255: double *imagOut; c@255: double *fftMag; c@255: double *earMag; 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: