How to measure plug-in latency in order to report it to host?

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

How can one measure the latency a plug-in (that one's developing) causes in order to correctly report it to the host?

Post

You don't measure it, you calculate it, and that depends entirely on your algorithm. If you just copy input samples to the output then you have a latency of 0 samples. Otherwise you should know if your algorithm introduces any latency and how much.
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral

Post

I don't know how much my algorithms e.g. a STFT from a library called Gamma produce latency for the data that I'm inputting there. How can I determine those?

Or does latency correspond to the amount of samples that must be hold in the plug-in (some internal buffers) before any audio output is generated.

Post

Fluky wrote:I don't know how much my algorithms e.g. a STFT from a library called Gamma produce latency for the data that I'm inputting there. How can I determine those?

Or does latency correspond to the amount of samples that must be hold in the plug-in before any audio output is generated.
What do you do with the STFT? Depending on what you do (I assume some kind of spectral processing?) your latency might be something like half the length of a STFT chunk. Although that depends on how you feed input to it I guess... hard to tell without knowing anything about your algorithm.

If you're not sure remember to try nulling your input and output, that means subtracting the two signals together to make sure they cancel out. I would recommend against using any number you might find from using that technique to measure the latency by guesswork if you don't understand what that number means or it won't work if you have different parameters/sampling rate.
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral

Post

Can I not measure the latency by disabling PDC in a DAW and then merely recording the input and output and see if there's any latency?

Calculating the latency by speculating on how much an algorithm (which one doesn't necessarily even know) takes time without measuring it sounds pretty complicated to me.

Post

Fluky wrote:Can I not measure the latency by disabling PDC in a DAW and then merely recording the input and output and see if there's any latency?
A_SN wrote:I would recommend against using any number you might find from using that technique to measure the latency by guesswork if you don't understand what that number means or it won't work if you have different parameters/sampling rate.
Fluky wrote:Calculating the latency by speculating on how much an algorithm (which one doesn't necessarily even know) takes time without measuring it sounds pretty complicated to me.
If you don't understand the algorithm your plugin uses well enough to calculate its latency yourself you've got a problem. A problem you should solve rather than avoid.

What do you use a STFT for and what parameters (i.e. window size) do you specify? Just tell me and I'll help you figure it out.
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral

Post

I'm taking a STFT (window size 1024) in order to find FFT magnitudes. The number of bins (their magnitudes) that I'm interested in is around 3-5. The magnitudes are found in for loops with some comparison logic.

I'm also applying a Butterworth BandShelf filter from the library DSPFilters to the input audio frame.

Post

Fluky wrote:I'm taking a STFT (window size 1024) in order to find FFT magnitudes. The number of bins (their magnitudes) that I'm interested in is around 3-5. The magnitudes are found in for loops with some comparison logic.

I'm also applying a Butterworth BandShelf filter from the library DSPFilters to the input audio frame.
Wait, what do you do with the FFT magnitudes? How does it affect the output?

As for your filter I don't think it has any latency to report, but I'm hardly the expert on IIRs.
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral

Post

The EQ should not have any delay, so this one is fine.
The STFT will have a latency proportional to its size. That's because you can't get an output before you get 1024 elements in your case. So the latency for this plugin will be 1024 samples (at least).

Post

A_SN wrote:
Fluky wrote:I'm taking a STFT (window size 1024) in order to find FFT magnitudes. The number of bins (their magnitudes) that I'm interested in is around 3-5. The magnitudes are found in for loops with some comparison logic.

I'm also applying a Butterworth BandShelf filter from the library DSPFilters to the input audio frame.
Wait, what do you do with the FFT magnitudes? How does it affect the output?
I'm merely searching them and then my processing is based on them (the recognized ones).

Post

Miles1981 wrote:The EQ should not have any delay, so this one is fine.
The STFT will have a latency proportional to its size. That's because you can't get an output before you get 1024 elements in your case. So the latency for this plugin will be 1024 samples (at least).
So latency is all the sizes of the buffers added? Do I need to consider processing that does not use buffers?

Post

Fluky wrote:I'm merely searching them and then my processing is based on them (the recognized ones).
If you don't actually delay the samples that you're processing with then you have no added latency. However your magnitudes might be a bit outdated with respect to the signal you're processing.
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral

Post

Also, how does one conduct when the latency is reporting correctly? Currently I cannot hear nor see delay between my plug-in's input and output, even if I'm reporting 0 latency.

Post

Fluky wrote:Also, how does one conduct when the latency is reporting correctly? Currently I cannot hear nor see delay between my plug-in's input and output, even if I'm reporting 0 latency.
If you tried nulling and it nulls right then your latency is 0 (as I'm starting to suspect).
Developer of Photosounder (a spectral editor/synth), SplineEQ and Spiral

Post

A_SN wrote:
Fluky wrote:Also, how does one conduct when the latency is reporting correctly? Currently I cannot hear nor see delay between my plug-in's input and output, even if I'm reporting 0 latency.
If you tried nulling and it nulls right then your latency is 0 (as I'm starting to suspect).
Of course it does not null, because the output signal is different (it's processed), but since the waves are recognizable and align, then this would still mean latency 0?

Technically I shouldn't output any processed samples before the STFT has been filled (1024 samples), because I need that to determine my processing. I can merely output the input or zeros though during those 1024 samples.

Post Reply

Return to “DSP and Plugin Development”