DryWetMixer issues

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);
}

Solved it with setting up the juce::dsp::DryWetMixer in the processorchain and then manually processing the signal trough each processor in the processorchain.

File: PluginProcessor.h

    using ProcessorChain = juce::dsp::ProcessorChain<
        juce::dsp::DryWetMixer<float>,
        juce::dsp::Gain<float>,
        ExoAlgoProcessor<float>,
        juce::dsp::LadderFilter<float>,
        juce::dsp::Limiter<float>
    >;

File: PluginProcessor.cpp

void ExoDistAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{

    
    // setup dryWetMixer
    auto& dryWetMixer = processorChain.template get<dryWetMixerIndex>();
    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);

    
    // processing the signal through the various processors
    processorChain.template get<gainIndex>().process(context);
    processorChain.template get<exoAlgoIndex>().process(context);
    processorChain.template get<filterIndex>().process(context);
    processorChain.template get<limiterIndex>().process(context);
    
    dryWetMixer.mixWetSamples(block);
}
1 Like