CLAM-Development  1.4.0
SMSSynthesisConfig.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
3  * UNIVERSITAT POMPEU FABRA
4  *
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21 
22 #include "SMSSynthesisConfig.hxx"
23 
24 namespace CLAM
25 {
26 
27 void SMSSynthesisConfig::DefaultInit()
28 {
29  AddAll();
30  UpdateData();
31  DefaultValues();
32 }
33 
34 void SMSSynthesisConfig::DefaultValues()
35 {
36  SetSamplingRate(44100);
37 
39 // GetSpectralSynth().SetAnalWindowSize(513);
40 // TODO PA remove (hack for anal-synth in streaming)
41 // GetSpectralSynth().SetAnalWindowSize(1025);
42 
43 
44  GetSpectralSynth().SetAnalWindowType(EWindowType::eBlackmanHarris92);
45  GetSpectralSynth().GetAnalWindowGenerator().SetInvert(true);
46 
47 
49 // SetHopSize((GetAnalWindowSize()i-1)/2);
50 // TODO PA remove hack...
51  SetAnalWindowSize(1025);
52  SetHopSize(512); // was 256
53  SetFrameSize(512); // was 256
54 
55  /* Default frame size is 256*/
56 // SetFrameSize(GetHopSize());
57 
58 
59 }
60 
62 {
63  GetSynthSineSpectrum().SetSpectrumSize(specSize);
64 }
65 
67 {
68  return GetSynthSineSpectrum().GetSpectrumSize();
69 }
70 
73 {
74  CLAM_ASSERT(w%2==1,"Window size must be odd");
75  GetSpectralSynth().SetAnalWindowSize(w);
76 
77  GetSynthSineSpectrum().SetSpectrumSize(GetSpectralSynth().GetIFFT().GetAudioSize()/2+1);
78 /* TODO:This condition should be checked!!
79  if(w<2*GetHopSize()+1)
80  SetHopSize((w-1)/2);*/
81 }
82 
84 {
85  return GetSpectralSynth().GetAnalWindowSize();
86 }
87 
90 {
91  GetSpectralSynth().SetAnalWindowType(t);
92 }
93 
95 {
96  return GetSpectralSynth().GetAnalWindowType();
97 }
98 
99 
101 {
102  CLAM_ASSERT(w%2==1,"Window size must be odd");
103  GetSpectralSynth().SetSynthWindowSize(w);
104 }
105 
107 {
108  return GetSpectralSynth().GetSynthWindowSize();
109 }
110 
113 {
114 
115  //CLAM_ASSERT(GetSynthWindowSize()>=2*h, "SMSSynthesisConfig::SetHopSize: Hop Size is too large compared to window size");
116  GetSpectralSynth().SetHopSize(h);
117 }
118 
120 {
121  GetOverlapAddSin().SetFrameSize(f);
122  GetOverlapAddRes().SetFrameSize(f);
123  GetOverlapAddGlobal().SetFrameSize(f);
124 }
125 
127 {
128  return GetOverlapAddSin().GetFrameSize();
129 }
130 
131 
133 {
134  return GetSpectralSynth().GetHopSize();
135 }
136 
139 {
140  GetSynthSineSpectrum().SetSamplingRate(sr);
141  GetPhaseMan().SetSamplingRate(sr);
142  GetSpectralSynth().SetSamplingRate(sr);
143 }
144 
146 {
147  return GetSynthSineSpectrum().GetSamplingRate();
148 }
149 
150 
151 TInt32 SMSSynthesisConfig::PowerOfTwo(TInt32 size)
152 {
153  int tmp = size;
154  int outputSize = 1;
155  while (tmp)
156  {
157  outputSize=outputSize << 1;
158  tmp=tmp >> 1;
159  }
160  if(outputSize == size << 1)
161  outputSize = outputSize >> 1;
162  return outputSize;
163 }
164 
165 
166 
167 
168 } // namespace CLAM
169