comparison dsp/rateconversion/Resampler.cpp @ 367:0721657fdd1d

Fix scaling on downsampling, another test
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 14 Oct 2013 16:20:00 +0100
parents 767947956fc1
children a4aa37f7af28
comparison
equal deleted inserted replaced
366:767947956fc1 367:0721657fdd1d
161 161
162 #ifdef DEBUG_RESAMPLER 162 #ifdef DEBUG_RESAMPLER
163 std::cerr << "process: buf siz " << m_buffer.size() << " filt siz for phase " << m_phase << " " << m_phaseData[m_phase].filter.size() << std::endl; 163 std::cerr << "process: buf siz " << m_buffer.size() << " filt siz for phase " << m_phase << " " << m_phaseData[m_phase].filter.size() << std::endl;
164 #endif 164 #endif
165 165
166 double scaleFactor = 1.0;
167 if (m_targetRate < m_sourceRate) {
168 scaleFactor = double(m_targetRate) / double(m_sourceRate);
169 }
170
166 while (outidx < maxout && 171 while (outidx < maxout &&
167 m_buffer.size() >= m_phaseData[m_phase].filter.size()) { 172 m_buffer.size() >= m_phaseData[m_phase].filter.size()) {
168 dst[outidx] = reconstructOne(); 173 dst[outidx] = scaleFactor * reconstructOne();
169 outidx++; 174 outidx++;
170 } 175 }
171 176
172 return outidx; 177 return outidx;
173 } 178 }