CLAM-Development  1.4.0
SpectralSpread.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 _SpectralSpread_
24 #define _SpectralSpread_
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 SpectralSpread: public FrameTransformationTmpl<Spectrum>
46  {
47 
48  const char *GetClassName() const {return "SpectralSpread";}
49 
50  InPort<Spectrum> mIn;
51  OutPort<Spectrum> mOut;
52 
53  FloatInControl mCenterFreqCtl;
54  public:
55 
57  :
58  mIn( "InSpectrum", this),
59  mOut( "OutSpectrum", this),
60  mCenterFreqCtl("CenterFreq", this)
61  {
63  SpecTypeFlags flg;
64  flg.bMagPhase = 1;
65  flg.bMagPhaseBPF = 1;
66  mBPFSpectrum.SetType(flg);
67  mFlag.bMagPhase = 0;
68  mFlag.bMagPhaseBPF = true;
69  }
70 
72 
73  virtual bool InitControls()
74  {
75  mCenterFreqCtl.DoControl(1000);
76  mAmount.DoControl(100);
77 
78  return true;
79  }
80 
81  bool Do(const Frame& in, Frame& out)
82  {
83  return Do(in.GetSpectrum(),
84  out.GetSpectrum());
85  }
86 
87  bool Do(const Spectrum& inpeaks,Spectrum& out);
88 
89  bool Do()
90  {
91  bool result = Do(mIn.GetData(), mOut.GetData());
92  mIn.Consume();
93  mOut.Produce();
94  return result;
95  }
96 
97  private:
98  Spectrum mBPFSpectrum;
99  SpecTypeFlags mFlag;
100  };
101 } //namespace CLAM
102 
103 #endif // _SpectralSpread_
104