View Full Version : ClanLib sound switch from dsound to openal?

10-27-2007, 08:10 AM
Wouldn't it be better to use openal for the sound module of ClanLib since openal is portable? It would remove the need to write OS-specific code for Windows with DirectSound.

10-27-2007, 04:12 PM
Actually, that would also be interesting, since Microsoft actually dropped hardware acceleration on (at least some parts of) DirectSound. OpenAL is the way to go. However, I'm kind of worried how good is the support of that on Linux though. The last time I checked, the Linux OpenAL was quite a bit outdated compared to their mac and windows counterparts.

10-27-2007, 07:53 PM
I see, I did not realize that the Linux OpenAL was outdated. But since OpenAL is advertised as the OpenGL analog for audio and sound, it seems natural to use it over OS-specific APIs like DSound (yah, I remember reading something about how OpenAL outperforming DSound on Vista) and the other code that is currently in the ClanLibSound module.

I would be interested in helping with this. However, I have not had any experience with OpenAL as of yet. I do have a little understanding of how the OpenGL/AL state machines work though. Could someone please provide a little more explanation regarding the purposes/interactions of/between the various classes of the Sound module?

I would have just sucked it up and went with DirectSound, but I cannot download the sdk because it requires a validation. I have learned to despise Microsoft.

11-03-2007, 06:02 PM
Just to make a few things clear. OpenGL and OpenAL got nothing to do with each other, except that the guys that did OpenAL obviously was inspired by the naming and possible also the design of OpenGL.

Regarding whether clanSound would be better off wrapping OpenAL, I do not really know. I havn't studied the OpenAL API and therefore don't really have an opinion whether it needs wrapping at all or if an updated clanSound would benefit from using it as a backend or not.

About DirectSound hardware acceleration, Microsoft is generally becoming increasingly annoying in the way they keep deprecating everything they do every 3 year. You therefore now have DirectSound, XACT and the Vista sound engine.

To make matters worse, it seems not even Microsoft anymore knows which of the APIs it prefers. XACT is basically a 'clanSound' mixer targeted for their Xbox platform, which means that it along with XInput is extremely lame in regards to supporting anything else than what the Xbox supports itself. So XACT's only DSP effect is Reverb, and XInput is a primitive API just barely covering the features of the Xbox 360 controller.

The Vista sound engine is only supported on Vista, making it sorta pointless to target at the moment, plus from what I could tell on the API it seemed like the guys doing it had only professional audio recording in mind, maybe forgetting features that are commonly used by low-latency game sound mixing (such as refilling parts of a ring buffer just ahead of the playback). Maybe they have a better solution for that than what I had in mind, but either way the API doesn't exactly help you plot a solution vector for these kinds of problems.

Generally the hardware support is so horrible for DirectSound (what exactly is Microsoft's hardware compatibility labs doing?) that you cannot really rely on any hardware acceleration for real. Take a look at the list of sound cards with known compatibility problems with Battlefield 2142 for an example of just how many mainstream cards that have broken drivers. This thing alone is a reason for not wanting to do a sound library. :)

I am not sure if OpenAL really solves all these problems, because at least in UT3 I noticed that OpenAL sound is disabled per default in the game, making you wonder why exactly that is. Of course Epic Megagames could just be cautious, or maybe OpenAL cannot fall back to DirectSound when lacking drivers?

If I were to upgrade clanSound one day, I think I would make it still use DirectSound for the Windows platform. The main difference (besides completely redesigning the API of clanSound and its implementation) would be that it would create a 5.1 or 7.1 sound buffer, thus end up with the same sound mixing code for both Windows, Linux and OS X, and at the same time allow you to play complex surround samples and do 3d positioning of sound. If this is what OpenAL already does on Windows I don't know - but that's how I would do it.