Main Page · Modules · All Classes · Class Hierarchy
MASoundBasicAnalyzer.hpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #pragma once
23 
24 #include "ml/MAAnalyzer.hpp"
25 
26 #include <MCBinaryData.hpp>
27 #include <MCDefs.hpp>
28 #include <MCTypes.hpp>
29 
30 #include <boost/scoped_ptr.hpp>
31 
32 class FilterBankWrapper;
33 class MARobotState;
34 
44 {
45 public:
46 
55  explicit MASoundBasicAnalyzer(unsigned int frequency, bool only_mfcc_components = false);
56  virtual ~MASoundBasicAnalyzer();
57 
58  virtual void AddSamples(const MARobotState& robot_state) override;
59  virtual void Reset() override;
60  virtual bool IsValid() const override;
61 
69  virtual MC::FloatList GetFeatureVector() override;
70 
81  MC::FloatTable GetFeatureVectors(unsigned int desired_vector_count = 0, unsigned int erased_vector_count = 0);
82 
90  unsigned int GetFeatureVectorCount() const;
91 
99  void AddSoundData(const MCBinaryData& raw_data);
100 
108  void AddSoundData(const MC::DoubleList& raw_data);
109 
110 protected:
111 
117  virtual void GenerateFeatureVectors();
118 
128  MC::FloatList ApplyHorizontalFeatures(const MC::FloatList& vector);
129 
135  virtual MC::FloatList CalculateHorizontalFeatures();
136 
147  MC::DoubleTable GenerateHannWindows(const MC::DoubleList& audio_data, int& remaining_count);
148 
149  // STATIC VARIABLES
151  static const int MfccCount;
152  // NON-STATIC VARIABLES
154  double Frequency;
158  boost::scoped_ptr<FilterBankWrapper> Wrapper;
160  MC::DoubleTable DataWindows;
162  MC::DoubleList LastDeltaFrame;
164  MC::DoubleList LastMmbsesDeltaFrame;
166  MC::FloatTable FeatureVectors;
170  MC::FloatTable SlidingWindow;
172  MC::DoubleList Buffer;
174  double* HannWindow;
179 };
180 
virtual bool IsValid() const override
Check if enough samples were added to the analyzer.
int SlidingWindowLimit
Sliding window count.
bool OnlyMfccCoefs
Calculate only mfcc band components.
Binary data class.
int * BarkBandLimits
Bark band limits.
MC::FloatTable GetFeatureVectors(unsigned int desired_vector_count=0, unsigned int erased_vector_count=0)
Get all feature vectors.
Analyzer base class.
Definition: MAAnalyzer.hpp:67
boost::scoped_ptr< FilterBankWrapper > Wrapper
Filter bank for MFCC calculation.
unsigned int GetFeatureVectorCount() const
Get the available feature vector count.
static const int MfccCount
Number of mfcc components.
MC::DoubleList LastDeltaFrame
Last delta frame.
virtual void Reset() override
Reset the analyzer and drop all samples.
virtual MC::FloatList CalculateHorizontalFeatures()
Calculate horizontal features for the feature vectors.
MC::FloatTable FeatureVectors
Feature vectors.
double Frequency
Audio frequency.
MASoundBasicAnalyzer(unsigned int frequency, bool only_mfcc_components=false)
Class constructor.
MC::DoubleList LastMmbsesDeltaFrame
Last MMBSES frame.
virtual void AddSamples(const MARobotState &robot_state) override
Add new samples from the robot state.
MC::FloatList ApplyHorizontalFeatures(const MC::FloatList &vector)
Add a feature vector to a sliding window to calculate horizontal features.
MC::DoubleTable GenerateHannWindows(const MC::DoubleList &audio_data, int &remaining_count)
Generate Hann windows from audio data.
MC::DoubleList Buffer
Audio buffer.
double * HannWindow
Hann window.
MC::FloatTable SlidingWindow
Sliding window of feature vectors.
virtual MC::FloatList GetFeatureVector() override
Get a feature vector.
Sound analyzer class.
virtual void GenerateFeatureVectors()
Generate feature vector frames.
int WindowSize
Ideal window size.
void AddSoundData(const MCBinaryData &raw_data)
Add raw (byte) sound data.
Robot state.
MC::DoubleTable DataWindows
Audio data windows.