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 _SpectralSynthesis_ 00023 #define _SpectralSynthesis_ 00024 00025 //uncomment this if you want to use Ooura fft instead of fftw 00026 //#define CLAM_OOURA 00027 00028 #include "ProcessingComposite.hxx" 00029 00030 #include "Array.hxx" 00031 #include "Audio.hxx" 00032 #include "DataTypes.hxx" 00033 #include "DynamicType.hxx" 00034 #include "Err.hxx" 00035 #include "IFFT.hxx" 00036 00037 #include "Frame.hxx" 00038 #include "Segment.hxx" 00039 #include "InControl.hxx" 00040 #include "Spectrum.hxx" 00041 #include "ProcessingData.hxx" 00042 #include "ProcessingDataConfig.hxx" 00043 #include "Processing.hxx" 00044 #include "AudioMultiplier.hxx" 00045 #include "WindowGenerator.hxx" 00046 #include "OverlapAdd.hxx" 00047 #include "AudioCircularBuffer.hxx" 00048 #include "CircularShift.hxx" 00049 00050 00051 00052 #include "SpectralAnalysis.hxx" 00053 00054 #include <stdlib.h> 00055 00056 #include "SpectralSynthesisConfig.hxx" 00057 00058 #include "AudioOutPort.hxx" 00059 #include "InPort.hxx" 00060 00061 namespace CLAM { 00062 00063 00064 00065 00066 /* SpectralSynthesisConfig moved to SpectralSynthesisConfig.hxx */ 00067 00068 00072 class SpectralSynthesis : public ProcessingComposite { 00073 00074 private: 00075 // Configuration data 00076 SpectralSynthesisConfig mConfig; 00077 00078 00079 //internal Processing Data 00080 Audio mAudio0,mAudio1, mAudio2,mAudio3; 00081 //Spectrum Spec; 00082 Audio mSynthWindow; 00083 00084 00085 //internal Processing Objects 00086 WindowGenerator mPO_AnalWindowGen; 00087 WindowGenerator mPO_SynthWindowGen; 00088 IFFT mPO_IFFT; 00089 AudioMultiplier mPO_AudioProduct; 00090 CircularShift mPO_CircularShift; 00091 00092 // And the interfaces with the outside world. 00093 00094 00095 // Internal convenience methods. 00096 00097 void AttachChildren(); 00098 bool ConfigureChildren(); 00099 void ConfigureData(); 00100 00101 00103 bool ConcreteConfigure(const ProcessingConfig&); 00104 00105 TInt32 CalculatePowerOfTwo(TInt32 size); 00106 00107 public: 00108 SpectralSynthesis(const SpectralSynthesisConfig& cfg); 00109 SpectralSynthesis(); 00110 ~SpectralSynthesis(); 00111 00112 // Processing Object compliance methods. 00113 const char *GetClassName() const {return "SpectralSynthesis";} 00114 00115 00116 const ProcessingConfig &GetConfig() const {return mConfig;} 00117 00119 bool Do(void); 00120 00122 bool Do(Spectrum& in, Audio &out); 00123 00124 bool Do(Frame& in); 00125 bool Do(Segment& in); 00126 00127 00129 InPort<Spectrum> mInput; 00130 AudioOutPort mOutput; 00131 00132 00133 }; 00134 00135 } //end of namespace 00136 00137 #endif //_SpectralSynthesis_ 00138