Modify dsp::compressor to enable sidechaining

Hi there,

I would like to modify the juce::dsp::compressor modul to be able to sidechain with it.
Therefore I would copy most of the processSample() of juce_Compressor.cpp and give my new functions 3 instead of 2 paramters:

So in my case:

processSample::processSample_mod (int channel, SampleType sideChain, SampleType inputValue){}

Can someone explain me the two functions of the processSample() method?

auto env = envelopeFilter.processSample (channel, inputValue);
auto gain = (env < threshold) ? static_cast<SampleType> (1.0)
                                  : std::pow (env * thresholdInverse, ratioInverse - static_cast<SampleType> (1.0));

What I already tried is:

SampleType Compressor<SampleType>::processSample_mod (int channel, SampleType sideChain, SampleType inputValue)
{
    // Ballistics filter with peak rectifier
    auto env = envelopeFilter.processSample (channel, sideChain);
    // VCA
    auto gain = (env < threshold) ? static_cast<SampleType> (1.0)
                                  : std::pow (env * thresholdInverse, ratioInverse - static_cast<SampleType> (1.0));

    // Output
    return gain * inputValue;
}

With this approach, the compressor already works halfway, but the attack time of the compressor is not working correctly. Any ideas how to solve this?