Report Latency?
-
How do we report our plugins latency to the daw? I see there are some api's for this but Im not sure how its done.
-
@Chazrox https://docs.hise.audio/scripting/scripting-api/engine/index.html#setlatencysamples
Engine.setLatencySamples(int latency)sets the latency of the plugin as reported to the host. Default is 0
You have to calculate the latency yourself, then report it to the host with that call. Neither is automatic.
-
@dannytaurus There is also, Engine.getLatencySamples(). Do I just get and set the samples on interface script and leave it there? Do I have to create a variable or anything specific?
-
@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, thenEngine.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.
- Adjust