Hello everyone.
I`m using AudioProcessorValueTreeState for save parameters of my compressor, but I was collapsed with a problem;
I converted values from gain to decibels with NormalisableRange and lambda in createParameter() method.
auto value = [](float value, int) { return String(std::log10(value) * 20.0f); };
auto userValue = [](const String& string)
{
if (string.getFloatValue() >= -48.0f)
{
return juce::jlimit(0.0f, 2.0f, std::powf(10, string.getFloatValue() * 0.05));
}
if (string.getFloatValue() < -48.0f)
{
return 0.0f / 20.0f;
}
};
auto overallGainParam = std::make_unique<AudioParameterFloat>(OVERALL_GAIN_ID, OVERALL_GAIN_NAME, NormalisableRange<float>(0.0f, 2.0f, 0.1f), 1.0f, "", AudioProcessorParameter::inputGain, value, userValue);
params.push_back(std::move(overallGainParam));
But now I can not correctly save parameters to XML. I noticed that when I build the code and run the plugin for the first time, a file is created in my Users folder with the extension .settings . When I call the plugin a second time, my previous settings are returned in a slightly modified form. Each subsequent time the plugin restores the state that was saved after the first call. .settings file is not updated. Has anyone had this problem? Does anyone know how to deal with this?
I have run out of solutions to the problem, SOS!!!
This enum value is not a parameter, but instead it is used to send a current value to the host to display in their meters (first seen in AAX, but I think other formats have that as well).
You should keep using AudioProcessorParameter::genericParameter if you want to save that value.
I tried to write this value there, the problem is not solved. Sliders are saved only once. Whatever I change further, every time I open the project, the state is returned to me as after the first session. Perhaps the problem is in the XML format or in my file system? I have not tested the plugin on other machines and I do not have this option.
Not sure what you mean by “call the plugin a second time”. Maybe a stupid question, but are you loading a saved session that had that plugin in it, or opening a new instance of the plugin?
What I see is that the volume values have not changed, and some other values have not been preserved accurately. Because I remember exactly that I lowered the threshold to -50.