[Openal] Transparently mixing many sounds
Garin Hiebert
garinh at cheesetoast.net
Tue Sep 26 22:57:56 PDT 2006
>
> First, does OpenAL include any elegant way of handling this?
No, OpenAL doesn't handle this.
For those who are interested:
A common term for this feature is "voice management," and some API's
(DirectSound 3D) do provide it. There are certainly benefits to voice
management, but here are some of the reasons OpenAL doesn't have it:
1) It adds complexity to the audio API.
2) It forces a specific voice management scheme on the developer (or if
multiple schemes are supported, then add even more complexity)
1) It abstracts audio hardware in an inconvenient way -- what normally
happens is that the API winds up growing so that the application can
discover what is being done in hardware, and what is being done in
software, and then some voices can have some properties, and some can
not, adding complexity -- either that, or a "lowest common denominator"
approach has to be taken and at least some the power of your audio
hardware is thrown out.
OpenAL's approach is to have a simple API which can be accelerated by
any known audio hardware that has accelerated features, and to allow
extensions to the API which expose advanced features (which may or may
not be vendor specific).
> If not:
>
> I have this idea to catch the exception when it is thrown, storing the
> number of playing sounds as the maximum that can be allocated. Then,
> whenever that maximum is reached, the system enables sounds based on
> a) whether a priority flag is set and b) their perceived loudness. In
> this way, sounds that are less perceptive are deactivated while the
> more obvious ones drown them out, so to speak.
This is a common approach that is used, although simply using priorities
combined with a "first played, first stopped" system for one-shot sounds
can be surprisingly effective and reduce computation. Priorities would
be set for anything associated with the main actors such that their
audio would always play if possible. (For instance -- if your product
is an FPS and there is such a large firefight going on that you're
running out of voices in this scheme, then there's probably so much
going on that having some audio drop out doesn't matter.)
If your 3D engine has a notion of "portals" -- a sound object is
detectable as being in another room than the listener -- then this
information may also be very useful for culling or adding effects (EFX
or EAX).
>
> Given a distance from the listener, gain and roll-off factor, plus
> perhaps the reference distance and other variables which I may not yet
> be considering, is there some way to calculate the sound's perceived
> volume?
If you find it desirable to do the full calculation, the distance gain
formulas are in the 1.1 Specification as well as the Programmer's Guide
-- see http://www.openal.org/documentation.html for more info.
Garin
More information about the Openal
mailing list