Mercurial > hg > svcore
comparison data/fft/FFTMemoryCache.cpp @ 408:115f60df1e4d
* Speed up spectrogram painting by releasing mutex in FFTDataServer
while calculating data prior to writing it, and by adding whole-column
value query methods to FFT objects
* Add paint cache to Thumbwheel -- repaints of this widget were slowing
down the whole spectrogram repaint
* More uses of MutexLocker (named and with debug) and more profile
points
* Make startup much quicker some of the time, with OSC server in place
author | Chris Cannam |
---|---|
date | Thu, 08 May 2008 14:46:22 +0000 |
parents | 7cc6b7b0d819 |
children | 3cc4b7cd2aa5 |
comparison
equal
deleted
inserted
replaced
407:88ad01799040 | 408:115f60df1e4d |
---|---|
63 } | 63 } |
64 | 64 |
65 void | 65 void |
66 FFTMemoryCache::resize(size_t width, size_t height) | 66 FFTMemoryCache::resize(size_t width, size_t height) |
67 { | 67 { |
68 Profiler profiler("FFTMemoryCache::resize"); | |
69 | |
68 #ifdef DEBUG_FFT_MEMORY_CACHE | 70 #ifdef DEBUG_FFT_MEMORY_CACHE |
69 std::cerr << "FFTMemoryCache[" << this << "]::resize(" << width << "x" << height << " = " << width*height << ")" << std::endl; | 71 std::cerr << "FFTMemoryCache[" << this << "]::resize(" << width << "x" << height << " = " << width*height << ")" << std::endl; |
70 #endif | 72 #endif |
71 | 73 |
72 if (m_width == width && m_height == height) return; | 74 if (m_width == width && m_height == height) return; |
180 } | 182 } |
181 | 183 |
182 void | 184 void |
183 FFTMemoryCache::setColumnAt(size_t x, float *mags, float *phases, float factor) | 185 FFTMemoryCache::setColumnAt(size_t x, float *mags, float *phases, float factor) |
184 { | 186 { |
187 Profiler profiler("FFTMemoryCache::setColumnAt: from polar"); | |
188 | |
185 setNormalizationFactor(x, factor); | 189 setNormalizationFactor(x, factor); |
186 | 190 |
187 if (m_storageType == Rectangular) { | 191 if (m_storageType == Rectangular) { |
192 Profiler subprof("FFTMemoryCache::setColumnAt: polar to cart"); | |
188 for (size_t y = 0; y < m_height; ++y) { | 193 for (size_t y = 0; y < m_height; ++y) { |
189 m_freal[x][y] = mags[y] * cosf(phases[y]); | 194 m_freal[x][y] = mags[y] * cosf(phases[y]); |
190 m_fimag[x][y] = mags[y] * sinf(phases[y]); | 195 m_fimag[x][y] = mags[y] * sinf(phases[y]); |
191 } | 196 } |
192 } else { | 197 } else { |
200 } | 205 } |
201 | 206 |
202 void | 207 void |
203 FFTMemoryCache::setColumnAt(size_t x, float *reals, float *imags) | 208 FFTMemoryCache::setColumnAt(size_t x, float *reals, float *imags) |
204 { | 209 { |
210 Profiler profiler("FFTMemoryCache::setColumnAt: from cart"); | |
211 | |
205 float max = 0.0; | 212 float max = 0.0; |
206 | 213 |
207 switch (m_storageType) { | 214 switch (m_storageType) { |
208 | 215 |
209 case Rectangular: | 216 case Rectangular: |
215 } | 222 } |
216 break; | 223 break; |
217 | 224 |
218 case Compact: | 225 case Compact: |
219 case Polar: | 226 case Polar: |
227 { | |
228 Profiler subprof("FFTMemoryCache::setColumnAt: cart to polar"); | |
220 for (size_t y = 0; y < m_height; ++y) { | 229 for (size_t y = 0; y < m_height; ++y) { |
221 float mag = sqrtf(reals[y] * reals[y] + imags[y] * imags[y]); | 230 float mag = sqrtf(reals[y] * reals[y] + imags[y] * imags[y]); |
222 float phase = atan2f(imags[y], reals[y]); | 231 float phase = atan2f(imags[y], reals[y]); |
223 phase = princargf(phase); | |
224 reals[y] = mag; | 232 reals[y] = mag; |
225 imags[y] = phase; | 233 imags[y] = phase; |
226 if (mag > max) max = mag; | 234 if (mag > max) max = mag; |
227 } | 235 } |
228 break; | 236 break; |
237 } | |
229 }; | 238 }; |
230 | 239 |
231 if (m_storageType == Rectangular) { | 240 if (m_storageType == Rectangular) { |
232 m_factor[x] = max; | 241 m_factor[x] = max; |
233 m_colset.set(x); | 242 m_colset.set(x); |