@Chazrox said in Report Latency?:
Engine.getLatencySamples()
All that does is give you back the number you already set manually with Engine.setLatencySamples().
If your plugin introduces latency (not all do) then you have to calculate or measure the amount of latency in samples and set it in Engine.setLatencySamples(), which is then reported to the host by HISE/JUCE.
If your plugin has a variable amount of latency, possibly from switching a latency-producing effect in/out, then you have to either:
Adjust Engine.setLatencySamples() in realtime, as the amount changes, so the new value is reported to the host, or
Report a larger fixed value to the host and compensate yourself within the plugin.
Example: if you have a effect in your synth that uses oversampling and introduces 100 samples of latency, you can either:
Use Engine.setLatencySamples(100) every time the effect is enabled in the synth, then Engine.setLatencySamples(0) when it's disabled, or
Set Engine.setLatencySamples(100) at initialisation then compensate yourself in the plugin by adding a fixed delay of 100 samples when the effect is disabled and removing the delay when the effect is enabled.
The second method seems better because you're reporting a fixed amount to the host them compensating within your own plugin.
If you use the first method and keep reporting different amounts of latency to the host, you won't know exactly when or how the host will apply the new latency value (next block, next play, will it glitch when it changes, etc.)
It sounds complicated but it isn't when you get your head around it.