Hi, I am new to this and wonder if you can help.
Can anyone recommend a good way to handle parameters in JUCE from the host (custom DAW) side? There seems to be a lot of documentation on what plugins should do, but no documentation about what the host can do to save/load plugin state.
What seems to work, and what doesn’t:
-
Plugin format manager is used to load plugins:
juce::AudioPluginFormatManager pluginFormatManager;
pluginFormatManager.addDefaultFormats(); -
From which valid instance of vst3 plugin is created:
juce::String msg;
auto instance = pluginFormatManager.createPluginInstance(*pluginDescriptions[0], sampleRate, buffsize, msg); -
This instance is initialized and works, but parameter loading is not working in any reasonable way. Enumerating is fine though:
void printParameters(const juce::Arrayjuce::AudioProcessorParameter*& parameters) {
for (auto parameter : parameters) {
std::cout << “[” << parameter->getParameterIndex() << “]\t”
<< std::setw(32) << parameter->getName(32) << “\t”
<< std::setw(16) << parameter->getValue() << “\t”
<< std::setw(16) << parameter->getNumSteps() << “\t”
<< std::setw(32) << parameter->getText(parameter->getValue(), 100)
<< std::endl;
}
}auto parameters = instance->getParameters();
printParameters(parameters); -
Some parameters can be set up to work by float values like 0.1234, which maps to, say, -18db. But they do not reflect to parameter->getValue() or parameter->getText(parameter->getValue(), 100). Audio is affected though, but only for some.
std::cout << “[” << parameter->getParameterIndex() << “] from:\t” << parameter->getValue() << “\t” << parameter->getText(parameter->getValue(), 100) << std::endl;
parameter->setValue(value);
std::cout << “[” << parameter->getParameterIndex() << “] to:\t” << value << “\t” << parameter->getText(value, 100) << std::endl;
But none of the functions seem to be able to map readable text representations to float values, or the other way around - getAllValueStrings, getText, getValueForText, etc.
Plugin tutorials speak about value trees, but they are not available on AudioPluginInstance. Like something tutorials seem to say:
parameters.replaceState(juce::ValueTree::fromXml(*xml));
Using state information does not help as well, since instance->getStateInformation/instance->setStateInformation operates with unreadable blobs of data. And the requirements are to have a readable config with text values in an externally modifiable file.
Some of the vst3 plugins have options to copy/export state, which outputs nice xml, but there seems to be no way to do it via the API.
Is there some other function or API that has to be used, or should some casting be done? There seems to be VST3PluginFormat::setStateFromVSTPresetFile, but it has no corresponding get function or any documentation that can be used.