From a364ec0cb02c6b29981ca0822ef396d7687eed69 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Sat, 11 Mar 2023 11:39:06 -0500 Subject: [PATCH] Fix the juce BlockSize API so plugin works in Logic (probably also fixes FruityLoops too and may fix other hosts with variable block sizes) --- src/PluginProcessor.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/PluginProcessor.cpp b/src/PluginProcessor.cpp index bd292956..3bc67ab6 100644 --- a/src/PluginProcessor.cpp +++ b/src/PluginProcessor.cpp @@ -285,7 +285,8 @@ void ValentineAudioProcessor::processBlock (juce::AudioBuffer& buffer, ju juce::ScopedNoDenormals noDenormals; auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); - auto currentSamplesPerBlock = getBlockSize(); + auto bufferSize = buffer.getNumSamples(); + auto currentSamplesPerBlock = bufferSize; // We need to prepare the process buffer first. The input buffer is delayed to account for // oversampling latency. Copying into the process buffer after this, then, would undo the @@ -319,7 +320,7 @@ void ValentineAudioProcessor::processBlock (juce::AudioBuffer& buffer, ju auto g = compressValue.get(); for (int i = 0; i < totalNumOutputChannels; ++i) - processBuffer.applyGainRamp (i, 0, getBlockSize(), currentGain, g); + processBuffer.applyGainRamp (i, 0, bufferSize, currentGain, g); currentGain = g; // Upsample then do non-linear processing @@ -342,7 +343,7 @@ void ValentineAudioProcessor::processBlock (juce::AudioBuffer& buffer, ju auto m = makeupValue.get(); for (int i = 0; i < totalNumOutputChannels; ++i) { - processBuffer.applyGainRamp (i, 0, getBlockSize(), currentMakeup, m); + processBuffer.applyGainRamp (i, 0, bufferSize, currentMakeup, m); } currentMakeup = m; @@ -371,7 +372,7 @@ void ValentineAudioProcessor::processBlockBypassed (juce::AudioBuffer& bu auto totalNumInputChannels = getTotalNumInputChannels(); auto totalNumOutputChannels = getTotalNumOutputChannels(); - auto currentSamplesPerBlock = getBlockSize(); + auto currentSamplesPerBlock = buffer.getNumSamples(); prepareInputBuffer (buffer, totalNumInputChannels,