CLAM-Development  1.4.0
SMSAnalysisConfig.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 "SMSAnalysisConfig.hxx"
23 
24 namespace CLAM
25 {
26 
27 void SMSAnalysisConfig::DefaultInit()
28 {
29  AddAll();
30  UpdateData();
31  DefaultValues();
32 }
33 
34 void SMSAnalysisConfig::DefaultValues()
35 {
36 
37  SetprSamplingRate(44100);
38 
39  GetSinSpectralAnalysis().SetWindowType(EWindowType::eHamming);
40  GetResSpectralAnalysis().SetWindowType(EWindowType::eBlackmanHarris92);
41 
42  GetPeakDetect().SetMagThreshold(-60);
43 
44  //TODO PA remove these values (aiming to analy-synt streaming) ?
45  SetSinWindowSize(2049);
46  SetHopSize(512);
48  SetResWindowSize(1025);
49 
50 }
51 
52 
54 {
55  GetSinSpectralAnalysis().SetWindowSize(w);
56 }
57 
59 {
60  return GetSinSpectralAnalysis().GetWindowSize();
61 }
62 
65 {
66  GetSinSpectralAnalysis().SetWindowType(t);
67 }
68 
70 {
71  return GetSinSpectralAnalysis().GetWindowType();
72 }
73 
76 {
77  GetSinSpectralAnalysis().SetZeroPadding(z);
78 }
79 
81 {
82  return GetSinSpectralAnalysis().GetZeroPadding();
83 }
84 
86 {
87  GetSinSpectralAnalysis().SetHopSize(h);
88  GetResSpectralAnalysis().SetHopSize(h);
89 }
90 
92 {
93  return GetSinSpectralAnalysis().GetHopSize();
94 }
95 
96 /*****Configuration for residual component analysis*****/
97 
99 {
100  GetResSpectralAnalysis().SetWindowSize(w);
101  GetSynthSineSpectrum().SetSpectrumSize(GetResSpectralAnalysis().GetFFT().GetAudioSize()/2+1);
102 }
103 
105 {
106  return GetResSpectralAnalysis().GetWindowSize();
107 }
108 
111 {
112  GetResSpectralAnalysis().SetWindowType(t);
113 }
114 
116 {
117  return GetResSpectralAnalysis().GetWindowType();
118 }
119 
122 {
123  GetResSpectralAnalysis().SetZeroPadding(z);
124 }
125 
127 {
128  return GetResSpectralAnalysis().GetZeroPadding();
129 }
130 
133 {
134  SetprSamplingRate( int(sr) );
135  GetSinSpectralAnalysis().SetSamplingRate(sr);
136  GetResSpectralAnalysis().SetSamplingRate(sr);
137  GetSynthSineSpectrum().SetSamplingRate(sr);
138 }
139 
141 {
142  return TData(GetprSamplingRate());
143 }
144 
145 
146 TInt32 SMSAnalysisConfig::PowerOfTwo(TInt32 size)
147 {
148  int tmp = size;
149  int outputSize = 1;
150  while (tmp)
151  {
152  outputSize=outputSize << 1;
153  tmp=tmp >> 1;
154  }
155  if(outputSize == size << 1)
156  outputSize = outputSize >> 1;
157  return outputSize;
158 }
159 
161 {
162  TSize largerWindowSize;
163  if(GetSinWindowSize()>GetResWindowSize()) largerWindowSize=GetSinWindowSize();
164  else largerWindowSize=GetResWindowSize();
165 
166  return -(largerWindowSize-1)/2+GetHopSize();
167 }
168 
170 {
172  else return (GetResWindowSize()-1)/GetHopSize();
173 }
174 
175 
176 } // namespace CLAM
177