CLAM-Development  1.4.0
SpectrumInterpolator.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 #ifndef _SPECTRUM_InterpolateER2_
23 #define _SPECTRUM_InterpolateER2_
24 
25 #include "Processing.hxx"
26 #include "DynamicType.hxx"
27 #include "InPort.hxx"
28 #include "OutPort.hxx"
29 #include "Spectrum.hxx"
30 #include "InControl.hxx"
31 
32 namespace CLAM {
33 
34 
36  {
37  public:
39  DYN_ATTRIBUTE(0, public, TData, InterpolationFactor);
40  protected:
41  void DefaultInit();
42 
43  };
44 
79  {
80  typedef SpecInterpConfig Config;
81  Config mConfig;
82 
84  int mSize;
85 
86  InPort<Spectrum> mIn1;
87  InPort<Spectrum> mIn2;
88  OutPort<Spectrum> mOut;
89 
91  typedef enum {
92  // Type states in with the same attribute is used for all
93  // of the inputs and the outputs (it may or may not be
94  // present; in the second case it will be Interpolateed at Do(...)
95  // time.
96  SMagPhase, SComplex, SPolar,
97 
98  // BPF output sum
99  SBPF,
100 
101  // Type states with only a BPF attribute in one of the
102  // inputs, other type in the other input and the
103  // output. The non-BPF attribute may or may not be
104  // instantiated. In the second case it will be Interpolateed at
105  // Do(...) time.
106 
107  SBPFMagPhase, SBPFComplex, SBPFPolar, SMagPhaseBPF,
108  SComplexBPF, SPolarBPF,
109 
110  // State in which nothing is known about prototypes.
111  SOther
112  } PrototypeState;
113 
115  typedef enum { Slinlin, Sloglog, Slinlog, Sloglin} ScaleState;
116 
118  PrototypeState mProtoState;
120  ScaleState mScaleState;
121 
122 
123  const char *GetClassName() const {return "SpectrumInterpolator";}
124 
125 
129  bool ConcreteConfigure(const ProcessingConfig&);
130  public:
133  const ProcessingConfig &GetConfig() const { return mConfig;}
134  bool Do(void);
135 
136 // FIXME bool Do(const Spectrum& in1, const Spectrum& in2, Spectrum& out);
137  bool Do(Spectrum& in1, Spectrum& in2, Spectrum& out);
138 
139  // Port interfaces.
140 
147  bool SetPrototypes(const Spectrum& in1,const Spectrum& in2,const Spectrum& out);
148 
149  bool SetPrototypes();
150 
151  bool UnsetPrototypes();
152 
153  bool MayDisableExecution() const {return true;}
154 
157 
158  private:
159 
163  inline void Interpolate(Spectrum& in1, Spectrum& in2, Spectrum& out);
164 
165  // Interpolateer methods for optimized configurations of the inputs/output
166 
167  // Direct sums
168  inline void InterpolateMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out);
169  inline void InterpolateMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
170  inline void InterpolateMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
171  inline void InterpolateMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
172  inline void InterpolateComplex(Spectrum& in1, Spectrum& in2, Spectrum& out);
173  inline void InterpolateComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
174  inline void InterpolateComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
175  inline void InterpolateComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
176  inline void InterpolatePolar(Spectrum& in1, Spectrum& in2, Spectrum& out);
177  inline void InterpolatePolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
178  inline void InterpolatePolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
179  inline void InterpolatePolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
180  // BPF Interpolateer
181  inline void InterpolateBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
182  // Interpolateing BPFs to non-BPFs.
183  inline void InterpolateBPFLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
184  inline void InterpolateBPFLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
185  inline void InterpolateBPFLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
186  inline void InterpolateBPFMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out);
187  inline void InterpolateMagPhaseBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
188  inline void InterpolateBPFMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
189  inline void InterpolateBPFMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
190  inline void InterpolateBPFMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
191  inline void InterpolateBPFMagPhaseLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
192  inline void InterpolateBPFComplex(Spectrum& in1, Spectrum& in2, Spectrum& out);
193  inline void InterpolateComplexBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
194  inline void InterpolateBPFComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
195  inline void InterpolateBPFComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
196  inline void InterpolateBPFComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
197  inline void InterpolateBPFComplexLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
198  inline void InterpolateBPFPolar(Spectrum& in1, Spectrum& in2, Spectrum& out);
199  inline void InterpolatePolarBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
200  inline void InterpolateBPFPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
201  inline void InterpolateBPFPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
202  inline void InterpolateBPFPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
203  inline void InterpolateBPFPolarLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
204 
205  };
206 
207 }
208 
209 #endif // _SPECTRUM_InterpolateER_
210