[openal] Properly configuring OpenAL Soft

Chris Robinson chris.kcat at gmail.com
Sat Mar 26 16:49:38 EDT 2016

On 03/26/2016 06:38 AM, Matthew Swartz wrote:
> Hi, I'm new to OpenAL Soft and wish to get the most out of it.
> In the game this is being used in, we use 48khz by default but want to
> support up to 96khz.
> I noticed in the OpenAL Soft config utility that it only goes up to a max
> of 48khz, so I was wondering why that is.


The config utility only lists up to 48khz because that's really the 
highest you need to worry about for playback. That fully covers the 
human hearing range, and having higher values can lull people into a 
false sense of quality that does nothing but waste CPU cycles and 
potentially make the output noisier. If you're doing extra processing on 
the output where those inaudible frequencies are important it may be 
useful to go higher, but not if you're just listening to it.[1][2] You 
can manually type in any other sample rate you want into the box though, 
up to 192khz (try to force it any higher and some internal calculations 
may become unstable).

If you're on Windows, this doesn't make much difference anyway since the 
audio service will only accept the sample rate the device is configured 
for. I'd imagine CoreAudio on OSX is the same, and PulseAudio on Linux 
is very limited in when it can reconfigure the device. In the case of 
MMDevAPI, trying to use a different rate will error and automatically 
fallback to the device rate, and in the case of dsound or winmm it'll 
add another resample step between OpenAL Soft and the audio service. 
It's best to just let OpenAL Soft autodetect what's being used and not 
worry about it.

[1] https://people.xiph.org/~xiphmont/demo/neil-young.html
[2] https://xiph.org/video/vid2.shtml

> Also, it's important that we can switch between 48khz to 96khz based on
> what sound is played, as an example some of the gunshots are in 48khz while
> others are in 96.

OpenAL Soft will automatically resample sounds to match the output. So 
it doesn't matter if you play a 96khz sound with 48khz output, or a 
48khz sound with 96khz output, or whatever else... the sound will be 
made to work for the output sample rate.

If you want a really high quality resampler, select Band-limited Sinc in 
the Resources tab (it's been moved to the main Playback tab in the 
latest Git). I'm considering making the 4- or 8-point Sinc resampler the 
default since they do sound better than basic linear resampling -- not 
as good as band-limited sinc which varies between 12 and 24 points, but 
still better than linear -- though they do take a bit more CPU power.

> Would PulseAudio be a good choice if I'm on Windows?

On Windows, you're mainly looking at MMDevAPI, DirectSound, or Windows 
Multimedia, the latter two essentially being compatibility layers that 
sit on MMDevAPI. PulseAudio is a Linux thing (maybe there's a client 
emulation wrapper lib available for Windows, but it's not the native 
sound system).

Hope that helps. If you have more questions, feel free to ask. :)

More information about the openal mailing list