Failure in juce_BallisticsFilter

How and where do i use chainsettings? i tried in the private of the .h file “using chainsettings” and MonoChain but i get a JUCE Assertion failure in juce_BallisticsFilter.cpp:93 error and also so slow loading up it does not work. Do i need to use the class juce_BallisticsFilter somewhere?

The assertion in juce::BallisticsFilter is telling you that the channel index you’re trying to process is outside the expected range:

template <typename SampleType>
SampleType BallisticsFilter<SampleType>::processSample (int channel, SampleType inputValue)
    jassert (isPositiveAndBelow (channel, yold.size()));

You’re processing leftChain and rightChain in your process block, but you never prepare them.

 // I created an Audio Block here
    juce::dsp::AudioBlock<float> block(buffer);
    auto leftblock = block.getSingleChannelBlock(0);
    auto rightblock = block.getSingleChannelBlock(1);
    juce::dsp::ProcessContextReplacing<float> leftContext(leftblock);
    juce::dsp::ProcessContextReplacing<float> rightContext(rightblock);

In prepareToPlay() you’ve called prepare on compressor, but then never use it elsewhere:

    juce::dsp::ProcessSpec spec;
       spec.numChannels = getTotalNumInputChannels();
       spec.sampleRate = sampleRate;
       spec.maximumBlockSize = samplesPerBlock;


I’m not sure what to do, do i use compressor in the cpp file above chainsettings or something? where do and is it just leftChain.prepare to prepare them?

Well you need to use one or the other. Currently, you’re not doing any processing with the compressor object - you’re initialising it but never using it. Inversely, you’re processing with the left/right chain objects, but you never initialise them.

If you want to continue with the separate objects for processing left and right, then you’ll need to initialise them in prepareToPlay(). If you want to have the single compressor object to handle both channels, you need to implement it in processBlock()

Okay thanks,
Have I understood this right if I have prepared the compressor replace the word compressor with the left/right chains.prepare is one way or have the compressor handle it which would be what? Compress.process in the process block? Sorry I’m not sure about the latter

is there any difference to both approaches?

To elaborate what ImJimmy said: you have in fact three dsp::Compressor objects:
compressor, leftChain and rightChain. You prepare the one and use the others, that’s why it errors using the leftChain and rightChain.

You don’t need separate compressors unless you want them to act independently (which is a rather rare use case. It distorts the stereo image).

Either you call prepare on the leftChain and rightChain or you call process on the compressor object instead of the leftChain and rightChain. Both are valid approaches. Using one compressor object has the benefit that it works for any number of channels.

The error in dsp::BallisticsFilter is a follow up error, because the Compressor uses the BallisticsFilter internally.

I think i’ve processed the compressor object in the audio block and connected params to slider classes and thats all working fine it builds and looks how it should but the compresser is still not compressing