# HG changeset patch # User Chris Cannam # Date 1434181625 -3600 # Node ID b66734b5f80666b30e547653f8d9be502953938b # Parent b386363ff6c810ef848bc88091f15e304f10db47 Fix to fft cache diff -r b386363ff6c8 -r b66734b5f806 data/fft/FFTapi.h --- a/data/fft/FFTapi.h Fri Jun 12 19:18:56 2015 +0100 +++ b/data/fft/FFTapi.h Sat Jun 13 08:47:05 2015 +0100 @@ -73,6 +73,8 @@ const int hs = m_size/2; for (int i = 0; i < hs; ++i) { m_input[i] = in[i + hs]; + } + for (int i = 0; i < hs; ++i) { m_input[i + hs] = in[i]; } fftf_execute(m_plan); diff -r b386363ff6c8 -r b66734b5f806 data/model/FFTModel.cpp --- a/data/model/FFTModel.cpp Fri Jun 12 19:18:56 2015 +0100 +++ b/data/model/FFTModel.cpp Sat Jun 13 08:47:05 2015 +0100 @@ -235,14 +235,27 @@ sv_frame_t off = range.first - m_savedData.range.first; - vector partial(m_savedData.data.begin() + off, m_savedData.data.end()); + vector acc(m_savedData.data.begin() + off, m_savedData.data.end()); - vector rest = getSourceData({ m_savedData.range.second, range.second }); + vector rest = + getSourceDataUncached({ m_savedData.range.second, range.second }); - partial.insert(partial.end(), rest.begin(), rest.end()); - return partial; + acc.insert(acc.end(), rest.begin(), rest.end()); + + m_savedData = { range, acc }; + return acc; + + } else { + + auto data = getSourceDataUncached(range); + m_savedData = { range, data }; + return data; } +} +vector +FFTModel::getSourceDataUncached(pair range) const +{ vector data(range.second - range.first, 0.f); decltype(range.first) pfx = 0; if (range.first < 0) { @@ -262,8 +275,6 @@ } } } - - m_savedData = { range, data }; return data; } diff -r b386363ff6c8 -r b66734b5f806 data/model/FFTModel.h --- a/data/model/FFTModel.h Fri Jun 12 19:18:56 2015 +0100 +++ b/data/model/FFTModel.h Sat Jun 13 08:47:05 2015 +0100 @@ -169,6 +169,7 @@ std::vector > getFFTColumn(int column) const; std::vector getSourceSamples(int column) const; std::vector getSourceData(std::pair) const; + std::vector getSourceDataUncached(std::pair) const; struct SavedSourceData { std::pair range;