Latency reporting for beginners


#1

Hello fellow Jucers :slight_smile:
Is there a simple way for a newbie like me to do latency reporting to the host (cubase/logic)?

do i just include in the pluginprocessor.cpp in the processblock something like :

void AudioProcessor::setLatencySamples ( int newLatency )

am i way out of course?

Many thanks


#2

That’s generally correct. You don’t need the AudioProcessor:: part as your processor will be inherited from AudioProcessor.

It’s best practice to call setLatencySamples() from the constructor or prepareToPlay(). Calling it after the plugin has been initialized (e.g prepareToPlay()) makes some DAWs sad and can result in unexpected behavior or even crashes.


#3

Excellent, many thanks for that,
do i have to define the number of samples ?
eg. setLatencySamples(225) ?
is there any example project?
apologies for my ignorance :slight_smile:


#4

just adding
void setLatencySamples ();
is not enough… i still get the same delay…
am i missing something ?


#5

You just need to make the setLatency call in a suitable place in your code (the constructor or prepareToPlay), you should not add a new function named setLatency.


#6

Worked like a charm :slight_smile:

setLatencySamples(226.015);

is that correct though?


#7

The setLatencySamples call takes an integer, so your floating point value is not preserved. (Where are you getting that number from?)


#8

thanks Xenakios,

I am geting the number from Smaart
I take as a reference a track without the plugin and I measure it against the track with the plugin and I get 5.12 ms
then i do 44100*0.00512 = 225.792 to convert ms to samples
so it is 225.792 I want to use and not 226.015 I wrote earlier but still is the same problem with the floating point number…
should I just ignore the . part and round up to 226 ?
is this the way to go about it anyway?


#9

Set your DAW to Samples and bounce to a new track with different presets and check the difference between the source and destination… and that will give you your latency in samples. Some algorithms have variable latency – so you need to check if yours is constant or not.

Rail