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@309
|
8
|
c@309
|
9 This program is free software; you can redistribute it and/or
|
c@309
|
10 modify it under the terms of the GNU General Public License as
|
c@309
|
11 published by the Free Software Foundation; either version 2 of the
|
c@309
|
12 License, or (at your option) any later version. See the file
|
c@309
|
13 COPYING included with this distribution for more information.
|
c@251
|
14 */
|
c@250
|
15
|
c@251
|
16 #ifndef MFCC_H
|
c@251
|
17 #define MFCC_H
|
c@251
|
18
|
c@251
|
19 #include "base/Window.h"
|
c@251
|
20
|
c@289
|
21 class FFTReal;
|
c@289
|
22
|
c@251
|
23 struct MFCCConfig {
|
c@251
|
24 int FS;
|
c@251
|
25 int fftsize;
|
c@251
|
26 int nceps;
|
c@255
|
27 double logpower;
|
c@251
|
28 bool want_c0;
|
c@257
|
29 WindowType window;
|
c@255
|
30 MFCCConfig(int _FS) :
|
c@257
|
31 FS(_FS), fftsize(2048), nceps(19),
|
c@257
|
32 logpower(1.0), want_c0(true), window(HammingWindow) { }
|
c@251
|
33 };
|
c@251
|
34
|
c@251
|
35 class MFCC
|
c@251
|
36 {
|
c@251
|
37 public:
|
c@251
|
38 MFCC(MFCCConfig config);
|
c@251
|
39 virtual ~MFCC();
|
c@251
|
40
|
c@255
|
41 /**
|
c@255
|
42 * Process time-domain input data. inframe must contain
|
c@255
|
43 * getfftlength() samples. outceps must contain space for nceps
|
c@255
|
44 * values, plus one if want_c0 is specified.
|
c@255
|
45 */
|
c@255
|
46 int process(const double *inframe, double *outceps);
|
c@255
|
47
|
c@255
|
48 /**
|
c@255
|
49 * Process time-domain input data. real and imag must contain
|
c@255
|
50 * getfftlength()/2+1 elements (i.e. the conjugate half of the FFT
|
c@255
|
51 * is not expected). outceps must contain space for nceps values,
|
c@255
|
52 * plus one if want_c0 is specified.
|
c@255
|
53 */
|
c@255
|
54 int process(const double *real, const double *imag, double *outceps);
|
c@251
|
55
|
c@251
|
56 int getfftlength() const { return fftSize; }
|
c@251
|
57
|
c@251
|
58 private:
|
c@251
|
59 /* Filter bank parameters */
|
c@251
|
60 double lowestFrequency;
|
c@251
|
61 int linearFilters;
|
c@251
|
62 double linearSpacing;
|
c@251
|
63 int logFilters;
|
c@251
|
64 double logSpacing;
|
c@251
|
65
|
c@251
|
66 /* FFT length */
|
c@251
|
67 int fftSize;
|
c@251
|
68
|
c@251
|
69 int totalFilters;
|
c@255
|
70 double logPower;
|
c@251
|
71
|
c@251
|
72 /* Misc. */
|
c@251
|
73 int samplingRate;
|
c@251
|
74 int nceps;
|
c@251
|
75
|
c@251
|
76 /* MFCC vector */
|
c@251
|
77 double *ceps;
|
c@251
|
78
|
c@251
|
79 double **mfccDCTMatrix;
|
c@251
|
80 double **mfccFilterWeights;
|
c@251
|
81
|
c@251
|
82 /* The analysis window */
|
c@251
|
83 Window<double> *window;
|
c@251
|
84
|
c@251
|
85 /* For the FFT */
|
c@255
|
86 double *realOut;
|
c@255
|
87 double *imagOut;
|
c@255
|
88 double *fftMag;
|
c@255
|
89 double *earMag;
|
c@289
|
90 FFTReal *fft;
|
c@255
|
91
|
c@251
|
92 /* Set if user want C0 */
|
c@251
|
93 int WANT_C0;
|
c@251
|
94 };
|
c@251
|
95
|
c@250
|
96
|
c@250
|
97 #endif
|
c@250
|
98
|