How to measure plug-in latency in order to report it to host?
-
- KVRian
- Topic Starter
- 1096 posts since 28 May, 2010 from Finland
How can one measure the latency a plug-in (that one's developing) causes in order to correctly report it to the host?
-
- KVRian
- 1050 posts since 6 May, 2008 from Poland
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.
-
- KVRian
- Topic Starter
- 1096 posts since 28 May, 2010 from Finland
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.
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.
-
- KVRian
- 1050 posts since 6 May, 2008 from Poland
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.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.
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.
-
- KVRian
- Topic Starter
- 1096 posts since 28 May, 2010 from Finland
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.
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.
-
- KVRian
- 1050 posts since 6 May, 2008 from Poland
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.
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.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.
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.
-
- KVRian
- Topic Starter
- 1096 posts since 28 May, 2010 from Finland
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.
I'm also applying a Butterworth BandShelf filter from the library DSPFilters to the input audio frame.
-
- KVRian
- 1050 posts since 6 May, 2008 from Poland
Wait, what do you do with the FFT magnitudes? How does it affect the output?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.
As for your filter I don't think it has any latency to report, but I'm hardly the expert on IIRs.
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
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).
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).
-
- KVRian
- Topic Starter
- 1096 posts since 28 May, 2010 from Finland
I'm merely searching them and then my processing is based on them (the recognized ones).A_SN wrote:Wait, what do you do with the FFT magnitudes? How does it affect the output?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.
-
- KVRian
- Topic Starter
- 1096 posts since 28 May, 2010 from Finland
So latency is all the sizes of the buffers added? Do I need to consider processing that does not use buffers?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).
-
- KVRian
- 1050 posts since 6 May, 2008 from Poland
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.Fluky wrote:I'm merely searching them and then my processing is based on them (the recognized ones).
-
- KVRian
- Topic Starter
- 1096 posts since 28 May, 2010 from Finland
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.
-
- KVRian
- 1050 posts since 6 May, 2008 from Poland
If you tried nulling and it nulls right then your latency is 0 (as I'm starting to suspect).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.
-
- KVRian
- Topic Starter
- 1096 posts since 28 May, 2010 from Finland
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?A_SN wrote:If you tried nulling and it nulls right then your latency is 0 (as I'm starting to suspect).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.
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.