Compressor Crashing

Hi all,

I hope you are all well,

I’ve been trying to build this compressor i’m at the final bit and I just want to be able to audible changes, I though I had followed all the advice given to me and it still does not work, it builds but it does not scan into audio host and it is classed as crashed validation in Logic pro.

Please take a look at the github file

Kind regards,


I think the part you commented out was the right approach:

void parameterChanged (const juce::String& parameterID, float newValue) dont need this now
    if (parameterID == "THRESHOLD")
        compressor.setThreshold (newValue);
    // and so on

Additionally you need to subscribe to the AudioProcessorValueTreeState in the constructor:

apvts.addParameterListener ("THRESHOLD");

And the parameterID is the first argument when you created the AudioParameter. Try verifying using a breakpoint in the parameterChanged() callback to see if you actually get those messages.

Good luck

N.B. there are pros and cons of using parameterChanged vs. getRawParameterValue().
I didn’t check if setThreshold on the compressor is thread safe, because the callbacks can come from any thread.

apvts(*this, nullptr, "Parameter", createParameters())

You’re calling this in your constructor member initializer list.
Since this createParameters() function is accessing the atomic members before the apvts has been fully constructed, it is possible that those atomics have not been constructed yet, and that is the cause of the crash. They are declared after the apvts, and member variables are constructed in the order that they are declared.

Move the assignment of those atomics to the constructor BODY.
This will ensure that those atomics have been fully constructed before you try to access them/assign values to them.

#ifndef JucePlugin_PreferredChannelConfigurations
     : AudioProcessor (BusesProperties()
                     #if ! JucePlugin_IsMidiEffect
                      #if ! JucePlugin_IsSynth
                       .withInput  ("Input",  juce::AudioChannelSet::stereo(), true)
                       .withOutput ("Output", juce::AudioChannelSet::stereo(), true)
                       ), apvts(*this, nullptr, "Parameter", createParameters()) 

    //initialize those atomics here, NOT in `createParameters()`, 
    //which should be a static function

this is what happens in your createParameters function:

    thresholdRaw  = apvts.getRawParameterValue ("THRESHOLD");
    ratioRaw      = apvts.getRawParameterValue ("RATIO");

you’re calling member functions of the apvts, yet it is still being constructed.


Thank you,

I’m trying to follow along with the guidance, this build now fails, I’ve tried different orders and combinations of what you have said, unfortunately having no luck, here is one of the combinations:

Kind regards,


Thank you. What are some if the pro’s and cons? do you have resource of this information?

Kind regards,