CLAM-Development  1.4.0
SpectrumSubstracter2.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_Substracter2_
23 #define _SPECTRUM_Substracter2_
24 
25 #include "Processing.hxx"
26 #include "DynamicType.hxx"
27 #include "InPort.hxx"
28 #include "OutPort.hxx"
29 #include "Spectrum.hxx"
30 
31 namespace CLAM {
32 
33 
35  {
36  public:
38  };
39 
61  SpecSubstracter2Config mConfig;
62 
64  int mSize;
65 
66  InPort<Spectrum> mIn1;
67  InPort<Spectrum> mIn2;
68  OutPort<Spectrum> mOut;
69 
71  typedef enum {
72  // Type states in with the same attribute is used for all
73  // of the inputs and the outputs (it may or may not be
74  // present; in the second case it will be Substracted at Do(...)
75  // time.
76  SMagPhase, SComplex, SPolar,
77 
78  // BPF output sum
79  SBPF,
80 
81  // Type states with only a BPF attribute in one of the
82  // inputs, other type in the other input and the
83  // output. The non-BPF attribute may or may not be
84  // instantiated. In the second case it will be Substracted at
85  // Do(...) time.
86 
87  SBPFMagPhase, SBPFComplex, SBPFPolar, SMagPhaseBPF,
88  SComplexBPF, SPolarBPF,
89 
90  // State in which nothing is known about prototypes.
91  SOther
92  } PrototypeState;
93 
95  typedef enum { Slinlin, Sloglog, Slinlog, Sloglin} ScaleState;
96 
98  PrototypeState mProtoState;
100  ScaleState mScaleState;
101 
102 
104  std::string NewUniqueName();
105 
106  const char *GetClassName() const {return "SpectrumSubstracter2";}
107 
108 
112  bool ConcreteConfigure(const ProcessingConfig&);
113 
114  public:
116 
118 
120 
121  const ProcessingConfig &GetConfig() const { return mConfig;}
122 
123  bool Do(void);
124 
125  bool Do(Spectrum& in1, Spectrum& in2, Spectrum& out);
126 
127  // Port interfaces.
128 
135  bool SetPrototypes(const Spectrum& in1,const Spectrum& in2,const Spectrum& out);
136 
137  bool SetPrototypes();
138 
139  bool UnsetPrototypes();
140 
141  bool MayDisableExecution() const {return true;}
142 
143  private:
144 
148  inline void Substract(Spectrum& in1, Spectrum& in2, Spectrum& out);
149 
150  // Substracter methods for optimized configurations of the inputs/output
151 
152  // Direct sums
153  inline void SubstractMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out);
154  inline void SubstractMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
155  inline void SubstractMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
156  inline void SubstractMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
157  inline void SubstractComplex(Spectrum& in1, Spectrum& in2, Spectrum& out);
158  inline void SubstractComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
159  inline void SubstractComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
160  inline void SubstractComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
161  inline void SubstractPolar(Spectrum& in1, Spectrum& in2, Spectrum& out);
162  inline void SubstractPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
163  inline void SubstractPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
164  inline void SubstractPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
165  // BPF Substracter
166  inline void SubstractBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
167  // Substracting BPFs to non-BPFs.
168  inline void SubstractBPFLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
169  inline void SubstractBPFLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
170  inline void SubstractBPFLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
171  inline void SubstractBPFMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out);
172  inline void SubstractMagPhaseBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
173  inline void SubstractBPFMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
174  inline void SubstractBPFMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
175  inline void SubstractBPFMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
176  inline void SubstractBPFMagPhaseLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
177  inline void SubstractBPFComplex(Spectrum& in1, Spectrum& in2, Spectrum& out);
178  inline void SubstractComplexBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
179  inline void SubstractBPFComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
180  inline void SubstractBPFComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
181  inline void SubstractBPFComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
182  inline void SubstractBPFComplexLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
183  inline void SubstractBPFPolar(Spectrum& in1, Spectrum& in2, Spectrum& out);
184  inline void SubstractPolarBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
185  inline void SubstractBPFPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
186  inline void SubstractBPFPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
187  inline void SubstractBPFPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
188  inline void SubstractBPFPolarLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
189 
190  };
191 
192 }
193 
194 #endif // _SPECTRUM_Substracter_
195