LinuxDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


OpenAL Development: The Programmer's View

by Dave Phillips
10/13/2000

Related Articles:

OpenAL Explained

What Is This 3D Audio Business?

OpenAL Applications: The User's View


Previous Features

More from the Linux DevCenter

The OpenAL project employs the two mainstays of all successful open source projects: a very active mailing list and a CVS source code repository. Loki Entertainment sponsors the CVS site and its own OpenAL newsgroup, while the OpenAL web site provides contact and sign-up information for the mailing list. Occasional development snapshots of code sources are available from the OpenAL web site, but to stay current, you should download and build the sources from the CVS site. If you've never downloaded from a CVS source code repository, have no fear; the site includes complete instructions for retrieving the files you need.

Developers will be especially interested in the XLDEMO example program included with the OpenAL source package. It provides a simple demonstration of the basic use of the library, with particular emphasis on the relationship between OpenGL graphics and OpenAL audio. Of course, to do anything with the OpenAL API, you need to retrieve, build, and install the library source code.

Enter your home directory, fire up your Internet connection, and log on to Loki's CVS site. Follow the instructions given there to download from the repository. If all goes well, you should have a new directory containing the source code for builds of the OpenAL library for Windows, the Mac OS, Linux, and BeOS. Enter it, read the text files, and move into the directory for your platform of choice.

Note: The following instructions apply only to the Linux build of the OpenAL library. Please see the documentation in your platform's directory for instructions specific to your system.

From your $HOME/openal/linux directory, run ./autogen.sh to generate the configure script, then run ./configure --help for a list of configuration options. The list is extensive, but it is recommended that you start with only the --enable-debug and --enable-optimization options. Most of the other options are either debug or audio library flags (the kernel sound drivers, OSS/Linux, ALSA, ESD, and WAV output are all supported, but in varying degrees of completeness). Now run ./configure --enable-debug --enable-optimization. If no errors are reported, run make and (as root) make install. You should now have the libopenal.so shared library in /usr/local/lib, and you should also have a new /usr/local/include/AL headers directory. The configuration is not complicated, and the sources compiled cleanly with the default libraries on my Red Hat 6.1 system.

After installing the library, move into the openal/demos/XLDEMO/ directory. Read the README file for general instructions for building the demo on your platform (Windows, Linux, or Mac; sorry, no demo for BeOS yet).

To build the Linux version of the demo, enter openal/demos/XLDEMO/linux and read the Makefile to find what dependencies must be resolved. As well as having libopenal installed, you'll need the OpenGL or the Mesa libraries and include files. You'll also need the GLUT library and headers. All other required libraries and headers should be included with any mainstream Linux distribution.

If your system meets the requirements, the demo should build quickly. Before running it, copy the *.mdl, *.wav, and *.pcm files from openal/demos/XLDEMO/COMMON into the Linux demo directory. Make sure your sound system is turned on, then start an X session and open an xterm window. Move to the directory where you built the demo and type in ./xldemo. The scene in Figure 1 should appear.

Screen shot of xldemo.

Figure 1: The xldemo opening scene.

Your starting position is the camera or viewer's position in the OpenGL 3D visual field. You are also the listener in OpenAL's 3D audio field, so where the camera goes, so goes the listener. All other objects (visual and audio) are rendered relative to your position. In Figure 1, the object at the center is a beacon that emits a radar beep following the arc of the broadcast beam. The objects seen at the far left and in the back are vehicles that traverse the area enclosed by the walls. The viewer moves around the space by using the arrow keys and the 'z' and 'x' keys. Note the dynamic activity of each object's sounds as you approach, follow, and leave them. The proximity effects are very striking.

The code that creates these effects can be found in the openal/demos/XLDEMO/COMMON and openal/demos/XLDEMO/linux directories. An audiovisual environment object (AVEnvironment in xlmain.cpp) is created in the main loop. The AVEnvironment object is constantly updated with the current position of the viewer and the other objects moving around the virtual world. The OpenGL display updates and the OpenAL audio updates use the same type of mechanisms to create a seamless integration of the movement of the sound and graphics. On the next page we'll take a closer look at how that works....

Pages: 1, 2, 3

Next Pagearrow




Linux Online Certification

Linux/Unix System Administration Certificate Series
Linux/Unix System Administration Certificate Series — This course series targets both beginning and intermediate Linux/Unix users who want to acquire advanced system administration skills, and to back those skills up with a Certificate from the University of Illinois Office of Continuing Education.

Enroll today!


Linux Resources
  • Linux Online
  • The Linux FAQ
  • linux.java.net
  • Linux Kernel Archives
  • Kernel Traffic
  • DistroWatch.com


  • Sponsored by: