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 _SMSSynthesis_ 00023 #define _SMSSynthesis_ 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 00057 class SMSSynthesis : public ProcessingComposite { 00058 00059 private: 00060 // Configuration data 00061 SMSSynthesisConfig mConfig; 00062 00063 int mCurrentFrame; 00064 00065 //internal Processing Objects 00070 SpectralSynthesis mSinSpectralSynthesis; 00071 SpectralSynthesis mResSpectralSynthesis; 00072 SpectralSynthesis mSpectralSynthesis; 00073 SynthSineSpectrum mSynthSineSpectrum; 00074 PhaseManagement mPhaseMan; 00075 SpectrumAdder2 mSpectrumAdder; 00076 00077 OverlapAdd mOverlapAddSin; 00078 OverlapAdd mOverlapAddRes; 00079 OverlapAdd mOverlapAddGlobal; 00080 00081 00082 00084 Audio mAudioFrame; 00085 00086 // Internal convenience methods. 00087 00088 void AttachChildren(); 00089 bool ConfigureChildren(); 00090 void ConfigureData(); 00091 00092 00094 bool ConcreteConfigure(const ProcessingConfig&); 00095 00096 TInt32 CalculatePowerOfTwo(TInt32 size); 00097 00098 public: 00099 SMSSynthesis(const SMSSynthesisConfig& cfg); 00100 SMSSynthesis(); 00101 ~SMSSynthesis(); 00102 00103 // Processing Object compliance methods. 00104 00105 const char *GetClassName() const {return "SMSSynthesis";} 00106 00107 00108 const ProcessingConfig &GetConfig() const {return mConfig;} 00109 00111 bool Do(void); 00112 00114 bool SinusoidalSynthesis(const SpectralPeakArray& in,Spectrum& outSpec,Audio& outAudio); 00116 bool SinusoidalSynthesis(const SpectralPeakArray& in,Audio& out); 00117 00121 bool Do(SpectralPeakArray& inputSinusoidalPeaks, Spectrum& inputResidualSpectrum, 00122 Spectrum& outputSinusoidalSpectrum, Spectrum& outputSpectrum, 00123 Audio& outputAudio, Audio& outputSinusoidalAudio, Audio& outputResidualAudio); 00124 00128 bool Do(SpectralPeakArray& inputSinusoidalPeaks, Spectrum& inputResidualSpectrum, 00129 Spectrum& outputSinusoidalSpectrum, Spectrum& outputSpectrum, 00130 Audio& outputAudio); 00131 00136 bool Do(SpectralPeakArray& inputSinusoidal, Spectrum& inputSpectrum, 00137 Audio& outputAudio, Audio& outputSinusoidal, Audio& outputResidual); 00139 bool Do(Frame& in); 00149 bool Do(Frame& in, bool isSynthesizeSinusoidsAndResidual); 00152 bool Do(Segment& in); 00153 protected: 00154 00155 void InitFrame(Frame& in); 00156 00158 InPort<SpectralPeakArray> mInputSinSpectralPeaks; 00159 InPort<Spectrum> mInputResSpectrum; 00160 OutPort<Spectrum> mOutputSinSpectrum; 00161 OutPort<Spectrum> mOutputSpectrum; 00162 AudioOutPort mOutputAudio; 00163 AudioOutPort mOutputResAudio; 00164 AudioOutPort mOutputSinAudio; 00165 00166 public: 00167 //Controls 00168 InControlTmpl<SMSSynthesis> mCurrentTimeControl; 00169 InControlTmpl<SMSSynthesis> mCurrentPitch; 00170 00171 00172 }; 00173 00174 }; //end of namespace 00175 00176 #endif //_SMSSynthesis_ 00177