Skip to content

Commit

Permalink
Compresorji_ponovno_delajo_3band
Browse files Browse the repository at this point in the history
  • Loading branch information
kuncgregor committed Jan 30, 2022
1 parent ffa76a6 commit 7c70d9d
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 36 deletions.
105 changes: 78 additions & 27 deletions Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, &params](auto& param, const auto& paramName) {

Expand All @@ -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, &params](auto& param, const auto& paramName) {

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -214,7 +229,8 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer<float>& 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) {
Expand Down Expand Up @@ -251,19 +267,14 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer

HP2.process(fb2Ctx);

//auto invAPBlock = juce::dsp::AudioBlock<float>(invAPBuffer);
//auto invAPCtx = juce::dsp::ProcessContextReplacing<float>(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();

Expand All @@ -277,18 +288,6 @@ void Multiband_compAudioProcessor::processBlock(juce::AudioBuffer<float>& 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);
}
*/

}

Expand Down Expand Up @@ -337,6 +336,16 @@ juce::AudioProcessorValueTreeState::ParameterLayout Multiband_compAudioProcessor
params.at(Names::Threshold_Low_Band),
NormalisableRange<float>(-60, 12, 1, 1),
0));
layout.add(std::make_unique<AudioParameterFloat>(
params.at(Names::Threshold_Mid_Band),
params.at(Names::Threshold_Mid_Band),
NormalisableRange<float>(-60, 12, 1, 1),
0));
layout.add(std::make_unique<AudioParameterFloat>(
params.at(Names::Threshold_High_Band),
params.at(Names::Threshold_High_Band),
NormalisableRange<float>(-60, 12, 1, 1),
0));

auto attackReleseRange = NormalisableRange<float>(5, 500, 1, 1);

Expand All @@ -345,12 +354,34 @@ juce::AudioProcessorValueTreeState::ParameterLayout Multiband_compAudioProcessor
params.at(Names::Attack_Low_Band),
attackReleseRange,
50));
layout.add(std::make_unique<AudioParameterFloat>(
params.at(Names::Attack_Mid_Band),
params.at(Names::Attack_Mid_Band),
attackReleseRange,
50));
layout.add(std::make_unique<AudioParameterFloat>(
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<double>{ 1,1.5,2,3,4,5,6,7,8,10,15,20,50,100 };
juce::StringArray sa;
Expand All @@ -363,11 +394,31 @@ juce::AudioProcessorValueTreeState::ParameterLayout Multiband_compAudioProcessor
params.at(Names::Ratio_Low_Band),
sa,
3));
layout.add(std::make_unique<AudioParameterChoice>(
params.at(Names::Ratio_Mid_Band),
params.at(Names::Ratio_Mid_Band),
sa,
3));
layout.add(std::make_unique<AudioParameterChoice>(
params.at(Names::Ratio_High_Band),
params.at(Names::Ratio_High_Band),
sa,
3));


layout.add(std::make_unique<AudioParameterBool>(
params.at(Names::Bypassed_Low_Band),
params.at(Names::Bypassed_Low_Band),
false));
layout.add(std::make_unique<AudioParameterBool>(
params.at(Names::Bypassed_Mid_Band),
params.at(Names::Bypassed_Mid_Band),
false));
layout.add(std::make_unique<AudioParameterBool>(
params.at(Names::Bypassed_High_Band),
params.at(Names::Bypassed_High_Band),
false));



layout.add(std::make_unique <AudioParameterFloat>(
Expand Down
6 changes: 5 additions & 1 deletion Source/PluginProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ class Multiband_compAudioProcessor : public juce::AudioProcessor

private:

CompressorBand compressor;
std::array<CompressorBand, 3> compressor;
CompressorBand& lowBandComp = compressor[0];
CompressorBand& midBandComp = compressor[1];
CompressorBand& highBandComp = compressor[2];


using Filter = juce::dsp::LinkwitzRileyFilter<float>;
// fc0 fc1
Expand Down
16 changes: 8 additions & 8 deletions test_filtr.filtergraph
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@
</LAYOUT>
</FILTER>
<FILTER uid="5" x="0.605" y="0.5221774193548387" uiLastX_Normal="197"
uiLastY_Normal="298" uiopen_Normal="0" uiLastX_Generic="1212"
uiLastY_Generic="536" uiopen_Generic="1">
uiLastY_Normal="298" uiopen_Normal="0" uiLastX_Generic="975"
uiLastY_Generic="215" uiopen_Generic="0">
<PLUGIN name="multiband_comp" format="VST3" category="Fx" manufacturer="Aerio"
version="1.0.0" file="C:\Program Files\Common Files\VST3\multiband_comp.vst3"
uniqueId="66deea" isInstrument="0" fileTime="17ea68f169d" infoUpdateTime="17ea6976f19"
uniqueId="66deea" isInstrument="0" fileTime="17eac1e5c24" infoUpdateTime="17eac26b20d"
numInputs="2" numOutputs="2" isShell="0" uid="e958fcec"/>
<STATE>478.VMjLgTc....O+fWarAhckI2bo8la8HRLt.iHfTlai8FYo41Y8HRUTYTK3HxO9.BOVMEUy.Ea0cVZtMEcgQWY9vSRC8Vav8lak4Fc9HyMz3BTEwlXmAiUYoWUrIVdA4hKAQkKTETRUAUSAAkKBolQY4BQtHTQDQzX5UTLXEWPlM1Y2Y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0UY4BQPIDQt3hKt3hKt3BTAAkKtTETRUDUS4BQl4xaQYjKAgTTAIUUFE1ZEEiXqEjTS8VTFgjPEwVXpEjYic1cVM1ZAAkKIAkKt3hKt3hKt3RQtDjKTETRUAUSAAkKBolQY4BQPUTQPUjV3UULh4FNFElZAIjTuMlQZYFRTgEcQYjKwTjQgASUF4RPp4RPt3hKt3hKt3RPAwjKPUjZTEDLD4RPHAkVpEDTtPEUtTkaIcUV4cVLgIWTFgDS3DyXlgDUXQWTF4RLEYTXvTkQtDjZtDjKt3hKt3hKtfiKL4BTEoFUAACQtDDRPokZAAkKTQkKU4VRWkUdmESXxEkQH0zZFkkYHQEVzEkQtDSQFEFLUYjKAolKA4hKt3hKt3hK44BSt3hKt3hKt3hKt3hYRUUSTEETIckVwTjQisVTTgkdEYjKAQjYPQSPWgUdMcjKAQjct3hdA4hKt3hKt3hKtnTUv.UQAslXuk0UXoWUFE0YQcEV77RRC8Vav8lak4Fc9vyKVMEUy.Ea0cVZtMEcgQWY9..</STATE>
<LAYOUT>
<INPUTS>
<BUS index="0" layout="L R"/>
Expand All @@ -78,13 +78,13 @@
</OUTPUTS>
</LAYOUT>
</FILTER>
<FILTER uid="6" x="0.55375" y="0.2822580645161291" uiLastX_Normal="33"
uiLastY_Normal="438" uiopen_Normal="1">
<FILTER uid="6" x="0.55375" y="0.2822580645161291" uiLastX_Normal="234"
uiLastY_Normal="375" uiopen_Normal="0">
<PLUGIN name="AudioFilePlayer" format="VST3" category="Fx" manufacturer="Matkat Music LLC"
version="1.0.0" file="C:\Program Files\Common Files\VST3\AudioFilePlayer.vst3"
uniqueId="79fe81c" isInstrument="0" fileTime="17e9cde1202" infoUpdateTime="17ea6976f19"
uniqueId="79fe81c" isInstrument="0" fileTime="17e9cde1202" infoUpdateTime="17eac26b20e"
numInputs="2" numOutputs="2" isShell="0" uid="e95d02c7"/>
<STATE>314.VMjLgDS....O+fWarAhckI2bo8la8HRLt.iHfTlai8FYo41Y8HRUTYTK3HxO9.BOVMEUy.Ea0cVZtMEcgQWY9vSRC8Vav8lak4Fc9DSMw3BTIISX1UEaho2ZVkUdAAkKAwDUigWRWkEcQ0VTucmUY4BQ18TQLolShUELhsVRxHlXyY0Xz0TLYIFNpE1ZQolXuk0UYIFMTg0bqwFYvUkQWgVUVgkdAcEVoMWLWoVRWokb2YzU3giQYsFNrwTYEMUS1MiTgYWSC4hKt3hKt3hKt3hKt3hRUACTEEzZh8VVWgkdUYTTmE0UX4BQP4hPqcjXm0jLh4BQP4xPt.0Qt3hKt3hKt3hKtQUUCUEQTg2ZrM1YQcUVDUjQicVP77RRC8Vav8lak4Fc9vyKVMEUy.Ea0cVZtMEcgQWY9..</STATE>
<STATE>298.VMjLgDR....O+fWarAhckI2bo8la8HRLt.iHfTlai8FYo41Y8HRUTYTK3HxO9.BOVMEUy.Ea0cVZtMEcgQWY9vSRC8Vav8lak4Fc9DyL43BTIISX1UEaho2ZVkUdAAkKAwDUigWRWkEcQ0VTucmUY4BQ1wTQLolShUELhsVRxHlXyY0Xz0TLYIFNpE1ZQolXuk0UYIFMTg0bqwFYvUkQWQGNrMVcMYEVxgCLXcVRGM1azHUX10zPt3hKt3hKt3hKt3hKtnTUv.UQAslXuk0UXoWUFE0YQcEVtPDTtHzZGI1YMIiXtPDTtLjKPcjKt3hKt3hKt3haTU0PUQDU3sFaicVTWkEQEYzXmEDOujzPu0Fbu4VYtQmO77hUSQ0LPwVcmklaSQWXzUlO..</STATE>
<LAYOUT>
<INPUTS>
<BUS index="0" layout="L R"/>
Expand Down

0 comments on commit 7c70d9d

Please sign in to comment.