diff --git a/libs/tote_bag/dsp/Compressor.cpp b/libs/tote_bag/dsp/Compressor.cpp index 50c7b9f5..db6c7304 100644 --- a/libs/tote_bag/dsp/Compressor.cpp +++ b/libs/tote_bag/dsp/Compressor.cpp @@ -62,7 +62,8 @@ void Compressor::setOversampleMultiplier (const int o) overSampleMultiplier = o - 1; } -inline void Compressor::makeMonoSidechain (const juce::dsp::AudioBlock& inAudio, juce::AudioBuffer& scSignal) +inline void Compressor::makeMonoSidechain (const juce::dsp::AudioBlock& inAudio, + juce::AudioBuffer& scSignal) { scSignal.clear(); auto* scWritePointer = scSignal.getWritePointer (0); @@ -101,7 +102,9 @@ inline float Compressor::calculateGain (float inputSample) else if (abs (doubleOvershoot) <= W) { - cvOutput = inputSample + ((1.0f / R - 1.0f) * powf (overshoot + W / 2.0f, 2)) / (2.0f * W); + cvOutput = + inputSample + + ((1.0f / R - 1.0f) * powf (overshoot + W / 2.0f, 2)) / (2.0f * W); } else { @@ -133,7 +136,8 @@ void Compressor::process (juce::dsp::AudioBlock& inAudio, { auto controlVoltage = juce::Decibels::gainToDecibels (abs (sidechain[sample])); // TODO: level detector methods should be float or templated - controlVoltage = static_cast (levelDetector.processSampleDecoupledBranched (controlVoltage)); + controlVoltage = static_cast ( + levelDetector.processSampleDecoupledBranched (controlVoltage)); controlVoltage = calculateGain (controlVoltage); controlVoltage = juce::Decibels::decibelsToGain (controlVoltage); diff --git a/libs/tote_bag/dsp/Compressor.h b/libs/tote_bag/dsp/Compressor.h index 11116306..8c953bf6 100644 --- a/libs/tote_bag/dsp/Compressor.h +++ b/libs/tote_bag/dsp/Compressor.h @@ -29,7 +29,8 @@ class Compressor float inThreshold, float inKnee); - void makeMonoSidechain (const juce::dsp::AudioBlock& inAudio, juce::AudioBuffer& scSignal); + void makeMonoSidechain (const juce::dsp::AudioBlock& inAudio, + juce::AudioBuffer& scSignal); void makeKneeCoeffs(); @@ -52,16 +53,13 @@ class Compressor private: juce::WeakReference meterSource; - juce::Atomic ratio { -1.0f }, - knee { -1.0f }, - msAttack { -1.0f }, - msRelease { -1.0f }, - threshold { -1.0 }; + juce::Atomic ratio {-1.0f}, knee {-1.0f}, msAttack {-1.0f}, msRelease {-1.0f}, + threshold {-1.0}; EnvelopeDetector levelDetector; juce::AudioBuffer analysisSignal; - int overSampleMultiplier { 1 }; + int overSampleMultiplier {1}; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Compressor) }; diff --git a/src/PluginProcessor.cpp b/src/PluginProcessor.cpp index bea7e07e..1395aeb5 100644 --- a/src/PluginProcessor.cpp +++ b/src/PluginProcessor.cpp @@ -368,8 +368,22 @@ void ValentineAudioProcessor::processBlock (juce::AudioBuffer& buffer, } auto g = compressValue.get(); - for (int i = 0; i < totalNumOutputChannels; ++i) - processBuffer.applyGainRamp (i, 0, bufferSize, currentGain, g); + + if (sidechainInput.getNumChannels() > 0) + { + for (int i = 0; i < totalNumOutputChannels; ++i) + { + sidechainInput.applyGainRamp (i, 0, bufferSize, currentGain, g); + } + } + else + { + for (int i = 0; i < totalNumOutputChannels; ++i) + processBuffer.applyGainRamp (i, 0, bufferSize, currentGain, g); + } + + // for (int i = 0; i < totalNumOutputChannels; ++i) + // processBuffer.applyGainRamp (i, 0, bufferSize, currentGain, g); currentGain = g; // Upsample then do non-linear processing diff --git a/src/PluginProcessor.h b/src/PluginProcessor.h index 3c9d8d06..6593016d 100644 --- a/src/PluginProcessor.h +++ b/src/PluginProcessor.h @@ -199,8 +199,8 @@ class ValentineAudioProcessor : public juce::AudioProcessor, FFCompParameterDefaults[static_cast (VParameter::outputClipEnable)] > 0.5f}; bool clipOnState = clipOn.get(); - juce::Atomic saturateOn = FFCompParameterDefaults[static_cast (VParameter::saturateEnable)] - > 0.5f; + juce::Atomic saturateOn = + FFCompParameterDefaults[static_cast (VParameter::saturateEnable)] > 0.5f; bool saturateOnState = saturateOn.get(); // This is used for, yes you guessed it, processing