[SOLVED] AudioProcessorValueTreeState: reset all sliders to default, from code?


I have a plugin that uses AudioProcessorValueTreeState to manage its state, with a bunch of sliders in the UI.

I’d like to add something like an “INIT” button to reset all sliders to their initial position; each parameter has a default value which is set it in createParameterLayout(), and can be easily recalled by double-clicking the sliders).

But how can I achieve the same result from my code?
Is there any built-in mechanism to do this? I took a look at the docs but couldn’t find what I was looking for.
I tried to manually access my parameters and then call something like

freqParam->setValue (freqParam->getDefaultValue());

but I got an error saying that AudioParameterFloat::setValue is inaccessible.

I got the feeling that I’m trying to reinvent the wheel here. Any thoughts?

Many thanks!!



From the documentation of AudioProcessorParameter::setValue:

If you want to set the value of a parameter internally, e.g. from your
editor component, then don’t call this directly - instead, use the
setValueNotifyingHost() method, which will also send a message to
the host telling it about the change. If the message isn’t sent, the host
won’t be able to automate your parameters properly.

I hope this helps.



Right… I completely missed that - thanks! :slight_smile:

For the records, after doing this,the next problem was that getDefaultValue is also private so it can’t be accessed; I found some useful tips on this thread and managed to get it working.

1 Like