CLAM-Development  1.4.0
3BandGate.hxx
Go to the documentation of this file.
1 
2 /*
3  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
4  * UNIVERSITAT POMPEU FABRA
5  *
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  *
21  */
22 
23 
24 #ifndef _ThreeBandGate_
25 #define _ThreeBandGate_
26 
27 #include "InPort.hxx"
28 #include "OutPort.hxx"
29 #include "InControl.hxx"
30 #include "Frame.hxx"
31 #include "FrameTransformation.hxx"
33 
34 namespace CLAM{
35 
36  class ThreeBandGate: public FrameTransformationTmpl<Spectrum>
37  {
38  InPort<Spectrum> mIn;
39  OutPort<Spectrum> mOut;
40 
41  FloatInControl mLowCutoffFreqCtl;
42  FloatInControl mHighCutoffFreqCtl;
43  FloatInControl mLowThresholdCtl;
44  FloatInControl mMidThresholdCtl;
45  FloatInControl mHighThresholdCtl;
46  public:
47  const char* GetClassName() const
48  {
49  return "ThreeBandGate";
50  }
51 
53  :
54  mIn("In Spectrum", this),
55  mOut("Out Spectrum", this) ,
56  mLowCutoffFreqCtl("LowCutoff", this),
57  mHighCutoffFreqCtl("HighCutoff", this),
58  mLowThresholdCtl("LowThreshold", this),
59  mMidThresholdCtl("MidThreshold", this),
60  mHighThresholdCtl("HighThreshold", this)
61  {
63  }
64 
66 
67  virtual bool InitControls()
68  {
69  mLowCutoffFreqCtl.DoControl(1000);
70  mHighCutoffFreqCtl.DoControl(5000);
71  mLowThresholdCtl.DoControl(-60);
72  mMidThresholdCtl.DoControl(-60);
73  mHighThresholdCtl.DoControl(-60);
74 
75  return true;
76  }
77 
78  bool Do(const Frame& in, Frame& out)
79  {
80  return Do(in.GetSpectrum(),
81  out.GetSpectrum());
82  }
83 
84  bool Do(const Spectrum& in, Spectrum& out);
85 
86  bool Do()
87  {
88  bool result = Do(mIn.GetData(), mOut.GetData());
89  mIn.Consume();
90  mOut.Produce();
91  return result;
92  }
93  };
94 };//namespace CLAM
95 
96 #endif // _ThreeBandGate_