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_InterpolateER2_ 00023 #define _SPECTRUM_InterpolateER2_ 00024 00025 #include "Processing.hxx" 00026 #include "DynamicType.hxx" 00027 #include "InPort.hxx" 00028 #include "OutPort.hxx" 00029 #include "Spectrum.hxx" 00030 #include "InControl.hxx" 00031 00032 namespace CLAM { 00033 00034 00035 class SpecInterpConfig: public ProcessingConfig 00036 { 00037 public: 00038 DYNAMIC_TYPE_USING_INTERFACE (SpecInterpConfig, 1,ProcessingConfig); 00039 DYN_ATTRIBUTE(0, public, TData, InterpolationFactor); 00040 protected: 00041 void DefaultInit(); 00042 00043 }; 00044 00078 class SpectrumInterpolator: public Processing { 00079 00080 typedef InControlTmpl<SpectrumInterpolator> SpectrumInterpolatorCtl; 00081 00082 SpecInterpConfig mConfig; 00083 00085 int mSize; 00086 00087 InPort<Spectrum> mIn1; 00088 InPort<Spectrum> mIn2; 00089 OutPort<Spectrum> mOut; 00090 00092 typedef enum { 00093 // Type states in with the same attribute is used for all 00094 // of the inputs and the outputs (it may or may not be 00095 // present; in the second case it will be Interpolateed at Do(...) 00096 // time. 00097 SMagPhase, SComplex, SPolar, 00098 00099 // BPF output sum 00100 SBPF, 00101 00102 // Type states with only a BPF attribute in one of the 00103 // inputs, other type in the other input and the 00104 // output. The non-BPF attribute may or may not be 00105 // instantiated. In the second case it will be Interpolateed at 00106 // Do(...) time. 00107 00108 SBPFMagPhase, SBPFComplex, SBPFPolar, SMagPhaseBPF, 00109 SComplexBPF, SPolarBPF, 00110 00111 // State in which nothing is known about prototypes. 00112 SOther 00113 } PrototypeState; 00114 00116 typedef enum { Slinlin, Sloglog, Slinlog, Sloglin} ScaleState; 00117 00119 PrototypeState mProtoState; 00121 ScaleState mScaleState; 00122 00123 00124 const char *GetClassName() const {return "SpectrumInterpolator";} 00125 00126 00130 bool ConcreteConfigure(const ProcessingConfig&); 00131 00132 public: 00133 SpectrumInterpolator(); 00134 00135 SpectrumInterpolator(const SpecInterpConfig &c); 00136 00137 ~SpectrumInterpolator() {}; 00138 00139 const ProcessingConfig &GetConfig() const { return mConfig;} 00140 00141 bool Do(void); 00142 00143 // FIXME bool Do(const Spectrum& in1, const Spectrum& in2, Spectrum& out); 00144 bool Do(Spectrum& in1, Spectrum& in2, Spectrum& out); 00145 00146 // Port interfaces. 00147 00154 bool SetPrototypes(const Spectrum& in1,const Spectrum& in2,const Spectrum& out); 00155 00156 bool SetPrototypes(); 00157 00158 bool UnsetPrototypes(); 00159 00160 bool MayDisableExecution() const {return true;} 00161 00163 SpectrumInterpolatorCtl mInterpolationFactorCtl; 00164 00165 private: 00166 00170 inline void Interpolate(Spectrum& in1, Spectrum& in2, Spectrum& out); 00171 00172 // Interpolateer methods for optimized configurations of the inputs/output 00173 00174 // Direct sums 00175 inline void InterpolateMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out); 00176 inline void InterpolateMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00177 inline void InterpolateMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00178 inline void InterpolateMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00179 inline void InterpolateComplex(Spectrum& in1, Spectrum& in2, Spectrum& out); 00180 inline void InterpolateComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00181 inline void InterpolateComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00182 inline void InterpolateComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00183 inline void InterpolatePolar(Spectrum& in1, Spectrum& in2, Spectrum& out); 00184 inline void InterpolatePolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00185 inline void InterpolatePolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00186 inline void InterpolatePolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00187 // BPF Interpolateer 00188 inline void InterpolateBPF(Spectrum& in1, Spectrum& in2, Spectrum& out); 00189 // Interpolateing BPFs to non-BPFs. 00190 inline void InterpolateBPFLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00191 inline void InterpolateBPFLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00192 inline void InterpolateBPFLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00193 inline void InterpolateBPFMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out); 00194 inline void InterpolateMagPhaseBPF(Spectrum& in1, Spectrum& in2, Spectrum& out); 00195 inline void InterpolateBPFMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00196 inline void InterpolateBPFMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00197 inline void InterpolateBPFMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00198 inline void InterpolateBPFMagPhaseLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00199 inline void InterpolateBPFComplex(Spectrum& in1, Spectrum& in2, Spectrum& out); 00200 inline void InterpolateComplexBPF(Spectrum& in1, Spectrum& in2, Spectrum& out); 00201 inline void InterpolateBPFComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00202 inline void InterpolateBPFComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00203 inline void InterpolateBPFComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00204 inline void InterpolateBPFComplexLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00205 inline void InterpolateBPFPolar(Spectrum& in1, Spectrum& in2, Spectrum& out); 00206 inline void InterpolatePolarBPF(Spectrum& in1, Spectrum& in2, Spectrum& out); 00207 inline void InterpolateBPFPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00208 inline void InterpolateBPFPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00209 inline void InterpolateBPFPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out); 00210 inline void InterpolateBPFPolarLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out); 00211 00212 }; 00213 00214 } 00215 00216 #endif // _SPECTRUM_InterpolateER_ 00217