SpectrumInterpolator.hxx

Go to the documentation of this file.
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 SpecInterpConfig Config;
00081                 Config mConfig;
00082 
00084                 int mSize;
00085 
00086                 InPort<Spectrum> mIn1;
00087                 InPort<Spectrum> mIn2;
00088                 OutPort<Spectrum> mOut;
00089 
00091                 typedef enum {
00092                         // Type states in with the same attribute is used for all
00093                         // of the inputs and the outputs (it may or may not be
00094                         // present; in the second case it will be Interpolateed at Do(...)
00095                         // time.
00096                         SMagPhase, SComplex, SPolar,
00097 
00098                         // BPF output sum
00099                         SBPF,
00100 
00101                         // Type states with only a BPF attribute in one of the
00102                         // inputs, other type in the other input and the
00103                         // output. The non-BPF attribute may or may not be
00104                         // instantiated. In the second case it will be Interpolateed at
00105                         // Do(...) time.
00106 
00107                         SBPFMagPhase, SBPFComplex, SBPFPolar, SMagPhaseBPF,
00108                         SComplexBPF, SPolarBPF,
00109 
00110                         // State in which nothing is known about prototypes.
00111                         SOther
00112                 } PrototypeState;
00113 
00115                 typedef enum { Slinlin, Sloglog, Slinlog, Sloglin} ScaleState;
00116 
00118                 PrototypeState mProtoState;
00120                 ScaleState mScaleState;
00121 
00122 
00123                 const char *GetClassName() const {return "SpectrumInterpolator";}
00124 
00125 
00129                 bool ConcreteConfigure(const ProcessingConfig&);
00130         public:
00131                 SpectrumInterpolator(const SpecInterpConfig &c=Config());
00132                 ~SpectrumInterpolator() {};
00133                 const ProcessingConfig &GetConfig() const { return mConfig;}
00134                 bool Do(void);
00135 
00136 //              FIXME bool Do(const Spectrum& in1, const Spectrum& in2, Spectrum& out);
00137                 bool Do(Spectrum& in1, Spectrum& in2, Spectrum& out);
00138 
00139                 // Port interfaces.
00140 
00147                 bool SetPrototypes(const Spectrum& in1,const Spectrum& in2,const Spectrum& out);
00148 
00149                 bool SetPrototypes();
00150 
00151                 bool UnsetPrototypes();
00152 
00153                 bool MayDisableExecution() const {return true;}
00154 
00156                 FloatInControl mInterpolationFactorCtl;
00157 
00158         private:
00159 
00163                 inline void Interpolate(Spectrum& in1, Spectrum& in2, Spectrum& out);
00164 
00165                 // Interpolateer methods for optimized configurations of the inputs/output
00166 
00167                 // Direct sums
00168                 inline void InterpolateMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out);
00169                 inline void InterpolateMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00170                 inline void InterpolateMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00171                 inline void InterpolateMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00172                 inline void InterpolateComplex(Spectrum& in1, Spectrum& in2, Spectrum& out);
00173                 inline void InterpolateComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00174                 inline void InterpolateComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00175                 inline void InterpolateComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00176                 inline void InterpolatePolar(Spectrum& in1, Spectrum& in2, Spectrum& out);
00177                 inline void InterpolatePolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00178                 inline void InterpolatePolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00179                 inline void InterpolatePolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00180                 // BPF Interpolateer
00181                 inline void InterpolateBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00182                 // Interpolateing BPFs to non-BPFs.
00183                 inline void InterpolateBPFLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00184                 inline void InterpolateBPFLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00185                 inline void InterpolateBPFLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00186                 inline void InterpolateBPFMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out);
00187                 inline void InterpolateMagPhaseBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00188                 inline void InterpolateBPFMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00189                 inline void InterpolateBPFMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00190                 inline void InterpolateBPFMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00191                 inline void InterpolateBPFMagPhaseLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00192                 inline void InterpolateBPFComplex(Spectrum& in1, Spectrum& in2, Spectrum& out);
00193                 inline void InterpolateComplexBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00194                 inline void InterpolateBPFComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00195                 inline void InterpolateBPFComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00196                 inline void InterpolateBPFComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00197                 inline void InterpolateBPFComplexLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00198                 inline void InterpolateBPFPolar(Spectrum& in1, Spectrum& in2, Spectrum& out);
00199                 inline void InterpolatePolarBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00200                 inline void InterpolateBPFPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00201                 inline void InterpolateBPFPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00202                 inline void InterpolateBPFPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00203                 inline void InterpolateBPFPolarLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00204 
00205         };
00206 
00207 }
00208 
00209 #endif // _SPECTRUM_InterpolateER_
00210 
Generated by  doxygen 1.6.3