[Openal] AL_*_OFFSET resolution
Chris Robinson
chris.kcat at gmail.com
Fri Dec 7 18:46:57 PST 2007
On Friday 07 December 2007 09:15:50 am Ben Swanson wrote:
> I am attempting to sync an animation to a sound file using the
> AL_SEC_OFFSET property. The problem I am having is that the resolution of
> the command seems to be 4096 samples, which leads to a choppy animation.
> Is there a way to change this (the sound file is in ogg vorbis format)?
>
> Ben
Audio isn't usually a good thing to exclusively time animation by, really. As
you've noted, there's an approximately 4K frame update size (* 2 channels * 2
bytes per sample = 16K bytes, a bit high but still somewhat reasonable for
display sync).
What implementation are you using? If you're using the Sample Implemention
(Linux, FreeBSD, Solaris, etc), then part of the problem is the mixer
inefficiency which pretty much requires a large(r) buffer or else it'll miss
sound card updates. In this case, you can try OpenAL Soft (
http://kcat.strangesoft.net/openal.html ) which has a few advantages: first
being that it has a much cleaner mixer, so smaller update sizes should be
possible.. and also (at least when using the ALSA backend) it uses ALSA in
mmap mode which lets the mixer write however many samples it needs directly
to the audio buffer when it needs. The update size basically becomes dynamic
which would hopefully be good enough for sync'ing to animation and the like.
The OSS backend doesn't currently do anything like that yet, but I may try
something in the future.
Also be careful with buffer queues, since the offset is from the start of the
queued buffers. So when you unqueue a buffer, the offset decreases according
to the size of the removed buffer.
More information about the Openal
mailing list