Skip to content

Commit

Permalink
testing_filter
Browse files Browse the repository at this point in the history
  • Loading branch information
kuncgregor committed Jan 30, 2022
1 parent 95dfe8a commit 7b13b8e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
36 changes: 35 additions & 1 deletion Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -205,6 +210,8 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer
LP.setCutoffFrequency(cutoff);
HP.setCutoffFrequency(cutoff);

AP.setCutoffFrequency(cutoff);

auto fb0Block = juce::dsp::AudioBlock<float>(filterBuffers[0]);
auto fb1Block = juce::dsp::AudioBlock<float>(filterBuffers[1]);

Expand All @@ -217,16 +224,43 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer
auto numSamples = buffer.getNumSamples();
auto numChannels = buffer.getNumChannels();

//if (compressor.bypassed->get())
// return;

apBuffer = buffer;
auto apBlock = juce::dsp::AudioBlock<float>(apBuffer);
auto apContext = juce::dsp::ProcessContextReplacing<float>(apBlock);
AP.process(apContext);


buffer.clear();

auto addFilterBand = [nc = numChannels, ns = numSamples](auto& inputBuffer, const auto& source) {
for (auto i = 0; i < nc; ++i) {
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);
}
}

//==============================================================================
Expand Down
4 changes: 4 additions & 0 deletions Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ class Multiband_compAudioProcessor : public juce::AudioProcessor
using Filter = juce::dsp::LinkwitzRileyFilter<float>;
Filter LP, HP;

Filter AP;

juce::AudioBuffer<float> apBuffer;

juce::AudioParameterFloat* lowCrossover{ nullptr };

std::array<juce::AudioBuffer<float>, 2> filterBuffers;
Expand Down

0 comments on commit 7b13b8e

Please sign in to comment.