SpectralSpread.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 
00023 #ifndef _SpectralSpread_
00024 #define _SpectralSpread_
00025 
00026 #include "SpectralEnvelopeExtract.hxx"
00027 #include "SpectralEnvelopeApply.hxx"
00028 #include "Frame.hxx"
00029 #include "InPort.hxx"
00030 #include "OutPort.hxx"
00031 #include "InControl.hxx"
00032 #include "FrameTransformation.hxx"
00033 #include "FrameTransformationConfig.hxx"
00034 #include "SegmentTransformationConfig.hxx"
00035 #include "Spectrum.hxx"
00036 #include "SpecTypeFlags.hxx"
00037 
00038 
00039 namespace CLAM{
00040 
00045         class SpectralSpread: public FrameTransformationTmpl<Spectrum>
00046         {
00047                 
00048                 const char *GetClassName() const {return "SpectralSpread";}
00049 
00050                 InPort<Spectrum> mIn;
00051                 OutPort<Spectrum> mOut;
00052                 
00053                 FloatInControl mCenterFreqCtl;
00054         public:
00055 
00056                 SpectralSpread() 
00057                         : 
00058                         mIn( "InSpectrum", this), 
00059                         mOut( "OutSpectrum", this),
00060                         mCenterFreqCtl("CenterFreq", this)
00061                 {
00062                         Configure( SegmentTransformationConfig() );
00063                         SpecTypeFlags flg;
00064                         flg.bMagPhase = 1;
00065                         flg.bMagPhaseBPF = 1;
00066                         mBPFSpectrum.SetType(flg);
00067                         mFlag.bMagPhase = 0;
00068                         mFlag.bMagPhaseBPF = true;
00069                 }
00070 
00071                 ~SpectralSpread() {}
00072 
00073                 virtual bool InitControls()
00074                 { 
00075                         mCenterFreqCtl.DoControl(1000);
00076                         mAmount.DoControl(100);
00077                         
00078                         return true;
00079                 }
00080                 
00081                 bool Do(const Frame& in, Frame& out)
00082                 {
00083                         return Do(in.GetSpectrum(), 
00084                                 out.GetSpectrum());
00085                 }
00086         
00087                 bool Do(const Spectrum& inpeaks,Spectrum& out);
00088 
00089                 bool Do()
00090                 {
00091                         bool result = Do(mIn.GetData(), mOut.GetData());
00092                         mIn.Consume();
00093                         mOut.Produce();
00094                         return result;  
00095                 }
00096 
00097         private:
00098                 Spectrum mBPFSpectrum;
00099                 SpecTypeFlags mFlag;
00100         };              
00101 }       //namespace CLAM
00102 
00103 #endif // _SpectralSpread_
00104 
Generated by  doxygen 1.6.3