SpectrumProduct.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_PRODUCT_
00023 #define _SPECTRUM_PRODUCT_
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 
00069         class SpectrumProduct: public Processing 
00070         {
00072                 int mSize;
00073 
00075                 typedef enum {
00076                         // Type states in with the same attribute is used for all
00077                         // of the inputs and the outputs (it may or may not be
00078                         // present; in the second case it will be added at Do(...)
00079                         // time.
00080                         SMagPhase, SComplex, SPolar,
00081 
00082                         // BPF output product
00083                         SBPF,
00084 
00085                         // Type states with only a BPF attribute in one of the
00086                         // inputs, other type in the other input and the
00087                         // output. The non-BPF attribute may or may not be
00088                         // instantiated. In the second case it will be added at
00089                         // Do(...) time.
00090 
00091                         SBPFMagPhase, SBPFComplex, SBPFPolar, SMagPhaseBPF,
00092                         SComplexBPF, SPolarBPF,
00093 
00094                         // State in which nothing is known about prototypes.
00095                         SOther
00096                 } PrototypeState;
00097 
00099                 typedef enum { Slinlin, Sloglog, Slinlog, Sloglin} ScaleState;
00100 
00102                 PrototypeState mProtoState;
00104                 ScaleState mScaleState;
00105 
00106                 const char *GetClassName() const {return "SpectrumProduct";}
00107 
00108         public:
00109 
00110                 InPort<Spectrum> mInput1;
00111                 InPort<Spectrum> mInput2;
00112                 OutPort<Spectrum> mOutput;
00113 
00114                 SpectrumProduct(const Config &c=Config());
00115                 virtual ~SpectrumProduct();
00116 
00117 
00118                 bool Do();
00119 
00120                 bool Do(Spectrum& in1, Spectrum& in2, Spectrum& out);
00121 
00122                 // Port interfaces.
00123 
00130                 bool SetPrototypes(const Spectrum& in1,const Spectrum& in2,const Spectrum& out);
00131 
00132                 bool SetPrototypes();
00133 
00134                 bool UnsetPrototypes();
00135 
00136                 bool MayDisableExecution() const {return true;}
00137 
00138         private:
00139 
00143                 inline void Multiply(Spectrum& in1, Spectrum& in2, Spectrum& out);
00144 
00145                 // Product methods for optimized configurations of the inputs/output
00146 
00147                 // Direct products
00148                 inline void MultiplyMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out);
00149                 inline void MultiplyMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00150                 inline void MultiplyMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00151                 inline void MultiplyMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00152                 inline void MultiplyComplex(Spectrum& in1, Spectrum& in2, Spectrum& out);
00153                 inline void MultiplyComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00154                 inline void MultiplyComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00155                 inline void MultiplyComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00156                 inline void MultiplyPolar(Spectrum& in1, Spectrum& in2, Spectrum& out);
00157                 inline void MultiplyPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00158                 inline void MultiplyPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00159                 inline void MultiplyPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00160                 // BPF Product
00161                 inline void MultiplyBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00162                 // BPF filters application
00163                 inline void MultiplyBPFLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00164                 inline void MultiplyBPFLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00165                 inline void MultiplyBPFLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00166                 inline void MultiplyBPFMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out);
00167                 inline void MultiplyMagPhaseBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00168                 inline void MultiplyBPFMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00169                 inline void MultiplyBPFMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00170                 inline void MultiplyBPFMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00171                 inline void MultiplyBPFMagPhaseLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00172                 inline void MultiplyBPFComplex(Spectrum& in1, Spectrum& in2, Spectrum& out);
00173                 inline void MultiplyComplexBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00174                 inline void MultiplyBPFComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00175                 inline void MultiplyBPFComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00176                 inline void MultiplyBPFComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00177                 inline void MultiplyBPFComplexLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00178                 inline void MultiplyBPFPolar(Spectrum& in1, Spectrum& in2, Spectrum& out);
00179                 inline void MultiplyPolarBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00180                 inline void MultiplyBPFPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00181                 inline void MultiplyBPFPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00182                 inline void MultiplyBPFPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00183                 inline void MultiplyBPFPolarLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00184 
00185         };
00186 
00187 }
00188 
00189 #endif // _SPECTRUM_PRODUCT_
00190 
Generated by  doxygen 1.6.3