Minimum reasonable latency Was: Re: ZynAddSubFX was: Re: [linux-audio-dev] some new soundfiles on-line

fons adriaensen fons.adriaensen at skynet.be
Thu May 19 21:03:36 UTC 2005


On Thu, May 19, 2005 at 05:59:25PM +0200, Florian Schmidt wrote:

> > You shouldn't check for events int jack_process(), but in a separate
> > thread, linked to jack_process() using a lock-free circular buffer for
> > the [event+timestamp] data.
> 
> Of course. I assumed that you assumed that i know this :) But this is
> not the problem. I still insist: To get constant latency you have to
> take 2 periods worth latency into account.

The scheme I described will give you exactly 2 periods latency.


cycle  N                   N+1                 N+2                 N+3
------|ppp------------E---|ppp----------------|ppp------------S---|ppp---
      |               ^   |                   |               ^   |
frame k              k+i  k+n                 k+2n         k+2n+i k+3n 


ppp = jack_process() running
n = period size

Consider the event E. Its frame_time is k+i, we add n to get k+n+i, and
put this into the queue read by jack_process(). In cycle N+1, jack_process()
calculates the offset for the events it finds in the queue. For E, it will
find offs = k+n+i - k+n = i, and offs < n, so it will put the audio signal
corresponding to E starting at sample i in the current period. That sample
has a latency w.r.t. the start of the current period of n+i, so we will hear
the event at the place marked S, exactly two periods after E.
 
The latency of two periods is composed of one period from the hardware,and
one period we added to the timestamp of the event.

-- 
FA



More information about the Linux-audio-dev mailing list