add queen mary DSP library
[ardour2.git] / libs / qm-dsp / dsp / mfcc / MFCC.h
blob9ce19fc90e022a2c66b1a887afcda2a9538c6ddf
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
3 /*
4 QM DSP Library
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2005 Nicolas Chetry, copyright 2008 QMUL.
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
16 #ifndef MFCC_H
17 #define MFCC_H
19 #include "base/Window.h"
21 class FFTReal;
23 struct MFCCConfig {
24 int FS;
25 int fftsize;
26 int nceps;
27 double logpower;
28 bool want_c0;
29 WindowType window;
30 MFCCConfig(int _FS) :
31 FS(_FS), fftsize(2048), nceps(19),
32 logpower(1.0), want_c0(true), window(HammingWindow) { }
35 class MFCC
37 public:
38 MFCC(MFCCConfig config);
39 virtual ~MFCC();
41 /**
42 * Process time-domain input data. inframe must contain
43 * getfftlength() samples. outceps must contain space for nceps
44 * values, plus one if want_c0 is specified.
46 int process(const double *inframe, double *outceps);
48 /**
49 * Process time-domain input data. real and imag must contain
50 * getfftlength()/2+1 elements (i.e. the conjugate half of the FFT
51 * is not expected). outceps must contain space for nceps values,
52 * plus one if want_c0 is specified.
54 int process(const double *real, const double *imag, double *outceps);
56 int getfftlength() const { return fftSize; }
58 private:
59 /* Filter bank parameters */
60 double lowestFrequency;
61 int linearFilters;
62 double linearSpacing;
63 int logFilters;
64 double logSpacing;
66 /* FFT length */
67 int fftSize;
69 int totalFilters;
70 double logPower;
72 /* Misc. */
73 int samplingRate;
74 int nceps;
76 /* MFCC vector */
77 double *ceps;
79 double **mfccDCTMatrix;
80 double **mfccFilterWeights;
82 /* The analysis window */
83 Window<double> *window;
85 /* For the FFT */
86 double *realOut;
87 double *imagOut;
88 double *fftMag;
89 double *earMag;
90 FFTReal *fft;
92 /* Set if user want C0 */
93 int WANT_C0;
97 #endif