PackageDescription: OpenAL

Open AL

Last published: June 28, 2011 by 'michael'

Defines 7 Classes
Extends 7 Classes

OpenAL - Cross-Platform 3D Audio

OpenAL is a cross-platform 3D audio API appropriate for use with gaming applications and many other types of audio applications.

The library models a collection of audio sources moving in a 3D space that are heard by a single listener somewhere in that space. The basic OpenAL objects are a Listener, a Source, and a Buffer. There can be a large number of Buffers, which contain audio data. Each buffer can be attached to one or more Sources, which represent points in 3D space which are emitting audio. There is always one Listener object (per audio context), which represents the position where the sources are heard -- rendering is done from the perspective of the Listener.

Example with a generated sine wave source moving from left to right with a doppler shift effect:

OpenAL.Listener default start.
OpenAL.Listener default dopplerFactor: 10.
[ | source buffer data |
data := ByteArray new: 8000 * 1.
1 to: 8000 * 1 do: [:i | data at: i put: ((i sin * 10) floor + 128)].
buffer := OpenAL.Buffer new.
buffer data: data format: OpenAL.AL_FORMAT_MONO8 frequency: 8000.
source := OpenAL.Source new.
source velocity: 1.5, 0, 0.
source queueBuffer: buffer.
source play.
source process.
-10 to: 10 by: (20 / 1000) do: [:i |
source position: i, 0, 0.
(Delay forMilliseconds: 1) wait].
source stop.
source delete.
buffer delete]
ensure: [OpenAL.Listener default stop]