[Openal] porting questions
Daniel PEACOCK
dpeacock at creativelabs.com
Wed Jun 6 11:53:14 PDT 2007
Hi Xavier,
> I'm trying to port a sound engine implemented with directsound to openal.
>
> So far, it's a much more pleasant API, I like it..
>
> But I have a few questions:
> * Is there any way to do panning?
> I can play stereo sounds (without 3D positionning and all). But I
would
> like to be able to do simple stereo panning on this sound. Is there a
> way to do it?
There is no support in the API to do panning at the moment. It is a
popular request so we should probably consider adding it as an extension.
For now, the only way to do this is to do the panning yourself. This can
be done by streaming the stereo audio data to a Source via the queueing
mechanism. If you keep the number of buffers small and of short duration
then panning can be done in real-time with reasonably low latency. (FYI
.. I use this technique in ALchemy (a DS3D to OpenAL converter for Windows
Vista)).
> And more generally - but I don't need it, for now - a way to tune the
> balance of sounds with more channels?
Again, you would have to do this manually at the moment.
> * How about ressource management / hardware limits?
> how do I know how many 3D sounds I can play simultaneously? Max size
of
> buffers? max streamming bandwith? and so on?
Try to generate as many OpenAL sources as you need (e.g using a for loop
and create one source per iteration). If the OpenAL device doesn't support
that many then the call to generate the source will fail. Each OpenAL
Source that you have successfully generated can play back a mono 3D buffer.
So, if you generate 60 Sources then you will know that you can play back 60
3D mono buffers simultaneously. NOTE : If you are playing buffers with
more than 1 channel then they require additional resources (e.g stereo
takes 2 voices on hardware, 5.1 takes 6 voices, etc ...). You can either
keep track of this yourself (e.g with 60 Sources if you play one stereo
then you can only play 58 mono buffers), or you can use the alc Context
creation hint ALC_STEREO_SOURCES to tell OpenAL to reserve Sources to
enable playback of a certain number of stereo buffers simultaneously.
In terms of maximum buffer size there may be limitations on some devices
(e.g 64MB on hardware) ... however for buffers this large you should
probably be streaming the data to OpenAL in small chunks.
> And is there some resource management mecanism, that would stop sounds
> it can't play, with some priorities, and so on...
No - this is up to the application to handle.
> * And how about hardware support /driver bugs ?
> I imagine on many (all?) hardware, the api will implemented using
> directsound, as a fallback if the hardware vendor doesn't provide a
> specific driver. - is that correct?
On Windows there are three different types of AL devices ...
"Generic Software" : A software mixer that works everywhere
"Generic Hardware" : A hardware mixer that works by converting OpenAL calls
into DS3D for devices with hardware support for DS3D.
<native> devices : Certain hardware like Audigy, and X-Fi cards have native
OpenAL devices that by-pass DS3D (and most of the OS) and communicate with
the soundcard drivers.
> And in my engine, in the course of the years, I have added some tricks
> and workaround for bugs[*]. Can I hope the the openal implementation
> also works around those? - or, to put in an other way, how widely is it
> tested and used?
There are definitely some tricks to get the "Generic Hardware" device to
work well. However, there can still be problems if the DS3D driver itself
is buggy ... which is why we recommend using the OpenAL Device enumeration
extension to determine what OpenAL devices are available on the system and
presenting the user with a choice.
OpenAL is gaining in popularity all the time -- there is a list of titles
on www.openal.org if you want to check it out. As you'll be able to see it
includes lots of AAA titles.
Dan
More information about the Openal
mailing list