Mercurial > hg > qm-vamp-plugins
comparison plugins/AdaptiveSpectrogram.cpp @ 106:35f2138c6891
* Update to new FFT api
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Wed, 13 May 2009 09:19:30 +0000 |
parents | abbc482aaad2 |
children | 0dd97d053053 |
comparison
equal
deleted
inserted
replaced
105:abbc482aaad2 | 106:35f2138c6891 |
---|---|
40 for (int i = 0; i < m_cutThreads.size(); ++i) { | 40 for (int i = 0; i < m_cutThreads.size(); ++i) { |
41 delete m_cutThreads[i]; | 41 delete m_cutThreads[i]; |
42 } | 42 } |
43 m_cutThreads.clear(); | 43 m_cutThreads.clear(); |
44 | 44 |
45 for (int i = 0; i < m_fftThreads.size(); ++i) { | 45 for (FFTMap::iterator i = m_fftThreads.begin(); i != m_fftThreads.end(); ++i) { |
46 delete m_fftThreads[i]; | 46 delete i->second; |
47 } | 47 } |
48 m_fftThreads.clear(); | 48 m_fftThreads.clear(); |
49 } | 49 } |
50 | 50 |
51 string | 51 string |
100 AdaptiveSpectrogram::initialise(size_t channels, size_t stepSize, size_t blockSize) | 100 AdaptiveSpectrogram::initialise(size_t channels, size_t stepSize, size_t blockSize) |
101 { | 101 { |
102 if (channels < getMinChannelCount() || | 102 if (channels < getMinChannelCount() || |
103 channels > getMaxChannelCount()) return false; | 103 channels > getMaxChannelCount()) return false; |
104 | 104 |
105 while (m_fftThreads.size() < (m_n + 1)) { | |
106 m_fftThreads.push_back(new FFTThread()); | |
107 } | |
108 | |
109 return true; | 105 return true; |
110 } | 106 } |
111 | 107 |
112 void | 108 void |
113 AdaptiveSpectrogram::reset() | 109 AdaptiveSpectrogram::reset() |
227 | 223 |
228 int w = minwid; | 224 int w = minwid; |
229 int index = 0; | 225 int index = 0; |
230 | 226 |
231 while (w <= maxwid) { | 227 while (w <= maxwid) { |
232 m_fftThreads[index]->calculate(inputBuffers[0], s, index, w, maxwid); | 228 if (m_fftThreads.find(w) == m_fftThreads.end()) { |
229 m_fftThreads[w] = new FFTThread(w); | |
230 } | |
231 m_fftThreads[w]->calculate(inputBuffers[0], s, index, maxwid); | |
233 w *= 2; | 232 w *= 2; |
234 ++index; | 233 ++index; |
235 } | 234 } |
236 | 235 |
237 w = minwid; | 236 w = minwid; |
238 index = 0; | |
239 | |
240 while (w <= maxwid) { | 237 while (w <= maxwid) { |
241 m_fftThreads[index]->await(); | 238 m_fftThreads[w]->await(); |
242 w *= 2; | 239 w *= 2; |
243 ++index; | |
244 } | 240 } |
245 | 241 |
246 m_first = true;//!!! | 242 m_first = true;//!!! |
247 | 243 |
248 Cutting *cutting = cut(s, maxwid/2, 0, 0, maxwid/2); | 244 Cutting *cutting = cut(s, maxwid/2, 0, 0, maxwid/2); |