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 _SinusoidalSynthesis_ 00023 #define _SinusoidalSynthesis_ 00024 00025 #include "SMSSynthesisConfig.hxx" 00026 #include "ProcessingComposite.hxx" 00027 00028 #include "Array.hxx" 00029 #include "Audio.hxx" 00030 #include "DataTypes.hxx" 00031 #include "DynamicType.hxx" 00032 #include "Err.hxx" 00033 #include "Frame.hxx" 00034 #include "Segment.hxx" 00035 #include "InControl.hxx" 00036 #include "Spectrum.hxx" 00037 #include "ProcessingData.hxx" 00038 #include "ProcessingDataConfig.hxx" 00039 #include "Processing.hxx" 00040 #include "SynthSineSpectrum.hxx" 00041 #include "PhaseManagement.hxx" 00042 #include "SpectralSynthesis.hxx" 00043 #include "SpectrumAdder2.hxx" 00044 #include "SMSAnalysis.hxx" 00045 00046 #include "InPort.hxx" 00047 #include "OutPort.hxx" 00048 #include "AudioOutPort.hxx" 00049 00050 #include <stdlib.h> 00051 00052 namespace CLAM { 00053 00063 class SinusoidalSynthesis : public ProcessingComposite { 00064 00065 private: 00066 // Configuration data 00067 typedef SMSSynthesisConfig Config; 00068 Config mConfig; 00069 00070 int mCurrentFrame; 00071 00072 //internal Processing Objects 00073 SpectralSynthesis mSinSpectralSynthesis; 00074 SynthSineSpectrum mSynthSineSpectrum; 00075 PhaseManagement mPhaseMan; 00076 SpectrumAdder2 mSpectrumAdder; 00077 00078 OverlapAdd mOverlapAddSin; 00079 00080 00081 00083 Audio mAudioFrame; 00084 00085 // Internal convenience methods. 00086 00087 void AttachChildren(); 00088 bool ConfigureChildren(); 00089 void ConfigureData(); 00090 00091 00093 bool ConcreteConfigure(const ProcessingConfig&); 00094 00095 TInt32 CalculatePowerOfTwo(TInt32 size); 00096 00097 public: 00098 SinusoidalSynthesis(const Config& cfg = Config()); 00099 ~SinusoidalSynthesis(); 00100 00101 // Processing Object compliance methods. 00102 00103 const char *GetClassName() const {return "SinusoidalSynthesis";} 00104 00105 00106 const ProcessingConfig &GetConfig() const {return mConfig;} 00107 00109 bool Do(void); 00110 00114 bool Do(SpectralPeakArray& inputSinusoidalPeaks, 00115 Spectrum& outputSpectrum, 00116 Audio& outputAudio); 00117 00118 00123 bool Do(SpectralPeakArray& inputSinusoidal, Audio& outputAudio); 00125 bool Do(Frame& in); 00128 bool Do(Segment& in); 00129 protected: 00130 00131 void InitFrame(Frame& in); 00132 00134 InPort<SpectralPeakArray> mInputSinSpectralPeaks; 00135 OutPort<Spectrum> mOutputSinSpectrum; 00136 OutPort<Spectrum> mOutputSpectrum; 00137 AudioOutPort mOutputAudio; 00138 00139 public: 00140 //Controls 00141 FloatInControl mCurrentTimeControl; 00142 FloatInControl mCurrentPitch; 00143 00144 00145 }; 00146 00147 }; //end of namespace 00148 00149 #endif //_SinusoidalSynthesis_ 00150