Re: [Jack-Devel] How to sync non-audio actions to JACK audio?

PrevNext  Index
DateFri, 18 Feb 2011 17:28:52 -0500
From Paul Davis <[hidden] at linuxaudiosystems dot com>
ToFelix Homann <[hidden] at web dot de>
Cc[hidden] at lists dot jackaudio dot org
In-Reply-ToFelix Homann [Jack-Devel] How to sync non-audio actions to JACK audio?
On Fri, Feb 18, 2011 at 3:59 PM, Felix Homann <[hidden]> wrote:
> Hi again,
>
> here's another question for a better understanding of JACK.
>
> I want to sync non-audio actions as sample accurate as possible to a sound
> file. For example, video playback or as in my case, I want to trigger some
> actions via OSC (Open Sound Control) instead of MIDI.
>
> Say, my process() callback has just written N audio frames to an output
> buffer. I want to call some function as exactly as possible when frame
> number n  (with 0 < = n <= N) is "played". When is frame number n actually
>  "played" after process() was called? What means are there in the JACK API
> to sync external non-audio actions to audio? Are there some examples for
> best practices?

Because of JACK's freely connectable graph, in theory there is no
single answer to the question "when will this audio be played",
because the audio could go via multiple routes to an output, or not go
to an output at all.

In the real world, although these configurations are possible, they
are very common.

The port latency API allows you to determine the latency associated
with a particular port. You should see jack_port_get_total_latency()
which returns:

   "The maximum of the sum of the latencies in every connection path
that can be drawn between the port and other ports with the
JackPortIsTerminal flag set."

HOWEVER ... this API is broken, and the next release of JACK will
include a complete replacement for it. Its not broken for some common
cases, but is broken for others. The breakage arises because JACK
cannot know about internal signal flow within clients, and the current
latency API only takes into account flow via connections that JACK
knows about. For simple cases, eg. a player connected directly to the
backend ports, this is not a problem.

--p
PrevNext  Index

1298068148.9407_0.ltw:2,a <AANLkTikf9EXOXtSC7cyN-x1ANjNp2+hGHSi17xtCtswB at mail dot gmail dot com>