Look-ahead vs DAW's latency compensation


#1

Hello,
maybe first I should just build my own algorithm and test it, but I am so curious that I can’t stand waiting :slight_smile:

The question is:
If my plugin causes latency (for example while I am using look-ahead), and my DAW has latency compensation turned ON, then does compensation happen automatically? Or should I set some flag containing latency value that DAW can compensate latency according to that special flag?

Intuition tells me that I should use some flag, because DAW doesn’t know if I made latency intentionaly (for example for phase shift or some delay) or it’s just technical error that need to be compensated.

If I am right, could you help me and tell how to send such info to the DAW? I use at the moment Logic Pro X


#2
void AudioProcessor::setLatencySamples (int newLatency )

Your processor subclass should call this to set the number of samples delay that it introduces.

The processor should call this as soon as it can during initialisation, and can call it later if the value changes.

Note that attempting the on-the-fly latency changes might not work in many hosts. You should play it safe and set the maximum latency your plugin will ever produce. Then to compensate for that, you will need to do some internal buffering in the plugin if the internal latency is actually lower.


#3

Ideally in prepareToPlay you call setLatencySamples() to tell the host, how many samples latency you will add.

PrepareToPlay is the right moment, since that is, where you know the actual sampleRate to convert your mili seconds into samples, and it is before the processing starts. The host wouldn’t like it to change the latency compensation during playback (and like Xenakios mentioned, in that case it would most likely ignore that).

Also be aware, that latency compensation obviously only works for recorded material. The live played track (i.e. monitoring or recording) will have the latency, but when you play back next time, it will be compensated… (the host just can’t see the future, even though the name look ahead suggests that)


#4

Hey great thanks for your support.
But there are 2 more questions:

  1. If I want use setLatencySamples() after initialisation, when some user change settings in the plugin, is it enough if I just cal setLatencySamples(), and it will automatically inform DAW about changes? Or should I do something more?

  2. does setLatencySamples() works with all hosts? How to find info about that? Once upon a time I tried to contact with Logic Pro developers to ask something (about “bypass” flag) but with no result. Probably I used some wrong way - I contacted through apple development, but they told me I should try with Logic support, but it takes me to regular apple support, and I plan the telephone call, but then the mechanical bot wast talking to me to wait but nowbody answered.


#5

At least Ableton live correctly reports the latency when changing the latency thru a parameter change (ie. oversampling). I did not test does it actually compensate the latency in real-time.