Latency and Params not shown on pluginHost

Hi I created a plugin that simply has a slider that add latency to an incoming signal and that is attached to a parameter of the AudioProcessorValueTreeState.

I cloned audioPluginHost and I added It to InternalPluginFormat::InternalPluginFormat() : factory { […]

after I added a tooltip to nodes that shows me latency of plugins added.

It works fine with third party plugins, while for my LatencyProcessor is shown ever 0 samples (even if I can test that it works because I can Hear it):

Here the code to get the latency in graph:

int   getLatencyOfNodeInSamples (AudioProcessorGraph::NodeID nodeId) const { return getNode(nodeId)->getProcessor()->getLatencySamples(); }

here the code to set latency in LatencyProcessor:

void LatencyProcessor::setLatency(int delay, bool sendChange)
    if (sendChange) { sendChangeMessage(); }

(To be shure that getLatencySamples() works I added DBG(getLatencySamples()); in processBlock of LatencyProcessor and it prints the right!).

also the “generic Window” that shows parameters works for third party plugins while with this no.

Another trial that I did is create a new basic plugin project in juce and inherit from LatencyProcessor, then compiling and adding to audioPluginHost all works.

What I’m missing ? I don’t want to compile this internal plugin.

Really Thank you in advice!

Little Update on topic just for Showing paramters maybe for someone shoud be useful:

I added this code in class InternalPlugin and in this way params in generic window are shown (not sync with plugin gui, but I immagine it’s my mistake on plugin gui on call setvalueNotifyingHost or setValue):

class InternalPlugin   : public AudioPluginInstance
    explicit InternalPlugin (std::unique_ptr<AudioProcessor> innerIn)
        : inner (std::move (innerIn))
        jassert (inner != nullptr);

        for (auto isInput : { true, false })
            matchChannels (isInput);

        setBusesLayout (inner->getBusesLayout());
        int index = 1;
        for (AudioProcessorParameter* param : inner->getParameters())

            if (AudioParameterBool* boolParam = dynamic_cast<AudioParameterBool*>(param))
                std::unique_ptr<AudioParameterBool> p = std::make_unique<AudioParameterBool> (ParameterID{ boolParam->getName(1000), index++ },
                                                                                              boolParam->getName(1000), boolParam->get());
                addHostedParameter (std::move (p));
            if (AudioParameterInt* intParam = dynamic_cast<AudioParameterInt*>(param))
                std::unique_ptr<AudioParameterInt> p = std::make_unique<AudioParameterInt> (ParameterID{ intParam->getName(1000), index++ },
                                                                                            intParam->getName(1000), intParam->getRange().getStart(),
                                                                                            intParam->getRange().getEnd(), intParam->get());
                addHostedParameter (std::move (p));
            if (AudioParameterChoice* choiceParam = dynamic_cast<AudioParameterChoice*>(param))
                std::unique_ptr<AudioParameterChoice> p = std::make_unique<AudioParameterChoice> (ParameterID{ choiceParam->getName(1000), index++ },
                                                                                                  choiceParam->getName(1000), choiceParam->getAllValueStrings(), choiceParam->getIndex());
                addHostedParameter (std::move (p));
            if (AudioParameterFloat* floatParam = dynamic_cast<AudioParameterFloat*>(param))
                std::unique_ptr<AudioParameterFloat> p = std::make_unique<AudioParameterFloat> (ParameterID{ floatParam->getName(1000), index++ },
                                                                                                floatParam->getName(1000), floatParam->getNormalisableRange(), floatParam->get());
                addHostedParameter (std::move(p));

Does someone could suggest me (if it exist) a smarter way to do this ? (maybe coèing the parameterTree?)

Someone have an idea on what’s happening for “LATECY” theme?

setLatencySamples can be treated differently by different hosts. Once you report the latency, you have no idea what the host will do with that information. The best way that works for me is to call it from a timer on the message thread.

1 Like

Really thank your reply! I totally agree with you, but here the point is different, the host is mine and the internal plugin format is mine… The things I have difficult to manage is to encapsulate infos about Params and latency of my processors in the right way to manage them, as I do, easily as au or vst

Oh I see. I misunderstood but actually the answer stays the same. You will need a timer on the message thread and an Atomic parameter to read/write the latency value to make sure that the latency is working properly and the readout is correct. As for the parameters, I am not sure why you need to std::move them.

Calling setLatencySamples in prepareToPlay() should work according to this thread.

There are a few mistakes in your example though, that might or might not have an effect:

  • you shouldn’t inherit AudioProcessorInstance, but rather AudioProcessor.
    The AudioProcessorInstance is the hosting class, not the hosted (regardless if you add it via AudioPluginFormatManager or not)
  • you shouldn’t call setBusesLayout(), it is called by the host after negotiating via isBusesLayoutSupported()

Which unfortunately means you cannot make your parameters depend on the buses layout.