diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 9e45db4..c88861a 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -58,6 +58,8 @@ Multiband_compAudioProcessor::Multiband_compAudioProcessor() LP.setType(juce::dsp::LinkwitzRileyFilterType::lowpass); HP.setType(juce::dsp::LinkwitzRileyFilterType::highpass); + + AP.setType(juce::dsp::LinkwitzRileyFilterType::allpass); } Multiband_compAudioProcessor::~Multiband_compAudioProcessor() @@ -142,6 +144,9 @@ void Multiband_compAudioProcessor::prepareToPlay (double sampleRate, int samples LP.prepare(spec); HP.prepare(spec); + AP.prepare(spec); + apBuffer.setSize(spec.numChannels, samplesPerBlock); + for (auto& buffer : filterBuffers) { buffer.setSize(spec.numChannels, samplesPerBlock); } @@ -205,6 +210,8 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer& buffer LP.setCutoffFrequency(cutoff); HP.setCutoffFrequency(cutoff); + AP.setCutoffFrequency(cutoff); + auto fb0Block = juce::dsp::AudioBlock(filterBuffers[0]); auto fb1Block = juce::dsp::AudioBlock(filterBuffers[1]); @@ -217,6 +224,15 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer& buffer auto numSamples = buffer.getNumSamples(); auto numChannels = buffer.getNumChannels(); + //if (compressor.bypassed->get()) + // return; + + apBuffer = buffer; + auto apBlock = juce::dsp::AudioBlock(apBuffer); + auto apContext = juce::dsp::ProcessContextReplacing(apBlock); + AP.process(apContext); + + buffer.clear(); auto addFilterBand = [nc = numChannels, ns = numSamples](auto& inputBuffer, const auto& source) { @@ -224,9 +240,27 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer& buffer inputBuffer.addFrom(i, 0, source, i, 0, ns); } }; - + /* + if (!compressor.bypassed->get()) { + addFilterBand(buffer, filterBuffers[0]); + addFilterBand(buffer, filterBuffers[1]); + } + else { + addFilterBand(buffer, apBuffer); + } + */ addFilterBand(buffer, filterBuffers[0]); addFilterBand(buffer, filterBuffers[1]); + + if (compressor.bypassed->get()) { + for (auto ch = 0; ch < numChannels; ++ch) { + juce::FloatVectorOperations::multiply(apBuffer.getWritePointer(ch), + -1.f, + numSamples); + } + + addFilterBand(buffer, apBuffer); + } } //============================================================================== diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index 86be748..8e04ca9 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -166,6 +166,10 @@ class Multiband_compAudioProcessor : public juce::AudioProcessor using Filter = juce::dsp::LinkwitzRileyFilter; Filter LP, HP; + Filter AP; + + juce::AudioBuffer apBuffer; + juce::AudioParameterFloat* lowCrossover{ nullptr }; std::array, 2> filterBuffers;