Breaking change AudioProcessorValueTreeState::getRawParameterValue now returns a std::atomic<float>* instead of a float*

Hello all,

I just came across the breaking change in Version 5.4.6 that getRawParameterValue now returns a std::atomic* instead of a float*.
With good hopes I tried to adopt that change in my plugin. But after several hours I found that this bascially changes larger parts of my code, probably with unexpected side-effects all over the place. Am I the only one with this trouble caused by that change?

Best regards, Tobias :sleepy:

Version 5.4.6

Change

AudioProcessorValueTreeState::getRawParameterValue now returns a
std::atomic* instead of a float*.

Possible Issues

Existing code which explicitly mentions the type of the returned value, or
interacts with the dereferenced float in ways unsupported by the std::atomic
wrapper, will fail to compile. Certain evaluation-reordering compiler
optimisations may no longer be possible.

Workaround

Update your code to deal with a std::atomic* instead of a float*.

Rationale

Returning a std::atomic* allows the JUCE framework to have much stronger
guarantees about thread safety.

Never mind. I found a solution. All good.

I am updating a pre-5.4.6 project, and this one bit me too.

For instance Decibels::decibelsToGain(*myRawParam) won’t work anymore.

My solution was to cast to a float, but I’m curious to know of other approaches.

Decibels::decibelsToGain((float)*myRawParam)

You can simply call load(), which will return the wrapped type:

auto gain = Decibels::decibelsToGain (myRawParam->load());
2 Likes

I had actually tried load(), and it got my past the first type mismatch error thrown by the Decibels class, but another error was thrown further along (can’t remember exactly what). Probably an error on my part!

Edit: Tried again, works fine. So yep, operator error! :laughing: