alw is the easiest way to get your hands on the functionality offered by the OpenAL API.
Its main part is a simple alw_gen.py Python script that generates alw.h and alw.c from the OpenAL headers (al.h, alc.h and efx.h). Those files can then be added and linked (statically or dynamically) into your project.
alw_gen.py requires Python version 2.6 or newer. It is also compatible with Python 3.x.
Here is a simple example of loading and using the OpenAL API via alw. Note that AL/alw.h must be included before any other OpenAL related headers:
#include <stdio.h> #include <AL/alw.h> // ... int main(int argc, char* argv[]) { ALCdevice* dev; ALCcontext* ctx; if (alwInit() < 0) { fprintf(stderr, "Failed to load OpenAL\n"); return 1; } // error checking omitted dev = alcOpenDevice(0); ctx = alcCreateContext(dev, 0); alcMakeContextCurrent(ctx); // use OpenAL... // clean up alcMakeContextCurrent(0); alcDestroyContext(ctx); alcCloseDevice(dev); alwTerminate(); return 0; }
The alw API consists of just three functions:
int alwInit(void)
Initializes the library. Should be called before any call to an OpenAL entry
point is made. Returns 0
when alw was initialized successfully or a
negative value if there was an error.
int alwInitEfx(void)
Loads the EFX extension entry points. Should be called after creating an OpenAL
context. Returns 0
when the EFX extension was loaded successfully or a
negative value if there was an error.
void alwTerminate(void)
Terminates the library and unloads the OpenAL module if possible.
alw is in the public domain. See the file UNLICENSE for more information.
- Slavomir Kaslev <slavomir.kaslev@gmail.com>
- gl3w, which alw is based on
- Niklas F. Pluem <niklas.crossedwires@gmail.com>
- Implementation
OpenAL is a trademark of Creative Labs, Inc.