[back to main page]

Notes related to all my programs using OpenAL

Contents:
  1. Installing OpenAL
  2. Command-line options respected by all my programs that use OpenAL
  3. FreeBSD specific notes

Installing OpenAL

Generally, you can install OpenAL from many sources, you can even get optimized OpenAL drivers from your sound card manufacturer. Section below describes how to install OpenAL in the simplest and most often case.
Linux users:
Just install appropriate package from your Linux distribution (under Debian etch this is package libopenal0a).
FreeBSD users:
Simple pkg_add -r openal command should do the trick.
Mac OS X users:
Download and run Creative free OpenAL installer for Mac OS X.
Windows users:
OpenAL libraries (DLL files) should already be included in all binary packages of my games under Windows. So you don't have to do anything.

However, you're free to remove appropriate DLL files (OpenAL32.dll and wrap_oal.dll) provided in my archives and install OpenAL yourself. This is especially handy if you want to use other OpenAL implementation than the one from Creative.

OpenAL libraries that are provided by default come from Creative free OpenAL installer.

You can always compile from sources available from www.openal.org, at least under Unixes this is rather straightforward.

Command-line options respected by all my programs that use OpenAL

--no-sound

Don't use OpenAL, even if it's available. The program will not even try to initialize OpenAL. Note that you don't have to use this option if you don't have OpenAL installed. This parameter is useful only if you have OpenAL, but you don't want to use it for whatever reason (e.g. because your cat sleeps on the chair beside you and you don't want to wake him up).

--audio-device OPENAL-DEVICE-NAME

Use given OPENAL-DEVICE-NAME. Details follow:

Since the default OpenAL implementations are purely in software, various OpenAL devices often mean that various software "backends" will be used.

There is no sure way to determine which OpenAL device will sound and work best, be fastest etc. You just have to try them all to be sure that you get all you can from OpenAL.

Linux and FreeBSD users:

Usual OpenAL implementation will have the following devices available:

OpenAL Name Device Notes
native operating system native The default device.
sdl Simple DirectMedia Layer backend
arts aRTs backend Note that it seems terribly unstable. Use at your own risk.
esd Esound daemon backend
alsa ALSA backend

While it works OK, it tries to acquire the exclusive ownership over sound device. So, unlike most other programs that use ALSA, OpenAL programs by default cannot play sound when some other program already plays sound. For example, you cannot run rhyrthmbox and listen to your own chosen music while playing my games.

The workaround is to run my games through aoss wrapper.

waveout WAVE file output

A file named like openal-0.wav will be generated that contains recorded sound.

Note that OpenAL generates somewhat buggy WAV file, and e.g. gstreamer-based programs may not want to play it. My programs will play it, but only because I made a workaround specifically for this. I found that it's usually a good workaround to convert the WAV file with sox, like sox openal-0.wav newopenal-0.wav. Such WAV file generated by sox should be readable everywhere. I reported this problem to Debian OpenAL package (probably a problem is general and fix will be generally usable too) here.

null no output

In the simplest case, to use some other device, e.g. alsa, just run program with command-line option like:

  --audio-device "'(( devices '(alsa) ))"
(Yes, the first argument's character is an apostrophe, and the whole argument is quoted to avoid being splitted by shell. No, it's not Lisp, but it was designed to look similar.)

Then if you will find that e.g. alsa device sounds best and you want my programs (and all other programs that use OpenAL) to always use alsa device, you can create file /etc/openalrc or $HOME/.openalrc with line

  ( define devices '(alsa) )
Windows users:

Newer Creative's OpenAL implementation has two devices: Generic Hardware (uses DirectSound3D) and Generic Software (uses DirectSound).

Like with Unices, it may be worth checking every available device to find which one suits you best. Call my programs with command-line options like

  --audio-device "Generic Hardware"
  --audio-device "Generic Software"
--print-audio-devices

Query OpenAL for a list of available devices. Prints all allowed arguments for --audio-device option given above. Note that not all OpenAL implementations support it — at the time of writing, only Creative's Windows OpenAL supports it.

FreeBSD specific notes

In FreeBSD 5.x I had some serious problems getting OpenAL to work smoothly within my OpenGL programs. It was reported on openal mailing list, but this was probably the kind of problem that results from a combination of various things — like my particular sound card, maybe combined with NVidia OpenGL using some significant CPU time etc. So nothing was solved. Only waveout and null OpenAL devices worked correctly. So if you experience problems, you should probably live without OpenAL sound under FreeBSD. Run my programs with --no-sound option.

In FreeBSD 6.x I was glad to notice that OpenAL works smoothly.