SpectralFocus.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 _SpectralFocus_
00024 #define _SpectralFocus_
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 SpectralFocus: public FrameTransformationTmpl<Spectrum>
00046         {
00047                 
00048                 const char *GetClassName() const {return "SpectralFocus";}
00049 
00050                 InPort<Spectrum> mIn;
00051                 OutPort<Spectrum> mOut;
00052                 
00053                 FloatInControl mCenterFreqCtl;
00054                 FloatInControl mFocusAmount;
00055 
00056         public:
00057 
00058                 SpectralFocus() 
00059                         : 
00060                         mIn("InSpectrum", this), 
00061                         mOut("OutSpectrum", this),
00062                         mCenterFreqCtl("CenterFreq", this),
00063                         mFocusAmount("Focus Amount", this)
00064                 {
00065                         Configure( SegmentTransformationConfig() );
00066                         SpecTypeFlags flg;
00067                         flg.bMagPhase = 1;
00068                         flg.bMagPhaseBPF = 1;
00069                         mBPFSpectrum.SetType(flg);
00070                         mFlag.bMagPhase = 0;
00071                         mFlag.bMagPhaseBPF = true;
00072                 }
00073 
00074                 ~SpectralFocus() {}
00075                 
00076                 virtual bool InitControls()
00077                 { 
00078                         mCenterFreqCtl.DoControl(1000);
00079                         mFocusAmount.DoControl(100);
00080 
00081                         return true;
00082                 }
00083                 
00084                 bool Do(const Frame& in, Frame& out)
00085                 {
00086                         return Do(in.GetSpectrum(), 
00087                                 out.GetSpectrum());
00088                 }
00089         
00090                 bool Do(const Spectrum& inpeaks,Spectrum& out);
00091 
00092                 bool Do()
00093                 {
00094                         bool result = Do(mIn.GetData(), mOut.GetData());
00095                         mIn.Consume();
00096                         mOut.Produce();
00097                         return result;  
00098                 }
00099 
00100         private:
00101                 Spectrum mBPFSpectrum;
00102                 SpecTypeFlags mFlag;
00103         };              
00104 }       //namespace CLAM
00105 
00106 #endif // _SpectralFocus_
00107 
Generated by  doxygen 1.6.3