Apply EQ Before Distortion

Hey I’m looking for a way to manipulate the EQed audio block, and I’m not sure what is the right way,
For now I wrote

for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
        buffer.clear (i, 0, buffer.getNumSamples());
        
    auto audioBlock = juce::dsp::AudioBlock<float>(buffer);
    auto context = juce::dsp::ProcessContextReplacing<float> (audioBlock);
    
    filter.process(context);

    
    for (int channel = 0; channel < totalNumInputChannels; ++channel)
    {
        auto* channelData = buffer.getWritePointer (channel);

        for(int sample = 0; sample < buffer.getNumSamples(); sample ++)
        {
            auto cleanSignal = buffer.getSample(channel, sample);

            channelData[sample] *= (driver * ranger) / 2;

            channelData[sample] = ((((((2.f / M_PI) * atan(channelData[sample])) * blender) + (cleanSignal * (1.f - blender)))/2) * volumer);

        }
        
    }

and it kinda works, but I guess that what I’m getting Is a clean eq block on top of the distorted one
Im trying to treat the filter context as a new buffer

channalData = filter.procces(context)

So basically 2 questions:

  1. Is that the right way of doing this? or tips how you’d do it otherwise
  2. If so, how would you write it?
    auto audioBlock = juce::dsp::AudioBlock<float>(buffer);
    auto context = juce::dsp::ProcessContextReplacing<float> (audioBlock);
    
    filter.process(context);

So buffer now contains the EQed signal.


    
    for (int channel = 0; channel < totalNumInputChannels; ++channel)
    {
        auto* channelData = buffer.getWritePointer (channel);

        for (int sample = 0; sample < buffer.getNumSamples(); sample ++)
        {
            auto cleanSignal = buffer.getSample(channel, sample);

Reasonable so far.


            channelData[sample] *= (driver * ranger) / 2;

Applies some gain.

This next bit is ugly to look at! Too many brackets to count :slight_smile:


            channelData[sample] = ((((((2.f / M_PI) * atan(channelData[sample])) * blender) 
     + (cleanSignal * (1.f - blender)))/2) * volumer);

So I’ll factor some stuff out for clarity. So hopefully it’s now clear why you have the clean signal mixed in! Not sure I got the brackets quite right

              cleanSignal *= (1.0f - blender) * volumer * 0.5f;
              auto drivenSignal = 2.0f / M_PI * atan(channelData[sample]) * blender;
              channelData[sample] = drivenSignal + cleanSignal;
        }  
    }
1 Like