Connecting Slider to AudioProcessorParameter

Hi,

Im working on a project that loads a VST plugin into my JUCE application as an AudioProcessorGraph node. I would like to make a custom GUI for this plugin. I have access to the parameters through processor->getParameters() however their type is AudioProcessorParameter and a SliderAttachment needs a RangedAudioParameter to attach itself.

How can I connect this existing AudioProcessorParameter to my Slider? Do i need to create a new apvts and syncronize it to the existing processor? Or can I somehow extract the existing apvts from the AudioProcessorGraph processor?

Any ideas or examples would be greatly appreciated.

Does dynamic_cast work?

Do you have maybe any example of how I would use that? What would I be casting here? The processor? The parameters?

I’m not certain, but you might be able to cast your AudioProcessorParameters* that you get from getParameters() to RangedAudioParameters* and pass them into a ParameterAttachment.

The other option might be to, as you say, create an APVTS in your processor, assign it the parameters and pass it to SliderAttachment. I’ve only ever done this with vanilla plugins, though, never in an application context.

I am not sure whether dynamic_cast will work since SliderAttachment will call convertFrom0to1, convertTo0to1, etc. I would suggest passing a reference of APVTS to your component.

Yeah, I’m not really sure outside of a plugin, but I just saw in the docs that all the parameter classes above and including RangedAudioParameter are abstract so I guessed we might be dealing with an AudioParameterFloat or something in disguise.

So i’ve been able to create a separate APVTS however it’s initialised without inheriting any of the parameters of the processor that is connected.

How should I keep their states in sync?

I also tried building the APVTS parameters like this but they still do not sync.

CustomGUI::CustomGUI(juce::AudioProcessor *processor) : apvts(*processor, nullptr)
{
  for (auto param : processor->getParameters())
  {
    apvts.createAndAddParameter(param->getName(10), param->getName(10), param->getLabel(), juce::NormalisableRange<float>(0.0f, 1.0f), param->getValue(), nullptr, nullptr);
  }
  apvts.state = juce::ValueTree("vitalparams");
}

Generally you should NOT create any APVTS within your GUI code. As I said before, you may pass a reference of APVTS to your component. The constructor may look like this:

explicit CustomGUI(juce::AudioProcessorValueTreeState &parameters);

I see, however the problem still remains of how to syncronise the APVTS with the processor for the VST3

When you create the APVTS within your processor, you have already attached it to the processor. You don’t need to synchronize it afterwards.

Ah right I understand, I’m just not sure where my processor is being created. I’m using the AudioPluginHost example as my reference point.

It is obvious to you where the Processor is generated and I can create the APVTS in this example?

I really appreciate your help with this by the way, i’m starting to understand more of the JUCE framework.

I have made a mistake (I thought plugin host can access the APVTS, but it can’t).

I have just gone through some code. It seems that the host can only access the normalized parameter, i.e., the AudioProcessorParameter. Therefore, I am afraid that you have to write your own attachment instead of using SliderAttachment (by using getCurrentValueAsText)

Sorry for the confusion.

Just messing around in Plugin Host, this seemed promising:

        auto hosted = dynamic_cast<HostedAudioProcessorParameter*>(processor->getParameters()[0]);
        auto minVal = 1.0f;
        auto maxVal = 10.f;
        auto defVal = 5.f;
        AudioParameterFloat floated {hosted->getParameterID(), hosted->getName(20), minVal, maxVal, defVal};

I’ve no idea how you decent values for min, max, default, but it seems I was able to create an AudioParameterFloat.

I also don’t know how catastrophic it would be to have 2 instances of a JUCE parameter object speaking to the plugin interface…

Basically, I’m hoping if I keep replying with bad information eventually someone will get riled up enough that they want to reply with the right information.

So you’re trying to use the AudioProcessorGraph to load another company’s plugin, don’t display it and show your own UI for it ???

Is that ethical?

Yes, completely ethical, there are open source plugins available. Also this is for a development platform.

JUCE links sliders to AudioProcessor here:

Thanks! Exacty what i was looking for :slight_smile: