CLAM-Development  1.4.0
SpectralFocus.hxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 
23 #ifndef _SpectralFocus_
24 #define _SpectralFocus_
25 
28 #include "Frame.hxx"
29 #include "InPort.hxx"
30 #include "OutPort.hxx"
31 #include "InControl.hxx"
32 #include "FrameTransformation.hxx"
35 #include "Spectrum.hxx"
36 #include "SpecTypeFlags.hxx"
37 
38 
39 namespace CLAM{
40 
45  class SpectralFocus: public FrameTransformationTmpl<Spectrum>
46  {
47 
48  const char *GetClassName() const {return "SpectralFocus";}
49 
50  InPort<Spectrum> mIn;
51  OutPort<Spectrum> mOut;
52 
53  FloatInControl mCenterFreqCtl;
54  FloatInControl mFocusAmount;
55 
56  public:
57 
59  :
60  mIn("InSpectrum", this),
61  mOut("OutSpectrum", this),
62  mCenterFreqCtl("CenterFreq", this),
63  mFocusAmount("Focus Amount", this)
64  {
66  SpecTypeFlags flg;
67  flg.bMagPhase = 1;
68  flg.bMagPhaseBPF = 1;
69  mBPFSpectrum.SetType(flg);
70  mFlag.bMagPhase = 0;
71  mFlag.bMagPhaseBPF = true;
72  }
73 
75 
76  virtual bool InitControls()
77  {
78  mCenterFreqCtl.DoControl(1000);
79  mFocusAmount.DoControl(100);
80 
81  return true;
82  }
83 
84  bool Do(const Frame& in, Frame& out)
85  {
86  return Do(in.GetSpectrum(),
87  out.GetSpectrum());
88  }
89 
90  bool Do(const Spectrum& inpeaks,Spectrum& out);
91 
92  bool Do()
93  {
94  bool result = Do(mIn.GetData(), mOut.GetData());
95  mIn.Consume();
96  mOut.Produce();
97  return result;
98  }
99 
100  private:
101  Spectrum mBPFSpectrum;
102  SpecTypeFlags mFlag;
103  };
104 } //namespace CLAM
105 
106 #endif // _SpectralFocus_
107