# HG changeset patch # User Chris Cannam # Date 1396615827 -3600 # Node ID 4a3005934850ba3cd83ea89f7c7eb187fd123aed # Parent f2d747d234d5f36d15d4f727ee6e7be2b1962a9e Try chaining the resamplers diff -r f2d747d234d5 -r 4a3005934850 cpp-qm-dsp/ConstantQ.cpp --- a/cpp-qm-dsp/ConstantQ.cpp Fri Apr 04 13:29:16 2014 +0100 +++ b/cpp-qm-dsp/ConstantQ.cpp Fri Apr 04 13:50:27 2014 +0100 @@ -111,8 +111,10 @@ int factor = pow(2, i); + // Each octave uses an identical fs/2 resampler fed with the + // output from that of the octave above Resampler *r = new Resampler - (sourceRate, sourceRate / factor, 60, 0.02); + (sourceRate, sourceRate / 2, 60, 0.02); // We need to adapt the latencies so as to get the first input // sample to be aligned, in time, at the decimator output @@ -144,7 +146,7 @@ // use that to compensate in a moment, when we've discovered // what the longest latency across all octaves is. - latencies.push_back(r->getLatency() * factor); + latencies.push_back(r->getLatency() + latencies[i-1]); m_decimators.push_back(r); } @@ -220,8 +222,10 @@ { m_buffers[0].insert(m_buffers[0].end(), td.begin(), td.end()); + vector dec(td); + for (int i = 1; i < m_octaves; ++i) { - vector dec = m_decimators[i]->process(td.data(), td.size()); + dec = m_decimators[i]->process(dec.data(), dec.size()); m_buffers[i].insert(m_buffers[i].end(), dec.begin(), dec.end()); }