From c2cbc78b5fc426debfbaa5aa94e3a91e0bdb77bb Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 3 Feb 2015 17:49:13 +0000 Subject: [PATCH] Fix to the LagrangeInterpolator when working with extreme ratios. --- .../effects/juce_LagrangeInterpolator.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp index 7bab3a576f..6d26cc46f5 100644 --- a/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp +++ b/modules/juce_audio_basics/effects/juce_LagrangeInterpolator.cpp @@ -87,7 +87,10 @@ int LagrangeInterpolator::process (const double actualRatio, const float* in, if (numOut >= 4) { - memcpy (lastInputSamples, in + (numOut - 4), 4 * sizeof (float)); + const float* end = in + numOut; + + for (int i = 0; i < 4; ++i) + lastInputSamples[i] = *--end; } else { @@ -152,7 +155,10 @@ int LagrangeInterpolator::processAdding (const double actualRatio, const float* if (numOut >= 4) { - memcpy (lastInputSamples, in + (numOut - 4), 4 * sizeof (float)); + const float* end = in + numOut; + + for (int i = 0; i < 4; ++i) + lastInputSamples[i] = *--end; } else {