From 43bbeed5ca27f8090245e94caf926bf4bd1f5dd7 Mon Sep 17 00:00:00 2001 From: Septen <gammerxpower@gmail.com> Date: Mon, 21 Mar 2016 23:58:52 +0300 Subject: [PATCH] CAR: implemented race-condition free behaviour for gain parameter. --- Source/Plugins/CAR/CAR.cpp | 12 ++++++++++-- Source/Plugins/CAR/CAR.h | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/Plugins/CAR/CAR.cpp b/Source/Plugins/CAR/CAR.cpp index 8222d2241..bb65bf868 100644 --- a/Source/Plugins/CAR/CAR.cpp +++ b/Source/Plugins/CAR/CAR.cpp @@ -46,9 +46,16 @@ AudioProcessorEditor* CAR::createEditor() } +float CAR::getGainLevel() +{ + m_gainLevel.updateTarget(); + return m_gainLevel.getNextValue(); +} + + void CAR::setGainLevel (float newGain) { - m_gainLevel = newGain; + m_gainLevel.setValue (newGain); } @@ -80,7 +87,8 @@ void CAR::process (AudioSampleBuffer& buffer, MidiBuffer& events) m_avgBuffer.applyGain (1.0f / float (numReferenceChannels)); - const float gain = -1.0f * m_gainLevel / 100.f; + m_gainLevel.updateTarget(); + const float gain = -1.0f * m_gainLevel.getNextValue() / 100.f; for (int i = 0; i < numAffectedChannels; ++i) { diff --git a/Source/Plugins/CAR/CAR.h b/Source/Plugins/CAR/CAR.h index ca1929de2..8f86eb0ce 100644 --- a/Source/Plugins/CAR/CAR.h +++ b/Source/Plugins/CAR/CAR.h @@ -73,7 +73,7 @@ public: void process (AudioSampleBuffer& buffer, MidiBuffer& events) override; /** Returns the current gain level that is set in the processor */ - float getGainLevel() const { return m_gainLevel; } + float getGainLevel(); /** Sets the new gain level that will be used in the processor */ void setGainLevel (float newGain); @@ -92,7 +92,7 @@ public: private: - float m_gainLevel; + LinearSmoothedValueAtomic<float> m_gainLevel; AudioSampleBuffer m_avgBuffer; -- GitLab