Error std::atomic

Hello, I am getting this error,

Assigning to ‘float *’ from incompatible type ‘std::atomic *’

reverbTimeParameter = treeState.getRawParameterValue("reverbTime");

Could anyone help please,

getRawParameterValue () returns a pointer to an atomic float, not to a float.

const auto curValue = treeState.getRawParameterValue("reverbTime");
// where auto is a std::atomic <float>*

to use it:

... = curValue->load ();

Be aware that this result lives in the treeState, you only get a pointer to it.

Also be careful with your naming conventions, you want to get the value of a parameter, not a parameter itself.

Thank you, I will try and implement this,

Hi again, I have been wrestling with this error, I wonder if you could take a look, It would be very much appreciated, this is the error:

No viable conversion from returned value of type ‘std::atomic *’ to function return type ‘std::atomic<float *>’

Returning object of type ‘std::atomic<float *>’ invokes deleted constructor

std::atomic<float*> AudioProcessorValueTreeState::getRawParameterValue (StringRef paramID) const noexcept
    if (auto* p = getParameterAdapter (paramID))
        return &p->getRawDenormalisedValue();

    return nullptr;

reverbTimeParameter has the wrong type.

your code should be something like this:

std::atomic<float>* reverbTimeParameter;
reverbTimeParameter = treeState.getRawParameterValue("reverbTime");

now you can get your parameter value with

but if you create reverbTimeParameter only to access the value, you can also just write
float value = treeState.getRawParameterValue("reverbTime")->load();

I hope this helps

Thank you for a swift reply, not sure I understand, do you mean change this:

treeState (*this, nullptr, Identifier ("MoorerParams"), createParameterLayout() )
     thisMoorerReverb = new MoorerReverb();
    reverbTimeParameter = treeState.getRawParameterValue("reverbTime");
    diffusionParameter = treeState.getRawParameterValue("diffusion");
    modulationParameter = treeState.getRawParameterValue("modulation");

Like I mentioned before, you really must consider your naming practices.

The getRawParameterValue method (actually also a bad name, by Juce), does not return something that you should call a parameter, like reverbTimeParameter.

It returns a pointer to something deep inside that treeState. The word “Raw” should already warn you to be careful.

With respect for your interest and eagerness to dive into the (complex) domain of reverb algorithms:
also do spend a lot of time in software (tech) design lessons and the C++ language.

For example: get rid of new and delete, it will pay you back big time with more stable and trustworthy software.

Thanks for the reply, yes your right, my coding skills are letting me down.

I will truck on, hopefully, will crack this.

Many thanks

Everything Peter said was 100% correct, but dont get discouraged by the struggles at the beginning, been there :slight_smile:

No, please do not get discouraged! Keep on coding, reading books and examples, watching tutorials, lessons and remain inspired.

Truck on! Great expression :slight_smile: