From 5b9c561579e7a65347f2c8bbb9a597d4afd6984a Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Sun, 21 Feb 2021 00:40:11 +0200 Subject: [PATCH] resampler : minor fixes --- src/resampler.cpp | 15 +++++++-------- src/resampler.h | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/resampler.cpp b/src/resampler.cpp index f65e9a5..dc96d71 100644 --- a/src/resampler.cpp +++ b/src/resampler.cpp @@ -9,16 +9,15 @@ double linear_interp(double first_number, double second_number, double fraction) } } +Resampler::Resampler() { + make_sinc(); +} + int Resampler::resample( float factor, int nSamples, const float * samplesInp, float * samplesOut) { - if (factor != m_lastFactor) { - make_sinc(); - m_lastFactor = factor; - } - int idxInp = 0; int idxOut = 0; int notDone = 1; @@ -31,8 +30,8 @@ int Resampler::resample( double one_over_factor = 1.0; while (notDone) { double temp1 = 0.0; - long left_limit = time_now - kWidth + 1; /* leftmost neighboring sample used for interp.*/ - long right_limit = time_now + kWidth; /* rightmost leftmost neighboring sample used for interp.*/ + long left_limit = time_now - kWidth + 1; /* leftmost neighboring sample used for interp.*/ + long right_limit = time_now + kWidth; /* rightmost leftmost neighboring sample used for interp.*/ if (left_limit<0) left_limit = 0; if (right_limit>num_samples) right_limit = num_samples; if (factor<1.0) { @@ -57,7 +56,7 @@ int Resampler::resample( time_now += factor; last_time = int_time; int_time = time_now; - while(last_time