OpenAL Basics

Let’s begin the discussion of JOAL by looking at the core classes that compose the basic structure of the OpenAL API. Given that the JOAL implementation is designed around the actual OpenAL spec, it is no surprise that the key objects used in OpenAL are also available in JOAL. These core classes are the Buffer, Source, and Listener.

Buffer holds the audio data that the user wants to play. It is capable of being set to handle 8- or 16-bit audio data in mono or stereo formats. OpenAL currently supports pulse code modulation (PCM) file formats such as WAV or AIFF. To use any other format requires decoding to a PCM format. Work is currently in progress to extend OpenAL to support the popular Ogg Vorbis format in the near future. When this work is complete, future versions of JOAL may support it. In addition, there is no current mechanism in JOAL to allow for streaming from a CD-ROM source, though future versions may support this feature.

Source holds all the information related to the sound slated for use in JOAL that is not directly related to the actual original audio data. The Buffer is attached to the Source so that they can be positioned in the world and updated as a result of changes during a game. The Source contains no audio itself. The Source class also contains the controls for starting, stopping, and looping, as well as volume.

The Listener class represents an actual person or location that is potentially able to hear audio in the game. Depending on the Buffer and the Source positions, OpenAL interpolates and renders the audio based on how the Listener should hear it in the world. The term renders might sound strange when applied to audio. That idea most likely comes from the OpenGL mindset of rendering graphics to a screen. Despite the strangeness of the term, rendering is the preferred way to reference the audio output that a Listener can hear. Listener classes can move and can also modify the volume based on position. Only one Listener can exist at any given time, though there may be multiple Buffer and Source classes, each with unique data and settings.



Practical Java Game Programming
Practical Java Game Programming (Charles River Media Game Development)
ISBN: 1584503262
EAN: 2147483647
Year: 2003
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net