[Openal] Synchronizing multiple sources, and determining current position

nic at weartronics.com nic at weartronics.com
Tue Oct 3 21:45:20 PDT 2006


Dear OpenAL list,

I am building an application which has a timeline containing multiple
video and audio tracks which can be played simultaneously, much like a
video editing application.

>From my reading, I understand that the sound card playback rate is
determined by an onboard clock (as opposed to the system clock), and this
sound card clock can vary the playback rate by as much as +/-10%,
especially in the case of poor quality cards. Therefore it is not feasible
to time the presentation of audio data based on the system clock because
there will be noticable artifacts when data is dropped or delayed.

I understand the usual solution for applications of this type is to keep
the buffers filled, allowing the card to play the data at its own rate and
accept this wrong playback rate. The presentation of the video frames can
then be timed from the sound card clock because video frames can be
dropped or delayed without being noticed by the user.

My questions is, how can I do this with OpenAL?

>From what I read, the only way to determine the current playback position
is by polling AL_SEC_OFFSET (or samples or  bytes) for a particular
source. So, if I mixed all the audio tracks in software, I could play the
data using a single OpenAL source and use this to time the presentation of
the video frames. Would this be a recommended solution? i.e. is there a
more appropriate solution than polling AL_SEC_OFFSET?

If possible, I would prefer to play back each audio track as it's own
OpenAL source to take advantage of hardware mixing. But what sort of
synchronism can be expected between sources with different sampling rates
/ frequencies / channels etc... playing back on the same hardware?

Any comments or ideas are welcome!

Best regards,

Nic


More information about the Openal mailing list