SpectrumAdder2.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_ADDER2_
00023 #define _SPECTRUM_ADDER2_
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 SpecAdder2Config: public ProcessingConfig
00035         {
00036         public:
00037                 DYNAMIC_TYPE_USING_INTERFACE (SpecAdder2Config, 0,ProcessingConfig);
00038         };
00039 
00073         class SpectrumAdder2: public Processing {
00074                 SpecAdder2Config mConfig;
00075 
00077                 int mSize;
00078 
00079                 InPort<Spectrum> mIn1;
00080                 InPort<Spectrum> mIn2;
00081                 OutPort<Spectrum> mOut;
00082 
00084                 typedef enum {
00085                         // Type states in with the same attribute is used for all
00086                         // of the inputs and the outputs (it may or may not be
00087                         // present; in the second case it will be added at Do(...)
00088                         // time.
00089                         SMagPhase, SComplex, SPolar,
00090 
00091                         // BPF output sum
00092                         SBPF,
00093 
00094                         // Type states with only a BPF attribute in one of the
00095                         // inputs, other type in the other input and the
00096                         // output. The non-BPF attribute may or may not be
00097                         // instantiated. In the second case it will be added at
00098                         // Do(...) time.
00099 
00100                         SBPFMagPhase, SBPFComplex, SBPFPolar, SMagPhaseBPF,
00101                         SComplexBPF, SPolarBPF,
00102 
00103                         // State in which nothing is known about prototypes.
00104                         SOther
00105                 } PrototypeState;
00106 
00108                 typedef enum { Slinlin, Sloglog, Slinlog, Sloglin} ScaleState;
00109 
00111                 PrototypeState mProtoState;
00113                 ScaleState mScaleState;
00114 
00115 
00117                 std::string NewUniqueName();
00118 
00119                 const char *GetClassName() const {return "SpectrumAdder2";}
00120 
00121 
00125                 bool ConcreteConfigure(const ProcessingConfig&);
00126 
00127         public:
00128                 SpectrumAdder2();
00129 
00130                 SpectrumAdder2(const SpecAdder2Config &c);
00131 
00132                 ~SpectrumAdder2() {};
00133 
00134                 const ProcessingConfig &GetConfig() const { return mConfig;}
00135 
00136                 bool Do(void);
00137 
00138                 bool Do(Spectrum& in1, Spectrum& in2, Spectrum& out);
00139 
00140                 // Port interfaces.
00141 
00148                 bool SetPrototypes(const Spectrum& in1,const Spectrum& in2,const Spectrum& out);
00149 
00150                 bool SetPrototypes();
00151 
00152                 bool UnsetPrototypes();
00153 
00154                 bool MayDisableExecution() const {return true;}
00155 
00156         private:
00157 
00161                 inline void Add(Spectrum& in1, Spectrum& in2, Spectrum& out);
00162 
00163                 // Adder methods for optimized configurations of the inputs/output
00164 
00165                 // Direct sums
00166                 inline void AddMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out);
00167                 inline void AddMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00168                 inline void AddMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00169                 inline void AddMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00170                 inline void AddComplex(Spectrum& in1, Spectrum& in2, Spectrum& out);
00171                 inline void AddComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00172                 inline void AddComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00173                 inline void AddComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00174                 inline void AddPolar(Spectrum& in1, Spectrum& in2, Spectrum& out);
00175                 inline void AddPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00176                 inline void AddPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00177                 inline void AddPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00178                 // BPF Adder
00179                 inline void AddBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00180                 // Adding BPFs to non-BPFs.
00181                 inline void AddBPFLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00182                 inline void AddBPFLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00183                 inline void AddBPFLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00184                 inline void AddBPFMagPhase(Spectrum& in1, Spectrum& in2, Spectrum& out);
00185                 inline void AddMagPhaseBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00186                 inline void AddBPFMagPhaseLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00187                 inline void AddBPFMagPhaseLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00188                 inline void AddBPFMagPhaseLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00189                 inline void AddBPFMagPhaseLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00190                 inline void AddBPFComplex(Spectrum& in1, Spectrum& in2, Spectrum& out);
00191                 inline void AddComplexBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00192                 inline void AddBPFComplexLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00193                 inline void AddBPFComplexLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00194                 inline void AddBPFComplexLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00195                 inline void AddBPFComplexLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00196                 inline void AddBPFPolar(Spectrum& in1, Spectrum& in2, Spectrum& out);
00197                 inline void AddPolarBPF(Spectrum& in1, Spectrum& in2, Spectrum& out);
00198                 inline void AddBPFPolarLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00199                 inline void AddBPFPolarLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00200                 inline void AddBPFPolarLinLog(Spectrum& in1, Spectrum& in2, Spectrum& out);
00201                 inline void AddBPFPolarLogLin(Spectrum& in1, Spectrum& in2, Spectrum& out);
00202 
00203         };
00204 
00205 }
00206 
00207 #endif // _SPECTRUM_ADDER_
00208 
Generated by  doxygen 1.6.3