How setting value of an audioParameter through osc?

Hi, I have a plugin with an audioParameter that can receive osc messages. To set his value I use this code:
void AudioProcessor::oscMessageReceived (const OSCMessage& message)
{
if (message.size() == 1) {
if (message.getAddressPattern().toString() == “/juce/prova1”)
{
processorValueTreeState.getParameter(“volume”)->setValueNotifyingHost(message.begin()->getFloat32());
}
}
}

The problem is that the message that I send via osc has a range of -140.0 as min value and 6.0 as max value (and if I print “DBG(message.begin()->getFloat32());”) I can see that it is correct), but “processorValueTreeState.getParameter(“volume”)->setValueNotifyingHost(message.begin()->getFloat32());” works only when the incoming messages have value between 0.0 and 1.0… What’s the problem here?

thank you in advice!

Parameters are internally stored with a range [0.0f; 1.0f]. So you first have to convert your [-140.0; 6.0] to the normalised one

auto normalisedValue = processorValueTreeState.getParameterRange ("volume").convertTo0to1 (yourOscValue);
3 Likes

@danielrudrich really really thank you! now it works! :slight_smile: