00001 /* 00002 * Copyright (c) 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 _SynthSineSpectrum_ 00023 #define _SynthSineSpectrum_ 00024 #include <typeinfo> 00025 00026 #define MAINLOBE_TABLE_SIZE 4096 // Tablesize of the mainlobe of a BH92 Window 00027 00028 #include "Err.hxx" 00029 #include "WindowGenerator.hxx" 00030 #include "AudioMultiplier.hxx" 00031 #include "Spectrum.hxx" 00032 #include "SpectralPeakArray.hxx" 00033 #include "Complex.hxx" 00034 #include "Processing.hxx" 00035 #include "SynthSineSpectrumConfig.hxx" 00036 #include "InPort.hxx" 00037 #include "OutPort.hxx" 00038 00039 namespace CLAM{ 00040 00044 /* SynthSineSpectrumConfig moved to SynthSineSpectrumConfig.hxx */ 00045 00046 00047 00057 class SynthSineSpectrum:public Processing 00058 { 00059 00060 InPort<SpectralPeakArray> mInput; 00061 OutPort<Spectrum> mOutput; 00062 00063 public: 00064 /* constructor/destructor */ 00065 SynthSineSpectrum(); 00066 SynthSineSpectrum(SynthSineSpectrumConfig& cfg); 00067 ~SynthSineSpectrum(); 00068 const char * GetClassName() const {return "SynthSineSpectrum";} 00069 00070 /* public member functions */ 00071 bool Do(const SpectralPeakArray& peakArray,Spectrum& residualSpectrumOut, double gain=1.0); 00072 bool Do(void); 00073 00075 bool ConcreteConfigure(const ProcessingConfig&); 00076 00077 const ProcessingConfig &GetConfig() const {return mConfig;} 00078 00079 private: 00080 /* private member functions */ 00081 void InitSynthSpec(TSize size); 00082 00083 void FillSynthSineSpectrum(const SpectralPeakArray& peakArray,double gain = 1.0); 00084 00085 /* private configuration*/ 00086 SynthSineSpectrumConfig mConfig; 00087 00088 /* window table generation */ 00089 WindowGenerator mWndGen; 00090 //Spectrum mBlackHarris92TransMainLobe; 00091 static double mBlackHarris92TransMainLobe[]; 00092 00093 /* internal buffer for synthesized sinusoidal spectrum */ 00094 Array< Complex > mSynthSineSpectrum; 00095 }; 00096 };// CLAM namespace 00097 #endif 00098