Update impulse response in convolution engine quickly

Hi,

I have a plugin that uses the convolution engine to process incoming audio. I need to update the IR quite frequently, e.g, 4x per second.

To avoid artefacts I was going to have an active and standby convolution engine and crossfade between them, but looking at the convolution engine code it seems it does that already – hooray!

However, if I update the IR I still notice various artefacts (pops, clicks, the usual). I’m wondering if it’s possibly due to the audio thread being blocked by the switching o the impulse response. Is that likely the case? or could there be a different issue?

And is there a better way to achieve my goals? :slightly_smiling_face:

Here’s how I’m updating the IR:

void DrawverbAudioProcessor::updateConvolutionIR(const std::vector<float>& finalIRLeft,
    const std::vector<float>& finalIRRight)
{
    int maxLength = std::max(static_cast<int>(finalIRLeft.size()), static_cast<int>(finalIRRight.size()));
    juce::AudioBuffer<float> irBuffer;
    irBuffer.setSize(2, maxLength);
    irBuffer.clear();

    irBuffer.copyFrom(0, 0, finalIRLeft.data(), static_cast<int>(finalIRLeft.size()));
    irBuffer.copyFrom(1, 0, finalIRRight.data(), static_cast<int>(finalIRRight.size()));

    convolutionEngine.loadImpulseResponse(std::move(irBuffer),
        getSampleRate(),
        juce::dsp::Convolution::Stereo::yes,
        juce::dsp::Convolution::Trim::yes,
        juce::dsp::Convolution::Normalise::no);
}

Thanks for any help.

I’ve realized that creating the audio buffer on another thread and passing that into my updateConvolutionIR function instead of the float arrays seems to help a lot with the issue. Still would love to hear if there’s anything else that can be improved. Thanks!