getRawParameterValue causes reverb to crash

Hello everyone,

I am working on a convolution reverb plugin and I am getting some strange behavior. As a preface, I just completed a compressor using JUCE and have followed up using similar boiler plate code regarding the AudioProcessorValueTreeState class.

However, when I do the following, my code breaks.

void ConvolutionReverbAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& midiMessages)

ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();

// float*  preDelay = parameters.getRawParameterValue("pre_delay");
float*  gain = parameters.getRawParameterValue("gain");
float*  width = parameters.getRawParameterValue("width");
float*  dry = parameters.getRawParameterValue("dry");
float*  wet = parameters.getRawParameterValue("wet");
float*  size = parameters.getRawParameterValue("size");
float* damping = parameters.getRawParameterValue("damping");
float* freeze = parameters.getRawParameterValue("freezing");

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

for (int channel = 0; channel < totalNumInputChannels; ++channel)
   // auto* channelData = buffer.getWritePointer (channel);
    // Reset params
    reverbParams.dryLevel = *dry;
    reverbParams.wetLevel = *wet;
    reverbParams.roomSize = *size;
    reverbParams.damping = *damping;
    reverbParams.freezeMode = *freeze;
    reverbParams.width = *width;
    reverbState.setParameters (reverbParams);
    // If mono
    if (totalNumInputChannels == 1)
        reverbState.processMono (buffer.getWritePointer(0), buffer.getNumSamples());
    // If Stereo
    else if (totalNumInputChannels == 2)
        reverbState.processStereo(buffer.getWritePointer(0), buffer.getWritePointer(1), buffer.getNumSamples());
    // Apply the gain


In my previous plugin, this worked just fine. However, whenever I comment the reverbParams. variables, the plugin runs and is able to be used in a DAW or the plugin host. If I allow those variables to be in the code, it breaks upon opening the program.

Could anyone provide me with some guidance as to what may be going wrong?

PS this is my prepare to play

void ConvolutionReverbAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)

reverbParams.dryLevel = 0.2f;
reverbParams.wetLevel = 0.0f;
reverbParams.roomSize = 0.0f;
reverbParams.damping = 0.0f;
reverbParams.freezeMode = 0.4;
reverbState.setSampleRate (sampleRate);
reverbState.setParameters (reverbParams);

I don’t know how to delete posts on here, but I fixed the problem. I named one of my avpts variables freeze not freezing. My bad.

1 Like

Have you looked in the debugger what problem exactly is happening at run time?

My initial guess is that you are getting back a null pointer from one or more of the getRawParameterValue calls.

Another example why the copy/paste on computers do more harm than help :wink:

When I need strings, I make sure that they exist only in one place as literals. All others should just reference them, so the compiler will spot the error. Here an example: