CLAM-Development  1.4.0
SpectralAnalysisConfig.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 
23 #include "CLAM_Math.hxx"
24 
25 #include <iostream>
26 
27 namespace CLAM
28 {
29 
30 void SpectralAnalysisConfig::DefaultInit()
31 {
32 
33  AddAll();
34  UpdateData();
35  DefaultValues();
36 }
37 
38 void SpectralAnalysisConfig::DefaultValues()
39 {
40 
41  SetprSamplingRate(44100);
43  SetprZeroPadding(0);
44 
45  SetprHopSize(0);//for preventing reading uninitialized memory
46 
48  SetWindowSize(1025);
50 
52  SetHopSize((GetWindowSize()-1)/2);
53 
54  GetCircularShift().SetAmount(-(GetWindowSize()-1)/2);
55 
56 }
57 
58 
60 {
61  CLAM_ASSERT(w%2==1,"Window size must be odd");
62  SetprWindowSize(w);
63  GetWindowGenerator().SetSize(w);
64  SetprFFTSize(nextPowerOfTwo( int( (w-1)*CLAM_pow(TData(2),TData(GetZeroPadding())) ) ) );
65  GetCircularShift().SetAmount(-((w-1)/TData(2)));
66  GetFFT().SetAudioSize(GetprFFTSize());
67  if(w<2*GetHopSize()+1)
68  SetHopSize((w-1)/2);
69 
70 }
71 
73 {
74  return GetWindowGenerator().GetSize();
75 }
76 
79 {
80  SetprWindowType(t);
81  GetWindowGenerator().SetType(t);
82 }
83 
85 {
86  return GetWindowGenerator().GetType();
87 }
88 
91 {
92  SetprZeroPadding(z);
93  SetprFFTSize(nextPowerOfTwo( int( (GetWindowSize()-1) * CLAM_pow(TData(2),TData(GetZeroPadding())) ) ) );
94  GetFFT().SetAudioSize(GetprFFTSize());
95 }
96 
98 {
99  return GetprZeroPadding();
100 }
101 
102 
103 
105 {
106  SetprHopSize(h);
107 }
108 
110 {
111  return GetprHopSize();
112 }
113 
116 {
117  SetprSamplingRate(int(sr));
120 }
121 
123 {
124  return GetprSamplingRate();
125 }
126 
127 
129 {
130 
131  int zp = GetprZeroPadding();
132  int ws = GetprWindowSize();
133  SetSamplingRate(GetprSamplingRate());
134 
135  SetZeroPadding(zp);
136 
137  SetWindowSize(ws);
138  SetWindowType(GetprWindowType());
139 
140  SetHopSize(GetprHopSize());
141 }
142 
143 } // namespace CLAM
144