00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017                                                                           
00018 
00019 #ifndef WINDOW_H
00020 #define WINDOW_H
00021 
00022 #include "Typedefs.h"
00023 #include "Debug.h"
00024 
00056 class Window{
00057 public:
00064   enum WindowType {
00065     RECTANGULAR         = 0 ,
00066     HANN                = 1 ,
00067     HANNING             = 2 ,
00068     HAMMING             = 3 ,
00069     COSINE              = 4 ,
00070     BLACKMAN            = 5 ,
00071     BLACKMANHARRIS      = 6 ,
00072     NUTTALL             = 7 ,
00073     BLACKMANNUTTALL     = 8 ,
00074     CUSTOM              = 9 
00076   };
00077 
00078 protected:
00079   int _inputSize;
00080   WindowType _windowType;
00081   MatrixXR _window;
00082   
00083   MatrixXR hann(int length);
00084   MatrixXR hamming(int length);
00085   MatrixXR cosine(int length);
00086 
00087   MatrixXR blackmanType(int length, Real a0, Real a1, Real a2, Real a3);
00088   MatrixXR blackman(int length);
00089   MatrixXR nuttall(int length);
00090   MatrixXR blackmanHarris(int length);
00091   MatrixXR blackmanNuttall(int length);
00092 
00093   template<typename FrameMatrixType, typename WindowedMatrixType>
00094   void process(const FrameMatrixType& frames, WindowedMatrixType* windowedFrames);
00095  
00096 public: 
00101   Window(int inputSize = 1024, WindowType windowType = RECTANGULAR);
00102 
00106   ~Window();
00107 
00108   void setup();
00109   void reset();
00110 
00124   void process(const MatrixXC& frames, MatrixXC* windowedFrames);
00125   void process(const MatrixXR& frames, MatrixXR* windowedFrames);
00126   void process(const MatrixXR& frames, MatrixXC* windowedFrames);
00127 
00133   int inputSize() const;
00134   
00138   void setInputSize( int size, bool callSetup = true );
00139   
00145   WindowType windowType() const;
00146   
00150   void setWindowType( WindowType type, bool callSetup = true );
00151 
00159   const MatrixXR& window() const;
00160 
00171   void setWindow( const MatrixXR& window, bool callSetup = true );
00172 };
00173 
00174 #endif