Mercurial > hg > qm-dsp
diff dsp/rateconversion/Resampler.cpp @ 142:f8fc21365a8c
Fix scaling on downsampling, another test
author | Chris Cannam |
---|---|
date | Mon, 14 Oct 2013 16:20:00 +0100 |
parents | 54c9e0811ae7 |
children | a4aa37f7af28 |
line wrap: on
line diff
--- a/dsp/rateconversion/Resampler.cpp Mon Oct 14 16:15:32 2013 +0100 +++ b/dsp/rateconversion/Resampler.cpp Mon Oct 14 16:20:00 2013 +0100 @@ -163,9 +163,14 @@ std::cerr << "process: buf siz " << m_buffer.size() << " filt siz for phase " << m_phase << " " << m_phaseData[m_phase].filter.size() << std::endl; #endif + double scaleFactor = 1.0; + if (m_targetRate < m_sourceRate) { + scaleFactor = double(m_targetRate) / double(m_sourceRate); + } + while (outidx < maxout && m_buffer.size() >= m_phaseData[m_phase].filter.size()) { - dst[outidx] = reconstructOne(); + dst[outidx] = scaleFactor * reconstructOne(); outidx++; }