Skip to content

Commit

Permalink
hack
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseDiazRohena committed Aug 31, 2024
1 parent 550029a commit 6fa9e3c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
10 changes: 7 additions & 3 deletions libs/tote_bag/dsp/Compressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ void Compressor::setOversampleMultiplier (const int o)
overSampleMultiplier = o - 1;
}

inline void Compressor::makeMonoSidechain (const juce::dsp::AudioBlock<float>& inAudio, juce::AudioBuffer<float>& scSignal)
inline void Compressor::makeMonoSidechain (const juce::dsp::AudioBlock<float>& inAudio,
juce::AudioBuffer<float>& scSignal)
{
scSignal.clear();
auto* scWritePointer = scSignal.getWritePointer (0);
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -133,7 +136,8 @@ void Compressor::process (juce::dsp::AudioBlock<float>& inAudio,
{
auto controlVoltage = juce::Decibels::gainToDecibels (abs (sidechain[sample]));
// TODO: level detector methods should be float or templated
controlVoltage = static_cast<float> (levelDetector.processSampleDecoupledBranched (controlVoltage));
controlVoltage = static_cast<float> (
levelDetector.processSampleDecoupledBranched (controlVoltage));

controlVoltage = calculateGain (controlVoltage);
controlVoltage = juce::Decibels::decibelsToGain (controlVoltage);
Expand Down
12 changes: 5 additions & 7 deletions libs/tote_bag/dsp/Compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class Compressor
float inThreshold,
float inKnee);

void makeMonoSidechain (const juce::dsp::AudioBlock<float>& inAudio, juce::AudioBuffer<float>& scSignal);
void makeMonoSidechain (const juce::dsp::AudioBlock<float>& inAudio,
juce::AudioBuffer<float>& scSignal);

void makeKneeCoeffs();

Expand All @@ -52,16 +53,13 @@ class Compressor
private:
juce::WeakReference<FFAU::LevelMeterSource> meterSource;

juce::Atomic<float> ratio { -1.0f },
knee { -1.0f },
msAttack { -1.0f },
msRelease { -1.0f },
threshold { -1.0 };
juce::Atomic<float> ratio {-1.0f}, knee {-1.0f}, msAttack {-1.0f}, msRelease {-1.0f},
threshold {-1.0};

EnvelopeDetector levelDetector;
juce::AudioBuffer<float> analysisSignal;

int overSampleMultiplier { 1 };
int overSampleMultiplier {1};

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Compressor)
};
18 changes: 16 additions & 2 deletions src/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,22 @@ void ValentineAudioProcessor::processBlock (juce::AudioBuffer<float>& 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
Expand Down
4 changes: 2 additions & 2 deletions src/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ class ValentineAudioProcessor : public juce::AudioProcessor,
FFCompParameterDefaults[static_cast<size_t> (VParameter::outputClipEnable)]
> 0.5f};
bool clipOnState = clipOn.get();
juce::Atomic<bool> saturateOn = FFCompParameterDefaults[static_cast<size_t> (VParameter::saturateEnable)]
> 0.5f;
juce::Atomic<bool> saturateOn =
FFCompParameterDefaults[static_cast<size_t> (VParameter::saturateEnable)] > 0.5f;
bool saturateOnState = saturateOn.get();

// This is used for, yes you guessed it, processing
Expand Down

0 comments on commit 6fa9e3c

Please sign in to comment.