Setting RangedAudioParameter manually using setValueNotifyingHost()

Hello all! I just wanted to point out something that was stumping me for the longest time.

I kept trying to set a RangedAudioParameter held inside an APVTS.

// Parameter created when intializing apvts parameter layout
params.push_back(std::make_unique<AudioParameterFloat>
("LFO Source", "LFO Source", NormalisableRange<float>(0.f, 3.f, 1.f), 0.f)); 

///////// Setting this parameter using setValueNotifyingHost(float value)
auto paramID = Identifier("LFO Source"); 
float lfoSourceVal = 1.f;

RangedAudioParameter* pParam = valueTree.getParameter(paramID);
pParam->beginChangeGesture();
pParam->setValueNotifyingHost(lfoSourceVal);
pParam->endChangeGesture();

The above code sets the RangedAudioParameter to 3. I didn’t realize that it needed normalized values in the setValueNotifyingHost() function like so:

pParam->setValueNotifyingHost(pParam->convertFrom0To1(lfoSourceVal));

It makes sense because it is a RangedAudioParameter, I just didn’t realize I needed to normalize it!

Easy fix, hope it helps you if you are getting stuck with a similar issue.