comparison src/mfcc_analyzer.hpp @ 0:add35537fdbb tip

Initial import
author irh <ian.r.hobson@gmail.com>
date Thu, 25 Aug 2011 11:05:55 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:add35537fdbb
1 // Copyright 2011, Ian Hobson.
2 //
3 // This file is part of gpsynth.
4 //
5 // gpsynth is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // gpsynth is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with gpsynth in the file COPYING.
17 // If not, see http://www.gnu.org/licenses/.
18
19 // MFCCAnalyzer - extracts MFCCs from a provided magnitude spectrum
20
21 #pragma once
22
23 #include "fftw3.h"
24
25 #include <vector>
26
27 namespace dsp {
28
29 class MFCCAnalyzer {
30 fftw_plan dct_plan_;
31 int frame_size_;
32 double sample_rate_;
33 double frequency_min_;
34 double frequency_max_;
35 std::vector< std::vector<double> > mel_filters_;
36 int mel_bands_;
37 int number_of_mfccs_;
38 std::vector<double> mfccs_;
39 double* mel_bands_dct_in_;
40 double* mel_bands_dct_out_;
41
42 public:
43 MFCCAnalyzer(int frame_size,
44 int mel_bands,
45 int number_of_mfccs,
46 double frequency_min,
47 double frequency_max);
48
49 ~MFCCAnalyzer();
50
51 void SetSampleRate(double sample_rate);
52
53 // extracts mfccs from a magnitude spectrum
54 const std::vector<double>& ExtractMFCCS(const std::vector<double>& spectrum);
55
56 private:
57 void InitializeMelDCT();
58 void InitializeFilters();
59 };
60
61 } // dsp namespace