How to get "audio time"?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to get "audio time"?

Ed Wildgoose-2
Hi

I am writing a fairly standard audio/visual app and need to get an
estimate of the current audio sample leaving the soundcard *right now*.  
With oss/alsa this is pretty straightforward, with Jack I am currently
futzing around timestamping the time of the last callback and then
implementing a simple dejitter algorithm to try and estimate the real
time of the last callback (since in reality the callback will occur some
time after it is supposed to due to scheduling delays)

Has anyone got a better suggestion for how to implement this?  Am I
missing some really obvious part of the API which gives me the current
sample position (or a decent estimate of it)?

Thanks

Ed W

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to get "audio time"?

lars.luthman (Bugzilla)
On Mon, 2007-07-02 at 17:03 +0100, Ed W wrote:

> Hi
>
> I am writing a fairly standard audio/visual app and need to get an
> estimate of the current audio sample leaving the soundcard *right now*.  
> With oss/alsa this is pretty straightforward, with Jack I am currently
> futzing around timestamping the time of the last callback and then
> implementing a simple dejitter algorithm to try and estimate the real
> time of the last callback (since in reality the callback will occur some
> time after it is supposed to due to scheduling delays)
>
> Has anyone got a better suggestion for how to implement this?  Am I
> missing some really obvious part of the API which gives me the current
> sample position (or a decent estimate of it)?
jack_frame_time() ? You have to "calibrate" it by storing its return
value at your specified 0 time and subtract that from any future return
values, but other than that it seems to be what you're looking for.


--ll

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to get "audio time"?

Fons Adriaensen-2
In reply to this post by Ed Wildgoose-2
On Mon, Jul 02, 2007 at 05:03:48PM +0100, Ed W wrote:

> I am writing a fairly standard audio/visual app and need to get an
> estimate of the current audio sample leaving the soundcard *right now*.  
> With oss/alsa this is pretty straightforward, with Jack I am currently
> futzing around timestamping the time of the last callback and then
> implementing a simple dejitter algorithm to try and estimate the real
> time of the last callback (since in reality the callback will occur some
> time after it is supposed to due to scheduling delays)
>
> Has anyone got a better suggestion for how to implement this?  Am I
> missing some really obvious part of the API which gives me the current
> sample position (or a decent estimate of it)?

Read

 a = jack_frame_time (jack_handle);
 b = jack_last_frame_time (jack_handle);

If L is the output latency (normally one period + something small for
DAC delay), then 'now' is the sample at offset a - b - L from the
start of the current period. It's negative of course because the
sample you hear "now" was processed in the previous callback.


--
FA

Follie! Follie! Delirio vano รจ questo !



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jackit-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jackit-devel