In this commit, @tpoole made the audio parameter classes thread safe by backing with a std::atomic<float>
rather than a float
.
However, the documentation for AudioProcessorValueTreeState
still states:
/** Returns a parameter by its ID string. */
RangedAudioParameter* getParameter (StringRef parameterID) const noexcept;
/** Returns a pointer to a floating point representation of a particular parameter which a realtime process can read to find out its current value.
*/
std::atomic<float>* getRawParameterValue (StringRef parameterID) const noexcept;
Digging into the implementation, they both call getParameterAdapter (paramID)
. Then the “Raw” version returns a pointer to a cached std::atomic<float>
and the non-raw version returns a pointer to the underlying RangedAudioParameter
It seems to me that now that the RangedAudioParameter
classes are backed by an atomic, calling getParameter()
from a realtime process should also be safe.
Can anyone confirm?
Assuming I’m correct, is there any reason to prefer getRawParameterValue()
besides avoiding the overhead of converting between normalised / non-normalised values?