Audio Plugin crashing right after opening it in Ableton

I am new to JUCE and audio programming in general.
I followed this tutorial to build a very simple EQ (i just used the first hour to do that) Learn Modern C++ by Building an Audio Plugin (w/ JUCE Framework) - Full Course - YouTube
When i first build the project, I just set the sliders and visuals stuff, it worked and i could open it in Ableton
Then I added the DSP module and writed prepare to play and process block functions exactly like in the video, with no error.
The project is building without any problem, but when i open it in PluginHost or Ableton i get this message :

Do you know where it can come from ? I also tried to build the project in standalone but the window is immediately closed when i open it.
Thank you a lot

Are you running the standalone version with a debugger attached? I’d expect it to hit and assertion or throw an exception if something had gone wrong, not just silently close the window!

When i run the standalone version with the debugger i only get this error :

I actually don’t know what it means !

Have a look at the call stack - an exaction has been thrown while trying to read a value from a std::atomic, it looks like you’re doing something wrong in your prepareToPlay that’s causing a std::atomic in the APVTS to be read incorrectly.

1 Like

Ok thank you,
this is my prepareToPlay:

However I don’t see what can cause a problem, I tried running the project with line 109 to 114 removed but it didn’t change anything

Sorry, the issues coming from getChainSettings(), missed that in the stack… what’s the implementation of getChainSettings()?

This is the getChainSettings() :

I also call it in the processBlock (same line as prepareToPlay)

I guess "LowCut Slow" should be "LowCut Slope".


You are right ! thank you

1 Like

And that’s why we don’t use raw strings for IDs :wink:


N.B. you shouldn’t use getRawParameterValue like this: this function makes a rather expensive lookup, so it should be done only once in a lifetime.

Better keep a pointer to the parameter as member variable and add a jassert right after the assignment. That will catch such typos early on:

// member:
AudioProcessorFloat* lowCutFreeq = nullptr;

// in constructor:
lowCutFreq = dynamic_cast<AudioParameterFloat*>(apvts.getParameter("LowCut Freq"));
jassert (lowCutFreq);

Thanks for the tip,
This error has gone but there are others. I will try to see if i made other mistakes like this one, and implement what you said daniel

There is apparently also a problem with the getSingleChannelBlock :

It seems that its linked to the line 180 of my processBlock(sorry i cant put 2media in the same post) where I wrote :
juce::dsp::AudioBlock block(buffer);
auto leftBlock = block.getSingleChannelBlock(0);
juce::dsp::ProcessContextReplacing leftContext(leftBlock);

Do you have an idea of where it could come from ?

This is my processBlock

void HarmonicsAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
    juce::ScopedNoDenormals noDenormals;
    auto totalNumInputChannels  = getTotalNumInputChannels();
    auto totalNumOutputChannels = getTotalNumOutputChannels();

    for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
        buffer.clear (i, 0, buffer.getNumSamples());

        auto chainSettings = getChainSettings(apvts);

        auto peakCoefficients = juce::dsp::IIR::Coefficients<float>::makePeakFilter(getSampleRate(), chainSettings.peakFreq, chainSettings.peakQuality, juce::Decibels::decibelsToGain(chainSettings.peakGainInDecibels));

        *leftChain.get<ChainPositions::Peak>().coefficients = *peakCoefficients;
        *rightChain.get<ChainPositions::Peak>().coefficients = *peakCoefficients;

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



That assertion is checking if the channel index you’ve provided is less than the number of channels there are… otherwise the index would be out of range and you’d get a crash when you try to read it.

Looks like you’re passing in 0 for the channel index, which implies your audio buffer is completely empty with 0 channels… have you set up your IO properly?

The screenshot says numChannels == 1 and channel == 1, so it is set up for mono but a second channel is accessed (and it doesn’t exist).