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