Skip to content

Commit

Permalink
WIP get some sidechain in there
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseDiazRohena committed Aug 18, 2024
1 parent 0d1b5f8 commit a86dca7
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ ValentineAudioProcessor::ValentineAudioProcessor()
#if !JucePlugin_IsMidiEffect
#if !JucePlugin_IsSynth
.withInput ("Input", juce::AudioChannelSet::stereo(), true)
.withInput ("Sidechain", juce::AudioChannelSet::stereo(), true)
#endif
.withOutput ("Output", juce::AudioChannelSet::stereo(), true)
#endif
Expand Down Expand Up @@ -308,7 +309,13 @@ void ValentineAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
auto bufferSize = buffer.getNumSamples();

auto inputOutputBuffer = getBusBuffer (buffer, true, 0);
const auto sideChainBuffer = getBusBuffer (buffer, true, 1);

const auto numMainInputChannels = inputOutputBuffer.getNumChannels();

auto bufferSize = inputOutputBuffer.getNumSamples();
auto currentSamplesPerBlock = bufferSize;

if (latencyChanged.get())
Expand All @@ -321,19 +328,19 @@ void ValentineAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
// oversampling latency. Copying into the process buffer after this, then, would undo the
// purpose of the delay: maintaining phase coherence between processed and unprocessed
// signals.
processBuffer.setSize (totalNumOutputChannels,
processBuffer.setSize (numMainInputChannels,
currentSamplesPerBlock,
true,
true,
true);
for (auto channel = 0; channel < totalNumInputChannels; ++channel)
for (auto channel = 0; channel < numMainInputChannels; ++channel)
processBuffer.copyFrom (channel,
0,
buffer.getReadPointer (channel),
buffer.getNumSamples());
inputOutputBuffer.getReadPointer (channel),
inputOutputBuffer.getNumSamples());

prepareInputBuffer (buffer,
totalNumInputChannels,
prepareInputBuffer (inputOutputBuffer,
numMainInputChannels,
totalNumOutputChannels,
currentSamplesPerBlock);

Expand All @@ -342,7 +349,7 @@ void ValentineAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
return;
}

inputMeterSource.measureBlock (buffer);
inputMeterSource.measureBlock (sideChainBuffer);

// "Downsample" and Bitcrush processing
if (crushOn.get())
Expand Down Expand Up @@ -428,11 +435,14 @@ void ValentineAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
auto processed = processBuffer.getSample (i, j);
auto unprocessed = buffer.getSample (i, j);

buffer.setSample (i, j, mix * processed + (1.0f - currentMix) * unprocessed);
inputOutputBuffer.setSample (i,
j,
mix * processed
+ (1.0f - currentMix) * unprocessed);
}
}

outputMeterSource.measureBlock (buffer);
outputMeterSource.measureBlock (inputOutputBuffer);
}

void ValentineAudioProcessor::processBlockBypassed (juce::AudioBuffer<float>& buffer,
Expand Down

0 comments on commit a86dca7

Please sign in to comment.