setValueNotifyingHost() behaving weirdly

First of all, please make your code a bit more readable:

var value = 1; // I assume you have a reason to not make this value float to avoid later cast

// set value on AudioProcessorValueTreeState:
auto* param = m_value_tree.getParameter (name);
auto  oldValue = param->convertTo0to1 ((float)value);
param->setValueNotifyingHost (param->convertTo0to1 ((float)value));

Your problem could be, that the host is not expecting the value to change, because you didn’t send a beginChangeGesture() and endChangeGesture(). So it could either ignore it or immediately overwrite it with the previous automated value. I think it is not defined, what should happen.

You should call

auto* param = m_value_tree.getParameter (name);
auto  oldValue = param->convertTo0to1 ((float)value);
param->beginChangeGesture();
param->setValueNotifyingHost (param->convertTo0to1 ((float)value));
param->endChangeGesture();

see the docs: setValueNotifyingHost()

1 Like