shithub: dumb

Download patch

ref: ffd168da5e639f5ef9943d2cc8c8be202a1003b0
parent: 1eef4c9f892c119f2f92f0d928efe1b7a98af934
author: Chris Moeller <kode54@gmail.com>
date: Thu Apr 25 21:42:23 EDT 2013

Fixed phase calculation when downsampling

--- a/dumb/src/helpers/lanczos_resampler.c
+++ b/dumb/src/helpers/lanczos_resampler.c
@@ -154,6 +154,7 @@
 			// accumulate in extended precision
             double kernel[LANCZOS_WIDTH * 2], kernel_sum = 0.0;
 			int i = LANCZOS_WIDTH;
+			int phase_adj = phase * step / LANCZOS_RESOLUTION;
 			double sample;
 
 			if ( out >= out_end )
@@ -162,7 +163,7 @@
 			for (; i >= -LANCZOS_WIDTH + 1; --i)
 			{
 				int pos = i * step;
-				kernel_sum += kernel[i + LANCZOS_WIDTH - 1] = lanczos_lut[abs(phase - pos)];
+				kernel_sum += kernel[i + LANCZOS_WIDTH - 1] = lanczos_lut[abs(phase_adj - pos)];
 			}
 			for (sample = 0, i = 0; i < LANCZOS_WIDTH * 2; ++i)
 				sample += in[i] * kernel[i];