[SDL] Audio Channels - Surround?

Ryan C. Gordon icculus at icculus.org
Fri Apr 6 18:11:42 PDT 2007


> I'm currently trying to decide between SDL and OpenAL as my audio library. 
> OpenAL offers surround sound (which I may want to use later on), but I'm not 
> too happy with their Linux support, particularly since, to my knowledge, the 
> latest stable version is still unable to play stereo music.

Are you sure about that? I've shipped titles with the Linux OpenAL that 
counted on it not spatializing stereo buffers, but playing them as 
stereo content directly on the Listener.

> Regarding SDL, I'm trying to figure out if it already supports surround audio. 
> The SDL_ OpenAudio documentation in the Wiki states that 4 and 6 channels may 
> be requested for surround audio.

SDL supports it, but most drivers do not. In 1.2, there's probably a lot 
of drivers that will _mishandle_ it if you don't request either mono or 
stereo output (causing all sorts of mixing problems), using a structure 
like this:

    if (requested_channels == 1)
       open_device_for_mono();
    else
       open_device_for_stereo();   /* that's obviously wrong. */


1.3 already has most of this cleaned up (to at least clamp to stereo 
correctly if not actually handle more-than-2 channels), but it's not 
really ready for primetime in lots of other ways.

ALSA supports surround sound on Linux with SDL. I'm pretty sure the 
DirectSound target supports it on Windows. CoreAudio on the Mac can 
support it but I don't know if the SDL target does.

Unlike OpenAL, you're going to end up writing your own mixer, though. 
SDL is much lower-level when it deals with audio output.

I'm not sure what SDL_mixer (the add-on library) does, though...probably 
  doesn't do more than stereo.

--ryan.



More information about the SDL mailing list