Thursday, March 17, 2011

OpenAL and OpenAL-Soft

OpenAL soft is an implementation of openAL API, which extends the capabilities of OpenAL by introducing additional devices to the existing collection. The standard implementation of OpenAL usually has three devices (according to my knowledge.). The native device which handles the native creative sound cards. Only native creative sound cards support it. The SoundBlaster Xfi series sound cards. You can download OpenAL-soft from http://kcat.strangesoft.net/openal.html
Sound Blaster audigy is supposed to have native support as well, but only the most expensive cards support the native device it seems. The card we used "Sound Blaster Audigy value", seems to lack the native device support. The other OpenAL devices are
. Generic Hardware
. Generic Software
Usually all other creative sound cards support Generic hardware, and so our sound card did fall under this category. Any non creative on board sound card will only support the generic software device. Generic software devices only support stereo sound, not four channel sound. This problem was unknown for a long time. :(. Any creative sound card will have generic hardware support so the objects could be placed on any position in space and sound emission would be handled by any number of channels (we only tested with 4 channels).
After moving to the creative sound card and correcting some logical errors as pointed by the OpenAL mail list (openal@opensource.creative.com). the problem with front and rear channels duplication (rear duplicating the front), was solved.
OpenAL-soft has a broader scope in mind in its implementation. It is supposed to emulate a device other than the generic hardware and generic software. " DirectSound Default", is the device emulated by the openAL-soft. This device should generate 4 channel sound even without a creative sound card. This claim we did not test yet. But when the device was tested on the creative sound card it almost had the same sound position quality as the generic hardware. Selection of the Device should happen from the ALC

   ALC alc;
AL al;
alc = ALFactory.getALC();
al = ALFactory.getAL();

ALCdevice device;
ALCcontext context;
String deviceSpecifier;

// Get handle to default device.
device = alc.alcOpenDevice("DirectSound Default");
if (device == null) {
throw new ALException("Error opening default OpenAL device");
}
// Get the device specifier.
deviceSpecifier = alc.alcGetString(device, ALC.ALC_DEVICE_SPECIFIER);
if (deviceSpecifier == null) {
throw new ALException("Error getting specifier for default OpenAL device");
}
System.out.println("Using device " + deviceSpecifier);
// Create audio context.
context = alc.alcCreateContext(device, null);
if (context == null) {
throw new ALException("Error creating OpenAL context");
}
// Set active context.
alc.alcMakeContextCurrent(context);

// Check for an error.
if (alc.alcGetError(device) != ALC.ALC_NO_ERROR) {
throw new ALException("Error making OpenAL context current");
}

This would be the initialization of the openAL The red color line presents the selection of device. If null were passed the selection would be the bast the openAL router thinks is. In our case it would be the generic hardware, in a creative xfi sound card this would be native.
The support of openAL soft on non creative sound cards is yet to be tested.

No comments:

Post a Comment