diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index e2d7e46..c318617 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -32,9 +32,17 @@ Multiband_compAudioProcessor::Multiband_compAudioProcessor() }; - floatHelper(compressor.attack, Names::Attack_Low_Band); - floatHelper(compressor.release, Names::Release_Low_Band); - floatHelper(compressor.threshold, Names::Threshold_Low_Band); + floatHelper(lowBandComp.attack, Names::Attack_Low_Band); + floatHelper(lowBandComp.release, Names::Release_Low_Band); + floatHelper(lowBandComp.threshold, Names::Threshold_Low_Band); + + floatHelper(midBandComp.attack, Names::Attack_Mid_Band); + floatHelper(midBandComp.release, Names::Release_Mid_Band); + floatHelper(midBandComp.threshold, Names::Threshold_Mid_Band); + + floatHelper(highBandComp.attack, Names::Attack_High_Band); + floatHelper(highBandComp.release, Names::Release_High_Band); + floatHelper(highBandComp.threshold, Names::Threshold_High_Band); auto choiceHelper = [&apvts = this->apvts, ¶ms](auto& param, const auto& paramName) { @@ -43,7 +51,9 @@ Multiband_compAudioProcessor::Multiband_compAudioProcessor() }; - choiceHelper(compressor.ratio, Names::Ratio_Low_Band); + choiceHelper(lowBandComp.ratio, Names::Ratio_Low_Band); + choiceHelper(midBandComp.ratio, Names::Ratio_Mid_Band); + choiceHelper(highBandComp.ratio, Names::Ratio_High_Band); auto boolHelper = [&apvts = this->apvts, ¶ms](auto& param, const auto& paramName) { @@ -52,7 +62,9 @@ Multiband_compAudioProcessor::Multiband_compAudioProcessor() }; - boolHelper(compressor.bypassed, Names::Bypassed_Low_Band); + boolHelper(lowBandComp.bypassed, Names::Bypassed_Low_Band); + boolHelper(midBandComp.bypassed, Names::Bypassed_Mid_Band); + boolHelper(highBandComp.bypassed, Names::Bypassed_High_Band); floatHelper(lowMidCrossover, Names::Low_Mid_Crossover_Freq); floatHelper(midHighCrossover, Names::Mid_High_Crossover_Freq); @@ -146,7 +158,10 @@ void Multiband_compAudioProcessor::prepareToPlay (double sampleRate, int samples spec.numChannels = getTotalNumOutputChannels(); spec.sampleRate = sampleRate; - compressor.prepare(spec); + for (auto& comp : compressor) { + comp.prepare(spec); + } + LP1.prepare(spec); HP1.prepare(spec); @@ -214,7 +229,8 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer& buffer for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i) buffer.clear(i, 0, buffer.getNumSamples()); - //compressor.updateCompressorSettings(); + for( auto& cmp : compressor) + cmp.updateCompressorSettings(); //compressor.process(buffer); for (auto& fb : filterBuffers) { @@ -251,19 +267,14 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer& buffer HP2.process(fb2Ctx); - //auto invAPBlock = juce::dsp::AudioBlock(invAPBuffer); - //auto invAPCtx = juce::dsp::ProcessContextReplacing(invAPBlock); + for (size_t i = 0; i < filterBuffers.size(); ++i) { + compressor[i].process(filterBuffers[i]); + } - //invAP1.process(invAPCtx); - //invAP2.process(invAPCtx); auto numSamples = buffer.getNumSamples(); auto numChannels = buffer.getNumChannels(); - if (compressor.bypassed->get()) - return; - - buffer.clear(); @@ -277,18 +288,6 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer& buffer addFilterBand(buffer, filterBuffers[1]); addFilterBand(buffer, filterBuffers[2]); - /* - if (compressor.bypassed->get()) { - for (auto ch = 0; ch < numChannels; ++ch) { - juce::FloatVectorOperations::multiply( - invAPBuffer.getWritePointer(ch), - -1.f, - numSamples); - } - - addFilterBand(buffer, invAPBuffer); - } - */ } @@ -337,6 +336,16 @@ juce::AudioProcessorValueTreeState::ParameterLayout Multiband_compAudioProcessor params.at(Names::Threshold_Low_Band), NormalisableRange(-60, 12, 1, 1), 0)); + layout.add(std::make_unique( + params.at(Names::Threshold_Mid_Band), + params.at(Names::Threshold_Mid_Band), + NormalisableRange(-60, 12, 1, 1), + 0)); + layout.add(std::make_unique( + params.at(Names::Threshold_High_Band), + params.at(Names::Threshold_High_Band), + NormalisableRange(-60, 12, 1, 1), + 0)); auto attackReleseRange = NormalisableRange(5, 500, 1, 1); @@ -345,12 +354,34 @@ juce::AudioProcessorValueTreeState::ParameterLayout Multiband_compAudioProcessor params.at(Names::Attack_Low_Band), attackReleseRange, 50)); + layout.add(std::make_unique( + params.at(Names::Attack_Mid_Band), + params.at(Names::Attack_Mid_Band), + attackReleseRange, + 50)); + layout.add(std::make_unique( + params.at(Names::Attack_High_Band), + params.at(Names::Attack_High_Band), + attackReleseRange, + 50)); + layout.add(std::make_unique < AudioParameterFloat>( params.at(Names::Release_Low_Band), params.at(Names::Release_Low_Band), attackReleseRange, 250)); + layout.add(std::make_unique < AudioParameterFloat>( + params.at(Names::Release_Mid_Band), + params.at(Names::Release_Mid_Band), + attackReleseRange, + 250)); + layout.add(std::make_unique < AudioParameterFloat>( + params.at(Names::Release_High_Band), + params.at(Names::Release_High_Band), + attackReleseRange, + 250)); + auto choices = std::vector{ 1,1.5,2,3,4,5,6,7,8,10,15,20,50,100 }; juce::StringArray sa; @@ -363,11 +394,31 @@ juce::AudioProcessorValueTreeState::ParameterLayout Multiband_compAudioProcessor params.at(Names::Ratio_Low_Band), sa, 3)); + layout.add(std::make_unique( + params.at(Names::Ratio_Mid_Band), + params.at(Names::Ratio_Mid_Band), + sa, + 3)); + layout.add(std::make_unique( + params.at(Names::Ratio_High_Band), + params.at(Names::Ratio_High_Band), + sa, + 3)); + layout.add(std::make_unique( params.at(Names::Bypassed_Low_Band), params.at(Names::Bypassed_Low_Band), false)); + layout.add(std::make_unique( + params.at(Names::Bypassed_Mid_Band), + params.at(Names::Bypassed_Mid_Band), + false)); + layout.add(std::make_unique( + params.at(Names::Bypassed_High_Band), + params.at(Names::Bypassed_High_Band), + false)); + layout.add(std::make_unique ( diff --git a/Source/PluginProcessor.h b/Source/PluginProcessor.h index abbc955..85ac330 100644 --- a/Source/PluginProcessor.h +++ b/Source/PluginProcessor.h @@ -161,7 +161,11 @@ class Multiband_compAudioProcessor : public juce::AudioProcessor private: - CompressorBand compressor; + std::array compressor; + CompressorBand& lowBandComp = compressor[0]; + CompressorBand& midBandComp = compressor[1]; + CompressorBand& highBandComp = compressor[2]; + using Filter = juce::dsp::LinkwitzRileyFilter; // fc0 fc1 diff --git a/test_filtr.filtergraph b/test_filtr.filtergraph index 0984674..a0d04e7 100644 --- a/test_filtr.filtergraph +++ b/test_filtr.filtergraph @@ -62,13 +62,13 @@ + uiLastY_Normal="298" uiopen_Normal="0" uiLastX_Generic="975" + uiLastY_Generic="215" uiopen_Generic="0"> - 478.VMjLgTc....O+fWarAhckI2bo8la8HRLt.iHfTlai8FYo41Y8HRUTYTK3HxO9.BOVMEUy.Ea0cVZtMEcgQWY9vSRC8Vav8lak4Fc9HyMz3BTEwlXmAiUYoWUrIVdA4hKAQkKTETRUAUSAAkKBolQY4BQtHTQDQzX5UTLXEWPlM1Y2Y0XqEDTtjDTt3hKt3hKt3hVh4RPtPUPIUETMEDTtHjZFkkKDYlPEgDUjYWQwHVdUYTVtf0UXIWUWkkKDAkPD4hKt3hKt3hKt3hKt3RUPIUQTMkKDYlKuEkQtDjXPEjTEYzXugiQtDSQFEFLUYjKAolKA4hKt3hKt3hKX4BQt.UQpQUPvPjKAgDTZoVPP4RRTYFUqcmUYcVSWkkKXcEVxU0UY4BQPIDQt3hKt3hKtXGQGAkKtTETRUDUS4BQl4xaQYjKAIGTAQ0YrI1ZMcjV0cmQY4BVWgkbUcUVtPDTBQjKt3hKt3hKt.0P14hKt3hKt3hKt3hKtnTUv.UQAslXuk0UXoWUFE0YQcEVtPDTtHzZGI1YMIiXtPDTtHjKPcjKt3hKt3hKt3haTU0PUQDU3sFaicVTWkEQEYzXmEDOujzPu0Fbu4VYtQmO77hUSQ0LPwVcmklaSQWXzUlO.. + 1613.VMjLgPjA...O+fWarAhckI2bo8la8HRLt.iHfTlai8FYo41Y8HRUTYTK3HxO9.BOVMEUy.Ea0cVZtMEcgQWY9vSRC8Vav8lak4Fc9DSLxTiKPUDahcFLVkkdUwlX4EjKtDDVAQUPIUET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