CLAM-Development
1.1
|
00001 /* 00002 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 #ifndef _SPECTRUM_Substracter2_ 00023 #define _SPECTRUM_Substracter2_ 00024 00025 #include "Processing.hxx" 00026 #include "DynamicType.hxx" 00027 #include "InPort.hxx" 00028 #include "OutPort.hxx" 00029 #include "Spectrum.hxx" 00030 00031 namespace CLAM { 00032 00033 00034 class SpecSubstracter2Config: public ProcessingConfig 00035 { 00036 public: 00037 DYNAMIC_TYPE_USING_INTERFACE (SpecSubstracter2Config, 0,ProcessingConfig); 00038 }; 00039 00060 class SpectrumSubstracter2: public Processing { 00061 SpecSubstracter2Config mConfig; 00062 00064 int mSize; 00065 00066 InPort<Spectrum> mIn1; 00067 InPort<Spectrum> mIn2; 00068 OutPort<Spectrum> mOut; 00069 00071 typedef enum { 00072 // Type states in with the same attribute is used for all 00073 // of the inputs and the outputs (it may or may not be 00074 // present; in the second case it will be Substracted at Do(...) 00075 // time. 00076 SMagPhase, SComplex, SPolar, 00077 00078 // BPF output sum 00079 SBPF, 00080 00081 // Type states with only a BPF attribute in one of the 00082 // inputs, other type in the other input and the 00083 // output. The non-BPF attribute may or may not be 00084 // instantiated. In the second case it will be Substracted at 00085 // Do(...) time. 00086 00087 SBPFMagPhase, SBPFComplex, SBPFPolar, SMagPhaseBPF, 00088 SComplexBPF, SPolarBPF, 00089 00090 // State in which nothing is known about prototypes. 00091 SOther 00092 } PrototypeState; 00093 00095 typedef enum { Slinlin, Sloglog, Slinlog, Sloglin} ScaleState; 00096 00098 PrototypeState mProtoState; 00100 ScaleState mScaleState; 00101 00102 00104 std::string NewUniqueName(); 00105 00106 const char *GetClassName() const {return "SpectrumSubstracter2";} 00107 00108 00112 bool ConcreteConfigure(const ProcessingConfig&); 00113 00114 public: 00115 SpectrumSubstracter2(); 00116 00117 SpectrumSubstracter2(const SpecSubstracter2Config &c); 00118 00119 ~SpectrumSubstracter2() {}; 00120 00121 const ProcessingConfig &GetConfig() const { return mConfig;} 00122 00123 bool Do(void); 00124 00125 bool Do(Spectrum& in1, Spectrum& in2, Spectrum& out); 00126 00127 // Port interfaces. 00128 00135 bool SetPrototypes(const Spectrum& in1,const Spectrum& in2,const Spectrum& out); 00136 00137 bool SetPrototypes(); 00138 00139 bool UnsetPrototypes(); 00140 00141 bool MayDisableExecution() const {return true;} 00142 00143 private: 00144 00148 inline void Substract(Spectrum& in1, Spectrum& in2, Spectrum& out); 00149 00150 // Substracter methods for optimized configurations of the inputs/output 00151 00152 // Direct sums 00153 inline void SubstractMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out); 00154 inline void SubstractMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00155 inline void SubstractMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00156 inline void SubstractMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00157 inline void SubstractComplex(Spectrum& in1, Spectrum& in2, Spectrum& out); 00158 inline void SubstractComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00159 inline void SubstractComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00160 inline void SubstractComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00161 inline void SubstractPolar(Spectrum& in1, Spectrum& in2, Spectrum& out); 00162 inline void SubstractPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00163 inline void SubstractPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00164 inline void SubstractPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00165 // BPF Substracter 00166 inline void SubstractBPF(Spectrum& in1, Spectrum& in2, Spectrum& out); 00167 // Substracting BPFs to non-BPFs. 00168 inline void SubstractBPFLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00169 inline void SubstractBPFLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00170 inline void SubstractBPFLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00171 inline void SubstractBPFMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out); 00172 inline void SubstractMagPhaseBPF(Spectrum& in1, Spectrum& in2, Spectrum& out); 00173 inline void SubstractBPFMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00174 inline void SubstractBPFMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00175 inline void SubstractBPFMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00176 inline void SubstractBPFMagPhaseLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00177 inline void SubstractBPFComplex(Spectrum& in1, Spectrum& in2, Spectrum& out); 00178 inline void SubstractComplexBPF(Spectrum& in1, Spectrum& in2, Spectrum& out); 00179 inline void SubstractBPFComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00180 inline void SubstractBPFComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00181 inline void SubstractBPFComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00182 inline void SubstractBPFComplexLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00183 inline void SubstractBPFPolar(Spectrum& in1, Spectrum& in2, Spectrum& out); 00184 inline void SubstractPolarBPF(Spectrum& in1, Spectrum& in2, Spectrum& out); 00185 inline void SubstractBPFPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00186 inline void SubstractBPFPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00187 inline void SubstractBPFPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00188 inline void SubstractBPFPolarLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00189 00190 }; 00191 00192 } 00193 00194 #endif // _SPECTRUM_Substracter_ 00195