Mercurial > hg > qm-dsp
comparison dsp/chromagram/ConstantQ.cpp @ 472:73fc1de3254a
Remove unused precalc data
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Thu, 30 May 2019 18:25:58 +0100 |
parents | 8d84e5d16314 |
children | fdaa63607c15 |
comparison
equal
deleted
inserted
replaced
471:e3335cb213da | 472:73fc1de3254a |
---|---|
15 #include "ConstantQ.h" | 15 #include "ConstantQ.h" |
16 #include "dsp/transforms/FFT.h" | 16 #include "dsp/transforms/FFT.h" |
17 | 17 |
18 #include <iostream> | 18 #include <iostream> |
19 | 19 |
20 #ifdef NOT_DEFINED | |
21 // see note in CQprecalc | |
22 | |
23 #include "CQprecalc.cpp" | |
24 | |
25 static bool push_precalculated(int uk, int fftlength, | |
26 std::vector<unsigned> &is, | |
27 std::vector<unsigned> &js, | |
28 std::vector<double> &real, | |
29 std::vector<double> &imag) | |
30 { | |
31 if (uk == 76 && fftlength == 16384) { | |
32 push_76_16384(is, js, real, imag); | |
33 return true; | |
34 } | |
35 if (uk == 144 && fftlength == 4096) { | |
36 push_144_4096(is, js, real, imag); | |
37 return true; | |
38 } | |
39 if (uk == 65 && fftlength == 2048) { | |
40 push_65_2048(is, js, real, imag); | |
41 return true; | |
42 } | |
43 if (uk == 84 && fftlength == 65536) { | |
44 push_84_65536(is, js, real, imag); | |
45 return true; | |
46 } | |
47 return false; | |
48 } | |
49 #endif | |
50 | |
51 //--------------------------------------------------------------------------- | 20 //--------------------------------------------------------------------------- |
52 // nextpow2 returns the smallest integer n such that 2^n >= x. | 21 // nextpow2 returns the smallest integer n such that 2^n >= x. |
53 static double nextpow2(double x) { | 22 static double nextpow2(double x) { |
54 double y = ceil(log(x)/log(2.0)); | 23 double y = ceil(log(x)/log(2.0)); |
55 return(y); | 24 return(y); |
76 void ConstantQ::sparsekernel() | 45 void ConstantQ::sparsekernel() |
77 { | 46 { |
78 // std::cerr << "ConstantQ: initialising sparse kernel, uK = " << m_uK << ", FFTLength = " << m_FFTLength << "..."; | 47 // std::cerr << "ConstantQ: initialising sparse kernel, uK = " << m_uK << ", FFTLength = " << m_FFTLength << "..."; |
79 | 48 |
80 SparseKernel *sk = new SparseKernel(); | 49 SparseKernel *sk = new SparseKernel(); |
81 | |
82 #ifdef NOT_DEFINED | |
83 if (push_precalculated(m_uK, m_FFTLength, | |
84 sk->is, sk->js, sk->real, sk->imag)) { | |
85 // std::cerr << "using precalculated kernel" << std::endl; | |
86 m_sparseKernel = sk; | |
87 return; | |
88 } | |
89 #endif | |
90 | 50 |
91 //generates spectral kernel matrix (upside down?) | 51 //generates spectral kernel matrix (upside down?) |
92 // initialise temporal kernel with zeros, twice length to deal w. complex numbers | 52 // initialise temporal kernel with zeros, twice length to deal w. complex numbers |
93 | 53 |
94 double* hammingWindowRe = new double [ m_FFTLength ]; | 54 double* hammingWindowRe = new double [ m_FFTLength ]; |
176 delete [] hammingWindowRe; | 136 delete [] hammingWindowRe; |
177 delete [] hammingWindowIm; | 137 delete [] hammingWindowIm; |
178 delete [] transfHammingWindowRe; | 138 delete [] transfHammingWindowRe; |
179 delete [] transfHammingWindowIm; | 139 delete [] transfHammingWindowIm; |
180 | 140 |
181 /* | |
182 using std::cout; | |
183 using std::endl; | |
184 | |
185 cout.precision(28); | |
186 | |
187 int n = sk->is.size(); | |
188 int w = 8; | |
189 cout << "static unsigned int sk_i_" << m_uK << "_" << m_FFTLength << "[" << n << "] = {" << endl; | |
190 for (int i = 0; i < n; ++i) { | |
191 if (i % w == 0) cout << " "; | |
192 cout << sk->is[i]; | |
193 if (i + 1 < n) cout << ", "; | |
194 if (i % w == w-1) cout << endl; | |
195 }; | |
196 if (n % w != 0) cout << endl; | |
197 cout << "};" << endl; | |
198 | |
199 n = sk->js.size(); | |
200 cout << "static unsigned int sk_j_" << m_uK << "_" << m_FFTLength << "[" << n << "] = {" << endl; | |
201 for (int i = 0; i < n; ++i) { | |
202 if (i % w == 0) cout << " "; | |
203 cout << sk->js[i]; | |
204 if (i + 1 < n) cout << ", "; | |
205 if (i % w == w-1) cout << endl; | |
206 }; | |
207 if (n % w != 0) cout << endl; | |
208 cout << "};" << endl; | |
209 | |
210 w = 2; | |
211 n = sk->real.size(); | |
212 cout << "static double sk_real_" << m_uK << "_" << m_FFTLength << "[" << n << "] = {" << endl; | |
213 for (int i = 0; i < n; ++i) { | |
214 if (i % w == 0) cout << " "; | |
215 cout << sk->real[i]; | |
216 if (i + 1 < n) cout << ", "; | |
217 if (i % w == w-1) cout << endl; | |
218 }; | |
219 if (n % w != 0) cout << endl; | |
220 cout << "};" << endl; | |
221 | |
222 n = sk->imag.size(); | |
223 cout << "static double sk_imag_" << m_uK << "_" << m_FFTLength << "[" << n << "] = {" << endl; | |
224 for (int i = 0; i < n; ++i) { | |
225 if (i % w == 0) cout << " "; | |
226 cout << sk->imag[i]; | |
227 if (i + 1 < n) cout << ", "; | |
228 if (i % w == w-1) cout << endl; | |
229 }; | |
230 if (n % w != 0) cout << endl; | |
231 cout << "};" << endl; | |
232 | |
233 cout << "static void push_" << m_uK << "_" << m_FFTLength << "(vector<unsigned int> &is, vector<unsigned int> &js, vector<double> &real, vector<double> &imag)" << endl; | |
234 cout << "{\n is.reserve(" << n << ");\n"; | |
235 cout << " js.reserve(" << n << ");\n"; | |
236 cout << " real.reserve(" << n << ");\n"; | |
237 cout << " imag.reserve(" << n << ");\n"; | |
238 cout << " for (int i = 0; i < " << n << "; ++i) {" << endl; | |
239 cout << " is.push_back(sk_i_" << m_uK << "_" << m_FFTLength << "[i]);" << endl; | |
240 cout << " js.push_back(sk_j_" << m_uK << "_" << m_FFTLength << "[i]);" << endl; | |
241 cout << " real.push_back(sk_real_" << m_uK << "_" << m_FFTLength << "[i]);" << endl; | |
242 cout << " imag.push_back(sk_imag_" << m_uK << "_" << m_FFTLength << "[i]);" << endl; | |
243 cout << " }" << endl; | |
244 cout << "}" << endl; | |
245 */ | |
246 // std::cerr << "done\n -> is: " << sk->is.size() << ", js: " << sk->js.size() << ", reals: " << sk->real.size() << ", imags: " << sk->imag.size() << std::endl; | 141 // std::cerr << "done\n -> is: " << sk->is.size() << ", js: " << sk->js.size() << ", reals: " << sk->real.size() << ", imags: " << sk->imag.size() << std::endl; |
247 | 142 |
248 m_sparseKernel = sk; | 143 m_sparseKernel = sk; |
249 return; | 144 return; |
250 } | 145 } |