diff --git a/resample.go b/resample.go index d3315bd..d30971c 100644 --- a/resample.go +++ b/resample.go @@ -57,7 +57,7 @@ func ResampleRatio(quality int, ratio float64, s Streamer) *Resampler { ratio: ratio, buf1: make([][2]float64, resamplerSingleBufferSize), buf2: make([][2]float64, resamplerSingleBufferSize), - pts: make([]point, quality*2), + pts: make([]point, quality*2+1), off: -resamplerSingleBufferSize, pos: 0, end: math.MaxInt, @@ -85,9 +85,8 @@ func (r *Resampler) Stream(samples [][2]float64) (n int, ok bool) { // Determine the quality*2 closest sample positions for the interpolation. // The window has length len(r.pts) and is centered around wantPos. - // todo: check if this is actually centered around wantPos - windowStart := int(wantPos) - len(r.pts)/2 + 1 // (inclusive) - windowEnd := int(wantPos) + len(r.pts)/2 + 1 // (exclusive) + windowStart := int(wantPos) - len(r.pts)/2 // (inclusive) + windowEnd := int(wantPos) + len(r.pts)/2 + 1 // (exclusive) // Prepare the buffers. if windowEnd >= r.off+resamplerSingleBufferSize {