From 544e35655a643ecccd2fc02fe0a8d137dad3b343 Mon Sep 17 00:00:00 2001 From: hogliux Date: Fri, 29 Jun 2018 10:02:33 +0100 Subject: [PATCH] DSP: Solved an issue with dsp::Convolution algorithm initialisation --- .../juce_dsp/frequency/juce_Convolution.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/modules/juce_dsp/frequency/juce_Convolution.cpp b/modules/juce_dsp/frequency/juce_Convolution.cpp index 469985d895..08678f1b17 100644 --- a/modules/juce_dsp/frequency/juce_Convolution.cpp +++ b/modules/juce_dsp/frequency/juce_Convolution.cpp @@ -377,6 +377,16 @@ struct Convolution::Pimpl : private Thread stopThread (10000); } + //============================================================================== + /** Inits the size of the interpolation buffer. */ + void initProcessing (int maximumBufferSize) + { + stopThread (1000); + + interpolationBuffer.setSize (1, maximumBufferSize, false, false, true); + mustInterpolate = false; + } + //============================================================================== /** Adds a new change request. */ void addToFifo (ChangeRequest type, juce::var parameter) @@ -659,8 +669,6 @@ struct Convolution::Pimpl : private Thread // action depending on the change level if (changeLevel == 3) { - interpolationBuffer.setSize (2, static_cast (currentInfo.maximumBufferSize), false, false, true); - loadImpulseResponse(); processImpulseResponse(); initializeConvolutionEngines(); @@ -717,16 +725,16 @@ struct Convolution::Pimpl : private Thread { auto&& buffer = output.getSingleChannelBlock (channel); - interpolationBuffer.copyFrom ((int) channel, 0, input.getChannelPointer (channel), (int) numSamples); + interpolationBuffer.copyFrom (0, 0, input.getChannelPointer (channel), (int) numSamples); engines[(int) channel]->processSamples (input.getChannelPointer (channel), buffer.getChannelPointer (0), numSamples); changeVolumes[channel].applyGain (buffer.getChannelPointer (0), (int) numSamples); - auto* interPtr = interpolationBuffer.getWritePointer ((int) channel); + auto* interPtr = interpolationBuffer.getWritePointer (0); engines[(int) channel + 2]->processSamples (interPtr, interPtr, numSamples); changeVolumes[channel + 2].applyGain (interPtr, (int) numSamples); - buffer += interpolated.getSingleChannelBlock (channel); + buffer += interpolated; } if (input.getNumChannels() > 1 && currentInfo.wantsStereo == false) @@ -1154,6 +1162,7 @@ void Convolution::prepare (const ProcessSpec& spec) juce::var (static_cast (spec.maximumBlockSize)) }; pimpl->addToFifo (types, parameters, 2); + pimpl->initProcessing (static_cast (spec.maximumBlockSize)); for (size_t channel = 0; channel < spec.numChannels; ++channel) {