LWJGL Forum

Programming => OpenAL => Topic started by: NateS on June 10, 2008, 01:54:06

Title: AL_SEC_OFFSET accuracy
Post by: NateS on June 10, 2008, 01:54:06
I'm synching my game to music using AL_SEC_OFFSET. I find the time this gives me doesn't update very often. Eg, the number I get only changes every 6 to 8 frames. When using Java Sound's DataLine#getMicrosecondPosition(), the number changes every frame. Because of this, my game is much smoother using Java Sound (which has a crap API). I'd really like to switch to OpenAL though.

Any ideas on how I can get a more accurate position using OpenAL?
Title: Re: AL_SEC_OFFSET accuracy
Post by: Matzon on June 10, 2008, 06:40:26
I can't help but think thee must be something odd with your game, since you designed it with such a requirement?
Why do you need to do stuff at a certain point in time, related to your sound?
Title: Re: AL_SEC_OFFSET accuracy
Post by: NateS on June 10, 2008, 19:46:04
:) The game displays lyrics synchronized to the music. I no longer think it is because OpenAL doesn't update its position fast enough. That misdiagnosis came from this...
http://lwjgl.org/forum/index.php/topic,2643.0.html
However for whatever reason, Java Sound is still smoother than OpenAL. My hunch is there is some rounding problem. I need to make a simpler test case to debug further.
Title: Re: AL_SEC_OFFSET accuracy
Post by: NateS on June 10, 2008, 23:14:33
I got a response from Dan at Creative:
Quote
Getting playback offsets is not going to be anywhere near as precise I'm afraid. The "Generic Hardware" and "Generic Software" devices only update the playback positions every 25 milliseconds.
I've finally proven this is the case. OpenAL only updates every 25ms while Java Sound updates every ~5ms.
Title: Re: AL_SEC_OFFSET accuracy
Post by: Matzon on June 11, 2008, 19:52:53
I modified PlayTest to output AL_SEC_OFFSET info. Generally I got much better resolution using openal-soft. So I suggest trying to use the latest LWJGL (2.0-rc1) which uses this on both linux and windows - but not on mac.