From a3674a44d43a15798cfe0c99863c519a443089be Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 10 Jul 2023 13:31:34 -0700 Subject: [PATCH] Make BaseProcessor::getInputBuffer() const --- src/processors/BaseProcessor.h | 3 ++- src/processors/chain/ProcessorChain.cpp | 4 ++-- src/processors/utility/Mixer.cpp | 4 ++-- src/processors/utility/StereoMerger.cpp | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/processors/BaseProcessor.h b/src/processors/BaseProcessor.h index 0ce6869e..d0c576c5 100644 --- a/src/processors/BaseProcessor.h +++ b/src/processors/BaseProcessor.h @@ -159,7 +159,8 @@ class BaseProcessor : private JuceProcWrapper /** Returns the netlist circuit quantities, or nullptr if the processor has no circuit quantities. */ auto* getNetlistCircuitQuantities() { return netlistCircuitQuantities.get(); } - AudioBuffer& getInputBuffer (int idx = 0) { return inputBuffers.getReference (idx); } + const AudioBuffer& getInputBuffer (int idx = 0) const { return inputBuffers.getReference (idx); } + AudioBuffer& getInputBufferNonConst (int idx = 0) { return inputBuffers.getReference (idx); } // Most derived classes should never use this! AudioBuffer* getOutputBuffer (int idx = 0) { return outputBuffers[idx]; } const ConnectionInfo& getOutputConnection (int portIdx, int connectionIdx) const { return outputConnections[portIdx].getReference (connectionIdx); } diff --git a/src/processors/chain/ProcessorChain.cpp b/src/processors/chain/ProcessorChain.cpp index 4fc1c07c..94da0456 100644 --- a/src/processors/chain/ProcessorChain.cpp +++ b/src/processors/chain/ProcessorChain.cpp @@ -134,13 +134,13 @@ void ProcessorChain::runProcessor (BaseProcessor* proc, AudioBuffer& buff } else if (nextNumProcs > 1 && nextNumInputs == 1) { - auto& copyNextBuffer = nextProc->getInputBuffer(); + auto& copyNextBuffer = nextProc->getInputBufferNonConst(); copyNextBuffer.makeCopyOf (nextBuffer, true); runProcessor (nextProc, copyNextBuffer, outProcessed); } else { - auto& copyNextBuffer = nextProc->getInputBuffer (inputIndex); + auto& copyNextBuffer = nextProc->getInputBufferNonConst (inputIndex); copyNextBuffer.makeCopyOf (nextBuffer, true); nextProc->incrementNumInputsReady(); diff --git a/src/processors/utility/Mixer.cpp b/src/processors/utility/Mixer.cpp index 98b6cada..3c57eaf7 100644 --- a/src/processors/utility/Mixer.cpp +++ b/src/processors/utility/Mixer.cpp @@ -54,7 +54,7 @@ void Mixer::processAudio (AudioBuffer& buffer) numInputsProcessed++; - auto& inBuffer = getInputBuffer (i); + auto& inBuffer = getInputBufferNonConst (i); int numChannels = inBuffer.getNumChannels(); int numSamples = inBuffer.getNumSamples(); @@ -108,7 +108,7 @@ void Mixer::processAudioBypassed (AudioBuffer& buffer) { if (inputsConnected.contains (i)) { - auto& inBuffer = getInputBuffer (i); + auto& inBuffer = getInputBufferNonConst (i); outputBuffers.getReference (0) = &inBuffer; return; } diff --git a/src/processors/utility/StereoMerger.cpp b/src/processors/utility/StereoMerger.cpp index bf340947..ee98f8b6 100644 --- a/src/processors/utility/StereoMerger.cpp +++ b/src/processors/utility/StereoMerger.cpp @@ -68,7 +68,7 @@ void StereoMerger::processAudio (AudioBuffer& buffer) if (isInput0Connected) { - auto& inBuffer = getInputBuffer (LeftChannel); + auto& inBuffer = getInputBufferNonConst (LeftChannel); makeBufferMono (inBuffer); stereoBuffer.addFrom (0, 0, inBuffer, 0, 0, numSamples); @@ -78,7 +78,7 @@ void StereoMerger::processAudio (AudioBuffer& buffer) if (isInput1Connected) { - auto& inBuffer = getInputBuffer (RightChannel); + auto& inBuffer = getInputBufferNonConst (RightChannel); makeBufferMono (inBuffer); if (isLeftRight)