CLAM-Development  1.4.0
3BandFilter.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 _ThreeBandFilter_
25 #define _ThreeBandFilter_
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 
50  class ThreeBandFilter: public FrameTransformationTmpl<Spectrum>
51  {
52  InPort<Spectrum> mIn;
53  OutPort<Spectrum> mOut;
54 
55  FloatInControl mLowCutoffFreqCtl;
56  FloatInControl mHighCutoffFreqCtl;
57  FloatInControl mLowGainCtl;
58  FloatInControl mMidGainCtl;
59  FloatInControl mHighGainCtl;
60  public:
61  const char* GetClassName() const
62  {
63  return "ThreeBandFilter";
64  }
65 
67  : mIn("In Spectrum", this)
68  , mOut("Out Spectrum", this)
69  , mLowCutoffFreqCtl("LowCutoff", this)
70  , mHighCutoffFreqCtl("HighCutoff", this)
71  , mLowGainCtl("LowGain", this)
72  , mMidGainCtl("MidGain", this)
73  , mHighGainCtl("HighGain", this)
74  {
76  }
77 
79 
80  bool ConcreteConfigure( const ProcessingConfig& config )
81  {
82  mLowCutoffFreqCtl.SetBounds(0.,1000000.);
83  mLowCutoffFreqCtl.DoControl(1000.);
84 
85  mHighCutoffFreqCtl.SetBounds(0.,1000000.);
86  mHighCutoffFreqCtl.DoControl(5000.);
87 
88  mLowGainCtl.SetBounds(0,100);
89  mLowGainCtl.DoControl(0);
90 
91  mMidGainCtl.SetBounds(0,100);
92  mMidGainCtl.DoControl(0);
93 
94  mHighGainCtl.SetBounds(0,100);
95  mHighGainCtl.DoControl(0);
96  return true;
97  }
98 
99  bool Do(const Frame& in, Frame& out)
100  {
101  return Do(in.GetSpectrum(),
102  out.GetSpectrum());
103  }
104 
105  bool Do(const Spectrum& in, Spectrum& out);
106 
107  bool Do()
108  {
109  bool result = Do(mIn.GetData(), mOut.GetData());
110  mIn.Consume();
111  mOut.Produce();
112  return result;
113  }
114  };
115 };//namespace CLAM
116 
117 #endif // _ThreeBandFilter_