SMSSynthesisConfig.cxx

Go to the documentation of this file.
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 #include "SMSSynthesisConfig.hxx"
00023 
00024 namespace CLAM
00025 {
00026 
00027 void SMSSynthesisConfig::DefaultInit()
00028 {
00029         AddAll();
00030         UpdateData();
00031         DefaultValues();        
00032 }
00033 
00034 void SMSSynthesisConfig::DefaultValues()
00035 {
00036         SetSamplingRate(44100);
00037 
00039 //      GetSpectralSynth().SetAnalWindowSize(513);
00040 //      TODO PA remove (hack for anal-synth in streaming)
00041 //      GetSpectralSynth().SetAnalWindowSize(1025);
00042 
00043         
00044         GetSpectralSynth().SetAnalWindowType(EWindowType::eBlackmanHarris92);
00045         GetSpectralSynth().GetAnalWindowGenerator().SetInvert(true);
00046 
00047         
00049 //      SetHopSize((GetAnalWindowSize()i-1)/2);
00050 //      TODO PA remove hack...
00051         SetAnalWindowSize(1025);        
00052         SetHopSize(512);        // was 256
00053         SetFrameSize(512);      // was 256
00054 
00055         /* Default frame size is 256*/
00056 //      SetFrameSize(GetHopSize());
00057 
00058 
00059 }
00060 
00061 void SMSSynthesisConfig::SetSpectrumSize(TSize specSize)
00062 {
00063         GetSynthSineSpectrum().SetSpectrumSize(specSize);
00064 }
00065 
00066 TSize SMSSynthesisConfig::GetSpectrumSize() const
00067 {
00068         return GetSynthSineSpectrum().GetSpectrumSize();
00069 }
00070 
00072 void SMSSynthesisConfig::SetAnalWindowSize(TSize w)
00073 {
00074         CLAM_ASSERT(w%2==1,"Window size must be odd");
00075         GetSpectralSynth().SetAnalWindowSize(w);
00076         
00077         GetSynthSineSpectrum().SetSpectrumSize(GetSpectralSynth().GetIFFT().GetAudioSize()/2+1);
00078 /*      TODO:This condition should be checked!!
00079         if(w<2*GetHopSize()+1)
00080                 SetHopSize((w-1)/2);*/
00081 }
00082 
00083 TSize SMSSynthesisConfig::GetAnalWindowSize() const
00084 {
00085         return GetSpectralSynth().GetAnalWindowSize();
00086 }
00087 
00089 void SMSSynthesisConfig::SetAnalWindowType(const EWindowType& t)
00090 {
00091         GetSpectralSynth().SetAnalWindowType(t);
00092 }
00093 
00094 const EWindowType& SMSSynthesisConfig::GetAnalWindowType() const
00095 {
00096         return GetSpectralSynth().GetAnalWindowType();
00097 }
00098 
00099 
00100 void SMSSynthesisConfig::SetSynthWindowSize(TSize w)
00101 {
00102         CLAM_ASSERT(w%2==1,"Window size must be odd");
00103         GetSpectralSynth().SetSynthWindowSize(w);
00104 }
00105 
00106 TSize SMSSynthesisConfig::GetSynthWindowSize() const
00107 {
00108         return GetSpectralSynth().GetSynthWindowSize();
00109 }
00110 
00112 void SMSSynthesisConfig::SetHopSize(TSize h)
00113 {
00114 
00115         //CLAM_ASSERT(GetSynthWindowSize()>=2*h, "SMSSynthesisConfig::SetHopSize: Hop Size is too large compared to window size");
00116         GetSpectralSynth().SetHopSize(h);
00117 }
00118 
00119 void SMSSynthesisConfig::SetFrameSize(TSize f)
00120 {
00121         GetOverlapAddSin().SetFrameSize(f);
00122         GetOverlapAddRes().SetFrameSize(f);
00123         GetOverlapAddGlobal().SetFrameSize(f);
00124 }
00125 
00126 TSize SMSSynthesisConfig::GetFrameSize()
00127 {
00128         return GetOverlapAddSin().GetFrameSize();
00129 }
00130 
00131 
00132 TSize SMSSynthesisConfig::GetHopSize() const
00133 {
00134         return GetSpectralSynth().GetHopSize();
00135 }
00136 
00138 void SMSSynthesisConfig::SetSamplingRate(TData sr)
00139 {
00140         GetSynthSineSpectrum().SetSamplingRate(sr);
00141         GetPhaseMan().SetSamplingRate(sr);
00142         GetSpectralSynth().SetSamplingRate(sr);
00143 }
00144 
00145 TData SMSSynthesisConfig::GetSamplingRate() const
00146 {
00147         return GetSynthSineSpectrum().GetSamplingRate();
00148 }
00149 
00150 
00151 TInt32 SMSSynthesisConfig::PowerOfTwo(TInt32 size)
00152 {
00153         int tmp = size;
00154         int outputSize = 1;
00155         while (tmp) 
00156         {
00157                 outputSize=outputSize << 1;
00158                 tmp=tmp >> 1;
00159         }
00160         if(outputSize == size << 1)
00161                 outputSize = outputSize >> 1;
00162         return outputSize;
00163 }
00164 
00165 
00166 
00167 
00168 } // namespace CLAM
00169 
Generated by  doxygen 1.6.3