diff data/model/WaveformOversampler.cpp @ 1538:fa67fbbff8fc zoom

Oversampler fixes and further tests
author Chris Cannam
date Wed, 26 Sep 2018 15:11:26 +0100
parents eb10ed56d5a4
children ca43af0dcab7
line wrap: on
line diff
--- a/data/model/WaveformOversampler.cpp	Wed Sep 26 14:44:38 2018 +0100
+++ b/data/model/WaveformOversampler.cpp	Wed Sep 26 15:11:26 2018 +0100
@@ -38,11 +38,11 @@
         double pos = (double(i) / oversampleBy) * m_filterRatio;
         double diff = pos - floor(pos);
         int ix = int(floor(pos));
-        float interpolated = (1.0 - diff) * fixedRatio[ix];
+        double interpolated = (1.0 - diff) * fixedRatio[ix];
         if (in_range_for(fixedRatio, ix + 1)) {
             interpolated += diff * fixedRatio[ix + 1];
         }
-        result[i] = interpolated;
+        result[i] = float(interpolated);
     }
 
     return result;
@@ -65,7 +65,7 @@
     
     sv_frame_t filterLength = m_filter.size(); // NB this is known to be odd
     sv_frame_t filterTailOut = (filterLength - 1) / 2;
-    sv_frame_t filterTailIn = filterTailIn / m_filterRatio;
+    sv_frame_t filterTailIn = filterTailOut / m_filterRatio;
 
     floatvec_t oversampled(targetFrameCount, 0.f);
 
@@ -77,7 +77,7 @@
     if (i1 > sourceLength) {
         i1 = sourceLength;
     }
-
+    
     floatvec_t sourceData = source->getData(channel, i0, i1 - i0);
     
     for (sv_frame_t i = i0; i < i1; ++i) {