comparison data/model/FFTModel.cpp @ 1095:b66734b5f806 simple-fft-model

Fix to fft cache
author Chris Cannam
date Sat, 13 Jun 2015 08:47:05 +0100
parents b386363ff6c8
children 4d9816ba0ebe
comparison
equal deleted inserted replaced
1094:b386363ff6c8 1095:b66734b5f806
233 233
234 //!!! Need FFTModel overlap tests to exercise this 234 //!!! Need FFTModel overlap tests to exercise this
235 235
236 sv_frame_t off = range.first - m_savedData.range.first; 236 sv_frame_t off = range.first - m_savedData.range.first;
237 237
238 vector<float> partial(m_savedData.data.begin() + off, m_savedData.data.end()); 238 vector<float> acc(m_savedData.data.begin() + off, m_savedData.data.end());
239 239
240 vector<float> rest = getSourceData({ m_savedData.range.second, range.second }); 240 vector<float> rest =
241 getSourceDataUncached({ m_savedData.range.second, range.second });
241 242
242 partial.insert(partial.end(), rest.begin(), rest.end()); 243 acc.insert(acc.end(), rest.begin(), rest.end());
243 return partial; 244
244 } 245 m_savedData = { range, acc };
245 246 return acc;
247
248 } else {
249
250 auto data = getSourceDataUncached(range);
251 m_savedData = { range, data };
252 return data;
253 }
254 }
255
256 vector<float>
257 FFTModel::getSourceDataUncached(pair<sv_frame_t, sv_frame_t> range) const
258 {
246 vector<float> data(range.second - range.first, 0.f); 259 vector<float> data(range.second - range.first, 0.f);
247 decltype(range.first) pfx = 0; 260 decltype(range.first) pfx = 0;
248 if (range.first < 0) { 261 if (range.first < 0) {
249 pfx = -range.first; 262 pfx = -range.first;
250 range = { 0, range.second }; 263 range = { 0, range.second };
260 for (int i = 0; in_range_for(data, i); ++i) { 273 for (int i = 0; in_range_for(data, i); ++i) {
261 data[i] /= float(channels); 274 data[i] /= float(channels);
262 } 275 }
263 } 276 }
264 } 277 }
265
266 m_savedData = { range, data };
267 278
268 return data; 279 return data;
269 } 280 }
270 281
271 vector<complex<float>> 282 vector<complex<float>>