Marsyas  0.5.0-beta1
/Users/jleben/code/marsyas/src/marsyas/marsystems/Windowing.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 1998-2008 George Tzanetakis <gtzan@cs.uvic.ca>
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 */
00018 
00019 #ifndef MARSYAS_WINDOWING_H
00020 #define MARSYAS_WINDOWING_H
00021 
00022 #include <marsyas/system/MarSystem.h>
00023 
00024 namespace Marsyas
00025 {
00043 class Windowing: public MarSystem
00044 {
00045 private:
00046   realvec envelope_;
00047   realvec tmp_;
00048   //mrs_real norm_;
00049   mrs_natural delta_;
00050 
00051   mrs_natural zeroPadding_;
00052   mrs_natural size_;
00053 
00054   MarControlPtr ctrl_type_;
00055   MarControlPtr ctrl_zeroPhasing_;
00056   MarControlPtr ctrl_zeroPadding_;
00057   MarControlPtr ctrl_size_;
00058   MarControlPtr ctrl_variance_;
00059   MarControlPtr ctrl_normalize_;
00060 
00061 
00062   void addcontrols();
00063   void myUpdate(MarControlPtr sender);
00064 
00065 public:
00066   Windowing(std::string name);
00067   Windowing(const Windowing& a);
00068   ~Windowing();
00069 
00070   MarSystem* clone() const;
00071 
00072   void myProcess(realvec& in, realvec& out);
00073 
00074 };
00075 
00077 void
00078 windowingFillRaisedCosine(realvec& envelope, mrs_real alpha, mrs_real beta);
00079 
00088 inline
00089 void
00090 windowingFillHamming(realvec& envelope)
00091 {
00092   windowingFillRaisedCosine(envelope, 0.54, 0.46);
00093 }
00094 
00103 inline
00104 void
00105 windowingFillHanning(realvec& envelope)
00106 {
00107   windowingFillRaisedCosine(envelope, 0.5, 0.5);
00108 }
00109 
00111 void windowingFillTriangle(realvec& envelope);
00112 
00114 void windowingFillBartlett(realvec& envelope);
00115 
00117 void windowingFillGaussian(realvec& envelope, mrs_real sigma);
00118 
00120 void windowingFillBlackman(realvec& envelope, mrs_real alpha=0.16);
00121 
00123 void windowingFillBlackmanHarris(realvec& envelope);
00124 
00126 void windowingFillCosine(realvec& envelope);
00127 
00128 
00129 }//namespace Marsyas
00130 
00131 #endif