Skip to content
Snippets Groups Projects
Commit 43bbeed5 authored by Septen's avatar Septen
Browse files

CAR: implemented race-condition free behaviour for gain parameter.

parent 7b9078ef
No related branches found
No related tags found
No related merge requests found
...@@ -46,9 +46,16 @@ AudioProcessorEditor* CAR::createEditor() ...@@ -46,9 +46,16 @@ AudioProcessorEditor* CAR::createEditor()
} }
float CAR::getGainLevel()
{
m_gainLevel.updateTarget();
return m_gainLevel.getNextValue();
}
void CAR::setGainLevel (float newGain) void CAR::setGainLevel (float newGain)
{ {
m_gainLevel = newGain; m_gainLevel.setValue (newGain);
} }
...@@ -80,7 +87,8 @@ void CAR::process (AudioSampleBuffer& buffer, MidiBuffer& events) ...@@ -80,7 +87,8 @@ void CAR::process (AudioSampleBuffer& buffer, MidiBuffer& events)
m_avgBuffer.applyGain (1.0f / float (numReferenceChannels)); 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) for (int i = 0; i < numAffectedChannels; ++i)
{ {
......
...@@ -73,7 +73,7 @@ public: ...@@ -73,7 +73,7 @@ public:
void process (AudioSampleBuffer& buffer, MidiBuffer& events) override; void process (AudioSampleBuffer& buffer, MidiBuffer& events) override;
/** Returns the current gain level that is set in the processor */ /** 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 */ /** Sets the new gain level that will be used in the processor */
void setGainLevel (float newGain); void setGainLevel (float newGain);
...@@ -92,7 +92,7 @@ public: ...@@ -92,7 +92,7 @@ public:
private: private:
float m_gainLevel; LinearSmoothedValueAtomic<float> m_gainLevel;
AudioSampleBuffer m_avgBuffer; AudioSampleBuffer m_avgBuffer;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment