WindowGenerator.hxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _WINDOW_GENERATOR_
00023 #define _WINDOW_GENERATOR_
00024
00025 #include <typeinfo>
00026 #include "DataTypes.hxx"
00027 #include "GlobalEnums.hxx"
00028 #include "Processing.hxx"
00029 #include "InControl.hxx"
00030 #include "Processing.hxx"
00031 #include "WindowGeneratorConfig.hxx"
00032 #include "Array.hxx"
00033 #include "AudioOutPort.hxx"
00034
00035 namespace CLAM {
00036
00037 class Audio;
00038 class Spectrum;
00039 class Storage;
00040 class ProcessingConfig;
00041
00080 class WindowGenerator: public Processing {
00081 public:
00082 typedef WindowGeneratorConfig Config;
00083 private:
00084 Config mConfig;
00085
00086 const char *GetClassName() const {return "WindowGenerator";}
00087
00091 bool ConcreteConfigure(const ProcessingConfig& c);
00092
00093 public:
00094 WindowGenerator(const WindowGeneratorConfig &c=Config());
00095
00096 ~WindowGenerator();
00097
00098 const ProcessingConfig &GetConfig() const { return mConfig;}
00099
00100 bool Do(void);
00101
00102 bool Do(DataArray& output);
00103 bool Do(Spectrum& output);
00104 bool Do(Audio& output);
00105
00106 bool MayDisableExecution() const {return true;}
00107
00108 void SetSize(TSize size)
00109 {
00110 CLAM_DEBUG_ASSERT(size%2==1,"Window size must be odd");
00111 mSize.DoControl((TControlData)size);
00112 }
00113
00114 protected:
00115 AudioOutPort mOutput;
00116
00117 private:
00118 FloatInControl mSize;
00119 DataArray mTable;
00120
00121 void CreateTable(DataArray& table,EWindowType windowType,long windowsize) const;
00122 void CreateWindowFromTable(DataArray &window) const;
00123 double BesselFunction(double x) const;
00124 void KaiserBessel(long size,DataArray& window,
00125 double alpha) const;
00126 void BlackmanHarrisX(long size,DataArray& window,
00127 double a0,double a1,double a2,double a3 = 0.) const;
00128 void BlackmanHarris62(long size,DataArray& window) const;
00129 void BlackmanHarris70(long size,DataArray& window) const;
00130 void BlackmanHarris74(long size,DataArray& window) const;
00131 void BlackmanHarris92(long size,DataArray& window) const;
00132 void BlackmanHarrisLike(long size,DataArray& window) const;
00133 void Hamming(long size,DataArray& window) const;
00134 void Triangular(long size,DataArray& window) const;
00135 void BlackmanHarris92TransMainLobe(long size,DataArray& window) const;
00136 void Gaussian(long size,DataArray& window) const;
00137 void Sine(long size,DataArray& window) const;
00138 void Square(long size,DataArray& window) const;
00139
00140 void InvertWindow(const DataArray& originalWindow,
00141 DataArray& invertedWindow) const;
00142 void InvertWindow(DataArray& window) const;
00143 void NormalizeWindow(DataArray& window) const;
00144 double Sinc(double x, short N) const;
00145
00146 };
00147
00148 };
00149
00150 #endif //_WINDOW_GENERATOR_
00151