I’m trying to create a way to have a mix knob in my audio plugin. For that i use a juce::dsp::DryWetMixer<float>. However when i’m testing the plugin, the volume just gets turned down, as if the DryWetMixer thinks the inputsignal is empty.
I have my own processor in my ProcessChain and too a updateEffects-function to update all my processors. This works completely fine on its own and just the dryWetMixer is not working.
Here is my code:
File: PluginProcessor.h
private:
juce::dsp::DryWetMixer<float> dryWetMixer;
using ProcessorChain = juce::dsp::ProcessorChain<
juce::dsp::Gain<float>,
ExoAlgoProcessor<float>,
juce::dsp::LadderFilter<float>,
juce::dsp::Limiter<float>
>;
ProcessorChain processorChain;
File: PluginProcessor.cpp
void Plugin::prepareToPlay (double sampleRate, int samplesPerBlock)
{
juce::dsp::ProcessSpec spec;
spec.maximumBlockSize = samplesPerBlock;
spec.numChannels = getTotalNumOutputChannels();
spec.sampleRate = sampleRate;
processorChain.prepare(spec);
dryWetMixer.setWetLatency(0.0f);
updateEffects();
}
void Plugin::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();
// clear the buffer
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
juce::dsp::AudioBlock<float> block(buffer);
juce::dsp::ProcessContextReplacing<float> context(block);
// setup dryWetMixer
juce::dsp::AudioBlock<float> originalBlock(block);
auto& mixParameter = *apvts.getRawParameterValue("Mix");
auto mixingRule = juce::dsp::DryWetMixer<float>::MixingRule::linear;
dryWetMixer.setMixingRule(mixingRule);
dryWetMixer.setWetMixProportion(mixParameter);
dryWetMixer.pushDrySamples(originalBlock);
updateEffects();
processorChain.process(context);
dryWetMixer.mixWetSamples(block);
}
