CLAM-Development  1.4.0
3BandSpectralAM.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 _ThreeBandAM_
25 #define _ThreeBandAM_
26 
27 #include "InPort.hxx"
28 #include "OutPort.hxx"
29 #include "InControl.hxx"
30 #include "Frame.hxx"
31 #include "FrameTransformation.hxx"
33 #include "SimpleOscillator.hxx"
34 
35 namespace CLAM{
36 
37  class ThreeBandAM: public FrameTransformationTmpl<Spectrum>
38  {
39  InPort<Spectrum> mIn;
40  OutPort<Spectrum> mOut;
41 
42  FloatInControl mLowCutoffFreqCtl;
43  FloatInControl mHighCutoffFreqCtl;
44  FloatInControl mLowPitchCtl;
45  FloatInControl mMidPitchCtl;
46  FloatInControl mHighPitchCtl;
47  FloatInControl mModAmplitudeCtl;
48  public:
49  const char* GetClassName() const
50  {
51  return "ThreeBandAM";
52  }
53 
55  :
56  mIn("In Spectrum", this),
57  mOut("Out Spectrum", this) ,
58  mLowCutoffFreqCtl("LowCutoff", this),
59  mHighCutoffFreqCtl("HighCutoff", this),
60  mLowPitchCtl("LowPitch", this),
61  mMidPitchCtl("MidPitch", this),
62  mHighPitchCtl("HighPitch", this),
63  mModAmplitudeCtl("ModAmp", this)
64  {
66  }
67 
69 
70  virtual bool InitControls()
71  {
72  mLowCutoffFreqCtl.DoControl(1000);
73  mHighCutoffFreqCtl.DoControl(5000);
74  mLowPitchCtl.DoControl(1000);
75  mMidPitchCtl.DoControl(1000);
76  mHighPitchCtl.DoControl(1000);
77  mModAmplitudeCtl.DoControl(1);
78 
79  return true;
80  }
81 
82  bool Do(const Frame& in, Frame& out)
83  {
84  return Do(in.GetSpectrum(),
85  out.GetSpectrum());
86  }
87 
88  bool Do(const Spectrum& in, Spectrum& out);
89 
90  bool Do()
91  {
92  bool result = Do(mIn.GetData(), mOut.GetData());
93  mIn.Consume();
94  mOut.Produce();
95  return result;
96  }
97  private:
98  SimpleOscillator mLFOscillator;
99  SimpleOscillator mMFOscillator;
100  SimpleOscillator mHFOscillator;
101  };
102 };//namespace CLAM
103 
104 #endif // _ThreeBandAM_