CLAM-Development  1.4.0
SpectralDelay.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 _SpectralDelay_
25 #define _SpectralDelay_
26 
27 #include "InPort.hxx"
28 #include "OutPort.hxx"
29 #include "InControl.hxx"
30 #include "Frame.hxx"
31 #include "FrameTransformation.hxx"
33 #include "TokenDelay.hxx"
34 
35 namespace CLAM{
36 
37  class SpectralDelay: public FrameTransformationTmpl<Spectrum>
38  {
39  InPort<Spectrum> mIn;
40  OutPort<Spectrum> mOut;
41 
42  FloatInControl mLowCutoffFreqCtl;
43  FloatInControl mHighCutoffFreqCtl;
44  FloatInControl mLowDelayCtl;
45  FloatInControl mMidDelayCtl;
46  FloatInControl mHighDelayCtl;
47  public:
48  const char* GetClassName() const
49  {
50  return "SpectralDelay";
51  }
52 
54  :
55  mIn("In Spectrum", this),
56  mOut("Out Spectrum", this) ,
57  mLowCutoffFreqCtl("LowCutoff", this),
58  mHighCutoffFreqCtl("HighCutoff", this),
59  mLowDelayCtl("LowDelay", this),
60  mMidDelayCtl("MidDelay", this),
61  mHighDelayCtl("HighDelay", this)
62  {
64  TokenDelayConfig cfg;
65  cfg.SetDelay(0);
66  cfg.SetMaxDelay(100);
67  mLFDelay.Configure(cfg);
68  mMFDelay.Configure(cfg);
69  mHFDelay.Configure(cfg);
70  }
71 
73 
74  bool ConcreteConfigure( const ProcessingConfig& config )
75  {
76  mLowCutoffFreqCtl.SetBounds(0,1000000);
77  mLowCutoffFreqCtl.DoControl(1000);
78 
79  mHighCutoffFreqCtl.SetBounds(0,1000000);
80  mHighCutoffFreqCtl.DoControl(5000);
81 
82  mLowDelayCtl.SetBounds(0,100);
83  mLowDelayCtl.DoControl(0);
84 
85  mMidDelayCtl.SetBounds(0,100);
86  mMidDelayCtl.DoControl(0);
87 
88  mHighDelayCtl.SetBounds(0,100);
89  mHighDelayCtl.DoControl(0);
90  return true;
91  }
92 
93  bool Do(const Frame& in, Frame& out)
94  {
95  return Do(in.GetSpectrum(),
96  out.GetSpectrum());
97  }
98 
99  bool Do(const Spectrum& in, Spectrum& out);
100 
101  bool Do()
102  {
103  bool result = Do(mIn.GetData(), mOut.GetData());
104  mIn.Consume();
105  mOut.Produce();
106  return result;
107  }
108  private:
109  TokenDelay<Spectrum> mLFDelay;
110  TokenDelay<Spectrum> mMFDelay;
111  TokenDelay<Spectrum> mHFDelay;
112 
113  Spectrum mLFSpectrum;
114  Spectrum mMFSpectrum;
115  Spectrum mHFSpectrum;
116 
117  TSize mFrameSize;
118  };
119 };//namespace CLAM
120 
121 #endif // _SpectralDelay_