AL 3D Audio and Environmental Audio Extension

3D Audio and Environmental Audio Extension: Using AL’s Support for 3D Audio and EAX


Games and sophisticated applications require the use of a 3D Audio facility to place their gamers or users in a 3D Space. This results in a virtual world in which the user is immersed, resulting in an improved user response. Added to this is a technology by Creative Labs, the EAX or Environmental Audio Extension, which makes the virtual world more rich with respect to 3D sound.

With this simple introduction, you experience the power of 3D sound and EAX and implement these by using the AL SDK.


  1. Download the SDK runtime and the SDK from
  2. Install the SDK runtime on your system.
  3. Install the SDK as directed so that it can run with VC++ (6 or .NET) or BC++ (32 bit).

An Introduction to 3D Audio

Audio in 3D enables a feeling of reality in Sound. To bring about this reality to the sound, you require two attributes:

  1. Attribute of the Listener.
  2. Attribute of the Source.

Attribute of listener means vectors that specify the position of the listener (the gamer or the user) in 3D space along with the relative velocity of motion. Other attributes, such as Doppler shift, Roll off factor, Max and Min hearing distance, FRONT, and UP vector of the listener are also required.

Attribute of the source means the values that determine the characteristics of the sound source. The most important values for these are the vectors for position of source and the relative velocity. Other values can be the cone angle and orientation.

This article will discuss the placement of sound in 3D space with the position and velocity attribute of each. For a full discussion about the attributes, please refer to the help file for the SDK.

Relative Velocity: The Term

The relative velocity of an object may be defined as the (absolute) velocity of the object with respect to the observer, when the observer is stationary. The velocity of the listener and source can be independently specified, yet the term is relative velocity. This is because the effect achieved by setting the velocity of the source and listener independently also can be achieved by setting the velocity of listener to ZERO and the source to the relative velocity of source with respect to listener, and vice-versa. And, because nothing is absolute in space, the term relative provides a better approach.

Steps to Coding

  1. Initialize the AL system.
  2. Create an AL context and set the context for current use.
  3. Open a wave buffer with 3D support and, before using it, set it as the current audio source.
  4. Play the wave.
  5. Perform positioning of listener (it can be done anytime after setting a current context as it has nothing to do with opening of wave or the like).
  6. Position the source in the listener’s space.

After youe are done using the program…

  1. Stop the wave.
  2. Close the wave.
  3. Delete the AL context. !!!Use the ALDelete() function!!!
  4. Uninitialize the AL system.

Program Name

The source code of the program and a DEMO EXE are attached.

  • Source Code Archive:
  • EXE Demo Archive: CG_Audio3D

Project/EXE Dependence

This project implements functions from AL and a few functions from the GL library. This article will not discuss the functions from GL SDK but only those from AL SDK.

Excerpt from the Code

Because this article deals with 3D location of sound, I will assume that the reader understands the code dealing with initializating the AL system and de-initializating and creating of the AL context by downloading the souce.

The IDs used in the code are defined as follows:

  • ID_WAVE: Points to the Wave buffer to be used.
  • ID_FONT: Points to the Font resource to be used to display result on GLX Window.
  • ID_TEXTURE: The 2D surface that is used to display 2D graphics on GLX Screen.

Opening Audio with 3D Support

if(!ALOpenWave( ID_WAVE,     //Wave resource ID
   // Wave file name (NULL terminated string)
   // We need 3D support on the Wave Resource
   // Wave data will be streamed ino wave buffer
   // Wave will be audible even if the window loses focus
   // We are not concerned about EAX now
   FALSE ))
   /* TODO : FILE failed to open.
    * Deal with error

Setting 3D Audio Attributes (Position and Velocity Vectors)

ALbool ALApply3D();

This function is very important. Whenever 3D parameters of the source and/or listener are changed, this function must be called for the changes in the 3D to take effect. It must be called after the listener and source 3D attributes are all set. It can be called after a batch of changes so that a more efficient program is created.

ALbool ALSet3DPosition( Vector *vec);

This function will take a vector that contains the position vector of the listener. By default, the listener is placed at Vector(0,0,0).

ALbool ALSet3DVelocity( Vector *vec);

This function will take a vector that contains the velocity vector of the listener. By default, the listener is stationary; in other words, Vector(0,0,0).

Now, the wave ID_WAVE is selected as the current wave buffer by calling ALSetWave(ID_WAVE). Then, afterward (because you know that your wave is 3D enabled), you can set the 3D Source attributes.

ALbool ALSetWave3DPosition(Vector *vec);

This function sets the position vector of the source in 3D space. By default, the source is set at the origin, Vector(0,0,0).

ALbool ALSetWave3DVelocity(Vector *vec);

This function sets the velocity vector of the source in 3D space. By default, the source is stationary; in other words, Vector(0,0,0).

Note: This is a general and simple 3D Audio Program; the source and demo can be viewed for results and understanding. Next, I will explain the Creative EAX effect on 3D Audio Resource. You should remember that the next program being discusses is an extension of the 3D Audio program; there is no change to whatever is discussed here, but only an addition of Creative EAX functionality.

More by Author

Must Read