Set latency for a plugin generated with faust (faust2juce)

Hi all,
I wrote an audio plugin in faust. It has a defined latency because of a lookahead function.
As the faust2juce architecture has no option to report latency to the projucer, my question is: Where and how can I set the latency which the plugin reports back to the DAW?
Thanks!

You should use the method AudioProcessor::setLatencySamples().

Thanks. Where in the projucer code would I put that?

And is there a way to make this dependent on the samplerate?
My lookahead in faust is defined as 0.001 seconds.

There is no way to do it from the projucer, you’ll have to code it in the prepareToPlay() or processBlock() methods. You should have a look at the example DSPModuleDemoPlugin.

thank you, will try

Just a note that from my experience, putting setLatencySamples() in processBlock() is not handled well by a number of Windows hosts, resulting in audio artifacts. PrepareToPlay() is a safe place to do it.

And this is not well supported by Cubase on macOS either :wink: Indeed, it seems that prepareToPlay() is the best place to do it.

@trummerschlunk We could possibly code that at Faust DSP level using a syntax like:

  • declare options [latency_frames:<frames>] or declare options [latency_sec:<sec>]

  • the have the C++ architecture uses this metadata with AudioProcessor::setLatencySamples() in prepareToPlay() .

Would this work?

That would be awesome :slightly_smiling_face:
latency_samples would also be great.

Done in [NEW] Latency metadata added in faust2juce. Set version to 2.48.4. · grame-cncm/faust@a8dd82e · GitHub
and read faust/architecture/juce at master-dev · grame-cncm/faust · GitHub