Hello All,
I’m trying to set some parameters non-automatable in an audio plugin. The plugin uses APVTS and parameterLayout() to create and update parameters.
Parameters like drop down menus are required to be set/updated and retrieved but not needed to be automated. I’ve tried all kinds of notifyingHost functions available, but does not work on all DAWs.
On researching similar posts, bumped into this one, and looks like it will help solving my issue.
This is the first time I’m exploring this function, so unable to understand how can I use it in my processor code to make it work ?
If someone can help with example code/project that’d be great. TIA!
@reuk Thank you, is there any way to use Attributes().withAutomatable (false) in add function of parameterLayour::add ? the current setup uses something like this,
parameter.add(
std::make_unique<juce::AudioParameterFloat>("abc", // parameterID
"ABC", // parameter name
NormalisableRange<float>(0.0f, 1.f, 1.f), //normalisableRange
0.f, // default value
String(), // parameterLabel
AudioProcessorParameter::genericParameter, //parameterCategory
);
parameter.add(
std::make_unique<juce::AudioParameterFloat>("xyz", // parameterID
"XYZ", // parameter name
-1, // minimum value
1, // maximum value
0) // default value
);
I’m aware that DAWs ignore this flag, but looking to implement it for some parameters which are not needed to be automated, but should be in APVTS so it retains it’s state when closing and reopening the plugin editor.
Majority like ComboBox, Text buttons etc.
Another way is to manually store & read these parameters in getStateInformation & setStateInformation respectively. If these parameters are UI related, you also need to link them with UI in a proper way.
Another example (where I store the version number and something from controller):
void PluginProcessor::getStateInformation (juce::MemoryBlock& destData) {
auto state = parameters.copyState();
auto conState = state.getOrCreateChildWithName ("conState", nullptr);
conState.setProperty ("diffs", controller.toString(), nullptr);
auto version = state.getOrCreateChildWithName ("version", nullptr);
version.setProperty ("string", JucePlugin_VersionString, nullptr);
std::unique_ptr<juce::XmlElement> xml (state.createXml());
copyXmlToBinary (*xml, destData);
}
void PluginProcessor::setStateInformation (const void* data, int sizeInBytes) {
std::unique_ptr<juce::XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes));
if (xmlState != nullptr) {
if (xmlState->hasTagName (parameters.state.getType())) {
auto state = juce::ValueTree::fromXml (*xmlState);
auto diffs = state.getChildWithName ("conState");
auto version = state.getChildWithName ("version");
if (diffs.isValid() && version.isValid()) {
state.removeChild (diffs, nullptr);
state.removeChild (version, nullptr);
if (version.getProperty ("string", "") == JucePlugin_VersionString) {
controller.fromString (diffs.getProperty ("diffs", ""));
}
}
parameters.replaceState (state);
}
}
}
Another way is to create an extra APVTS that is not attached to the PluginProcessor someone mentioned this somewhere, but I haven’t tried it.
@zsliu98 Thank you for the suggestion, is “uiState” is separate state? and then adding all parameters as group? Also how to decide on ID if you have state already?
But I don’t see this retaining when plugin editor is closed and reopened.
For instance, I’m setting this slider at 0.3 from UI, and when closing and reopening the UI, this setting is gone.
Taking this approach will sustain the set values for parameters on close/reopen plugin editor?
(I’m using ParameterLayout& ParameterLayout::add to add ‘Audio’ parameters to APVTS.)
I am adding a child to the state of APVTS. The child (a value tree) is initialized by "uiState", { { "width", ZLInterface::WindowWidth }, { "height", ZLInterface::WindowHeight } }, {}.
right, but how to use it with actual UI parameter like a slider or button or menu?
I’ve a current setup that uses APVTS even for the parameters that are not supposed to be automated , but added to APVTS to retain it’s state when plugin editor is closed or reopened.