Handling parameters in JUCE from the host side

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:

  1. Plugin format manager is used to load plugins:

    juce::AudioPluginFormatManager pluginFormatManager;
    pluginFormatManager.addDefaultFormats();

  2. From which valid instance of vst3 plugin is created:

    juce::String msg;
    auto instance = pluginFormatManager.createPluginInstance(*pluginDescriptions[0], sampleRate, buffsize, msg);

  3. 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);

  4. 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.

anyone?

When you host plugins, they are not necessarily made with juce. From the host’s perspective there is no AudioParameterBool or such things. Only the AudioProcessorParameter methods are available.
(There is a subclass PluginInstance::Parameter, but afaics it doesn’t add too many options)

For the host all parameters are normalised from 0 to 1.

If the plugin implements the textToValue and valueToText properly, you should be able to convert into a textual representation and back, e.g. getCurrentValueAsText() etc.

It might be, that getAllValuesAsStrings() only works if isDiscrete() returns true.
You can have a look into the source of GenericAudioProcessorEditor, that uses sometimes heuristics to do the right thing for a parameter.

1 Like