annotate dsp/mfcc/MFCC.h @ 289:befe5aa6b450

* Refactor FFT a little bit so as to separate construction and processing rather than have a single static method -- will make it easier to use a different implementation * pull in KissFFT implementation (not hooked up yet)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 13 May 2009 09:19:12 +0000
parents 9619d6995b73
children e5907ae6de17
rev   line source
c@251 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
c@250 2
c@251 3 /*
c@251 4 QM DSP Library
c@250 5
c@251 6 Centre for Digital Music, Queen Mary, University of London.
c@251 7 This file copyright 2005 Nicolas Chetry, copyright 2008 QMUL.
c@251 8 All rights reserved.
c@251 9 */
c@250 10
c@251 11 #ifndef MFCC_H
c@251 12 #define MFCC_H
c@251 13
c@251 14 #include "base/Window.h"
c@251 15
c@289 16 class FFTReal;
c@289 17
c@251 18 struct MFCCConfig {
c@251 19 int FS;
c@251 20 int fftsize;
c@251 21 int nceps;
c@255 22 double logpower;
c@251 23 bool want_c0;
c@257 24 WindowType window;
c@255 25 MFCCConfig(int _FS) :
c@257 26 FS(_FS), fftsize(2048), nceps(19),
c@257 27 logpower(1.0), want_c0(true), window(HammingWindow) { }
c@251 28 };
c@251 29
c@251 30 class MFCC
c@251 31 {
c@251 32 public:
c@251 33 MFCC(MFCCConfig config);
c@251 34 virtual ~MFCC();
c@251 35
c@255 36 /**
c@255 37 * Process time-domain input data. inframe must contain
c@255 38 * getfftlength() samples. outceps must contain space for nceps
c@255 39 * values, plus one if want_c0 is specified.
c@255 40 */
c@255 41 int process(const double *inframe, double *outceps);
c@255 42
c@255 43 /**
c@255 44 * Process time-domain input data. real and imag must contain
c@255 45 * getfftlength()/2+1 elements (i.e. the conjugate half of the FFT
c@255 46 * is not expected). outceps must contain space for nceps values,
c@255 47 * plus one if want_c0 is specified.
c@255 48 */
c@255 49 int process(const double *real, const double *imag, double *outceps);
c@251 50
c@251 51 int getfftlength() const { return fftSize; }
c@251 52
c@251 53 private:
c@251 54 /* Filter bank parameters */
c@251 55 double lowestFrequency;
c@251 56 int linearFilters;
c@251 57 double linearSpacing;
c@251 58 int logFilters;
c@251 59 double logSpacing;
c@251 60
c@251 61 /* FFT length */
c@251 62 int fftSize;
c@251 63
c@251 64 int totalFilters;
c@255 65 double logPower;
c@251 66
c@251 67 /* Misc. */
c@251 68 int samplingRate;
c@251 69 int nceps;
c@251 70
c@251 71 /* MFCC vector */
c@251 72 double *ceps;
c@251 73
c@251 74 double **mfccDCTMatrix;
c@251 75 double **mfccFilterWeights;
c@251 76
c@251 77 /* The analysis window */
c@251 78 Window<double> *window;
c@251 79
c@251 80 /* For the FFT */
c@255 81 double *realOut;
c@255 82 double *imagOut;
c@255 83 double *fftMag;
c@255 84 double *earMag;
c@289 85 FFTReal *fft;
c@255 86
c@251 87 /* Set if user want C0 */
c@251 88 int WANT_C0;
c@251 89 };
c@251 90
c@250 91
c@250 92 #endif
c@250 93