1ce50ff2f2a7 — Chris Cannam 3 months ago
Don't invite smoothing when setting the very first ratio
1 files changed, 10 insertions(+), 1 deletions(-)

M src/Resampler.cpp
M src/Resampler.cpp +10 -1
@@ 573,6 573,7 @@ protected:
     int m_iinsize;
     int m_ioutsize;
     double m_prevRatio;
+    bool m_ratioUnset;
     int m_debugLevel;
 };
 

          
@@ 585,6 586,7 @@ D_SRC::D_SRC(Resampler::Quality quality,
     m_iinsize(0),
     m_ioutsize(0),
     m_prevRatio(1.0),
+    m_ratioUnset(true),
     m_debugLevel(debugLevel)
 {
     if (m_debugLevel > 0) {

          
@@ 690,7 692,14 @@ D_SRC::resampleInterleaved(float *const 
         outcount = int(ceil(incount * ratio) + 5);
     }
 
-    if (ratio != m_prevRatio) {
+    if (m_ratioUnset) {
+
+        // The first time we set a ratio, we want to do it directly
+        src_set_ratio(m_src, ratio);
+        m_ratioUnset = false;
+        m_prevRatio = ratio;
+
+    } else if (ratio != m_prevRatio) {
 
         // If we are processing a block of appreciable length, turn it
         // into two recursive calls, one for the short smoothing block