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_ADDER_ 00023 #define _SPECTRUM_ADDER_ 00024 00025 #include "Processing.hxx" 00026 #include "DynamicType.hxx" 00027 #include "InPort.hxx" 00028 #include "OutPort.hxx" 00029 00030 #include "Spectrum.hxx" 00031 00032 namespace CLAM { 00033 00034 00035 class SpecAdderConfig: public ProcessingConfig 00036 { 00037 public: 00038 DYNAMIC_TYPE_USING_INTERFACE (SpecAdderConfig, 1,ProcessingConfig); 00039 DYN_ATTRIBUTE (0, public, int, NInputs); 00040 protected: 00041 void DefaultInit(); 00042 00043 }; 00044 00076 class SpectrumAdder: public Processing { 00077 SpecAdderConfig mConfig; 00078 00080 int mSize; 00081 00083 int mNInputs; 00084 00088 InPort<Spectrum> **mInputs; 00089 00092 Complex **complex_bufs; 00093 Polar **polar_bufs; 00094 TData **mag_bufs; 00095 TData **phase_bufs; 00096 bool *remove; 00097 00098 OutPort<Spectrum> mOut; 00099 00101 typedef enum { 00102 // Type states in with the same attribute is used for all 00103 // of the inputs and the outputs (it may or may not be 00104 // present; in the second case it will be added at Do(...) 00105 // time. 00106 SMagPhase, SComplex, SPolar, 00107 00108 // State when any of the inputs has only a BPF instantiated. 00109 ShasBPF, 00110 00111 // State in which nothing is known about prototypes. 00112 SOther 00113 } PrototypeState; 00114 00116 typedef enum { Slin, Slog} ScaleState; 00117 00119 PrototypeState mProtoState; 00121 ScaleState mScaleState; 00122 00124 std::string NewUniqueName(); 00125 00126 const char *GetClassName() const {return "SpectrumAdder";} 00127 00131 bool ConcreteConfigure(const ProcessingConfig&); 00132 00133 public: 00134 SpectrumAdder(); 00135 00136 SpectrumAdder(const SpecAdderConfig &c); 00137 00138 ~SpectrumAdder(); 00139 00140 const ProcessingConfig &GetConfig() const { return mConfig;} 00141 00142 bool Do(void); 00143 00144 bool Do(Spectrum **inputs, Spectrum& out); 00145 00146 00147 00154 bool SetPrototypes(Spectrum **inputs,const Spectrum& out); 00155 00156 bool SetPrototypes(); 00157 00158 bool UnsetPrototypes(); 00159 00160 bool MayDisableExecution() const {return true;} 00161 00162 private: 00163 00167 inline void Add(Spectrum **inputs, Spectrum& out); 00168 00169 // Adder methods for optimized configurations of the inputs/output 00170 00171 // Direct sums 00172 inline void AddMagPhase(Spectrum **inputs, Spectrum& out); 00173 inline void AddMagPhaseLin(Spectrum **inputs, Spectrum& out); 00174 inline void AddMagPhaseLog(Spectrum **inputs, Spectrum& out); 00175 inline void AddComplex(Spectrum **inputs, Spectrum& out); 00176 inline void AddComplexLin(Spectrum **inputs, Spectrum& out); 00177 inline void AddComplexLog(Spectrum **inputs, Spectrum& out); 00178 inline void AddPolar(Spectrum **inputs, Spectrum& out); 00179 inline void AddPolarLin(Spectrum **inputs, Spectrum& out); 00180 inline void AddPolarLog(Spectrum **inputs, Spectrum& out); 00181 }; 00182 00183 } 00184 00185 #endif // _SPECTRUM_ADDER_ 00186