Mercurial > hg > qm-dsp
comparison 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 |
comparison
equal
deleted
inserted
replaced
141:54c9e0811ae7 | 142:f8fc21365a8c |
---|---|
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 } |