I have attached a slider to a value tree state, just like in the AudioProcessorValueTreeState class tutorial. This works perfectly.
Now, when I save the parameters, I would like to save all but one parameter. The parameter, that is not saved, should be set to its default value, when the plugin is restored.
How should I implement this? I have seen no method to directly change parameter using Value Trees, so that I could set it to default after restoring the value tree.
I would also like to know, if there is any way to influence a parameter attached to a slider from inside the plugin, for example via timer callbacks. Of course the parameter should still be automatable. So for example, if I have a slider, that under certain circumstances should not go over half of its range.
Is there any way to do this sensibly? Or should I reconsider my design decisions?
Hopefully I did not confuse the terms too much, I am still very new to the value tree state class etc.
As far as I understand it, this would use the AudioParameter Class, which would not work with the Value Tree State class. I definitely cannot use this method on my parameter, since it is not initialised as Audio Parameter, but as a part of the value tree using AudioProcessorValueTreeState::createAndAddParameter().
Or am I misunderstanding something here?
Thanks for your fast answer, though.
I would advise against using setValue directly, because then the host and the plugin may have different states, leading to data loss of subsequent automation (i.e. the host not sending changes, because it assumes, the plugin has already that state, if that makes sense).
Iāve tried to do that with .setProperty, the problem is, that this function takes a node of the value tree as input, not the parameter ID. The parameter ID is the only thing I have, since I set it on creation of that parameter by using createAndAddParameter(). I believe this is why it doesnāt work if I call that using APVTS.state.setProperty(āgainā, 0.0, nullptr), assuming I used APVTS.createAndAddParameter(āgainā, ā¦)
Ah, ok, so would you also advice against using setValueNotifyingHost?
I would have to make a pointer or something like that, that is assigned to the parameterWithID, so I can access it, right? There is no way I can get a pointer to the parameterWithID from of the Value Tree?
Thanks for the answers by the way, I did not really look at the return value of createAndAddParameter yet
Edit: Okay, I think I got it to work by creating a AudioParameterWithID pointer and than setting it to the address return by createAndAddParameter. Then I changed the parameter Value by using the pointer and the setValueNotifyingHost method.
Still have to run more tests, to make sure this construction is stable