Sdl sound

hi

does anyone know how to choose a sounddevice by using sdl / sdl_mixer

if i have two soundcards in my pc, how can tell sdl to play the
sound on the first one or the second

does sdl / sdl_mixer support more channels than mono / stereo ??

jan

kleinree wrote:

if i have two soundcards in my pc, how can tell sdl to play the
sound on the first one or the second

It is up to the magic of environment variables to control which
soundcard. Actaully, on Windows I don’t believe you get any control.
Check out the SDL_PATH_DSP and AUDIODEV variables on this page,

http://sdldoc.csn.ul.ie/sdlenvvars.php

hi

does anyone know how to choose a sounddevice by using sdl / sdl_mixer

On Linux, you do:
export SDL_AUDIODRIVER=

if i have two soundcards in my pc, how can tell sdl to play the
sound on the first one or the second

Dunno.

does sdl / sdl_mixer support more channels than mono / stereo ??

No, but on Linux and using the Alsa sound driver, it could. Support
for other systems would only require modifying other sound drivers.
I made a set of patches early this summer for 4/6 channel support.
They’re at ftp://ling.lll.hawaii.edu/pub/greg/Surround-SDL.tgz.

I worked at improving the support for 4/6 channels off and on this
summer, but I’ve given it up now, since no one seems to be interested.

Greg Lee <@Greg_Lee>On Wed, 11 Aug 2004, kleinree wrote:

Gah! I am! Well, even though I have a shoddy old SoundBlaster which
can only do 2 channels, this kind of stuff is good to support! :^)

-bill!On Wed, Aug 11, 2004 at 05:44:54AM -1000, Greg Lee wrote:

I worked at improving the support for 4/6 channels off and on this
summer, but I’ve given it up now, since no one seems to be interested.

I worked at improving the support for 4/6 channels off and on this
summer, but I’ve given it up now, since no one seems to be interested.

I wouldn’t say “no one is interested” … it’s definitely something that
should get supported sooner or later.

I am concerned about the legacy code that will break when the
assumptions about 1 vs. 2 channels are no longer accurate, but oh well.

The Mythical SDL 1.3 should really support > 2 channel out of the box,
if you ask me.

–ryan.

I worked at improving the support for 4/6 channels off and on this
summer, but I’ve given it up now, since no one seems to be interested.

I wouldn’t say “no one is interested” … it’s definitely something that
should get supported sooner or later.

I am concerned about the legacy code that will break when the
assumptions about 1 vs. 2 channels are no longer accurate, but oh well.

Why should any legacy code break? The only difference to the API is
that where some SDL function lets you specify either 1 or 2 for the
number of channels, with the changes, you can specify 1, 2, 4, or 6.
That’s it. Legacy code will specify only 1 or 2, and everything will
work just like it used to.

That’s the theory, anyway. But since I knew there would be concern
about this, I tested a variety of games using SDL sound, to see if
problems would crop up. No problems. Furthermore, I modified a
number of games to open SDL for 6 channel sound instead of just
2 channels. Still no problems. Everything still worked.

I’ve documented all this in some detail. The documents are in the
archive with the patches. I wish some of you would just take
a look, and maybe even apply the patches and give it a try, instead
of just assuming that there will be all sorts of problems.

The Mythical SDL 1.3 should really support > 2 channel out of the box,
if you ask me.

Greg Lee <@Greg_Lee>On Wed, 11 Aug 2004, Ryan C. Gordon wrote:

check out this code

if(numchannels==1)
//1 channel sound code
else
//2 channel sound code

if it supports more than 1 and 2 channels, the above code would break if
more than 2 channels were used because it assumes there are only 2 options;
mono and stereo.

these legacy code assumptions are what he’s talking about> ----- Original Message -----

From: greg@ling.lll.hawaii.edu (Greg Lee)
To: "A list for developers using the SDL library. (includes SDL-announce)"

Sent: Wednesday, August 11, 2004 4:05 PM
Subject: Re: [SDL] sdl sound

On Wed, 11 Aug 2004, Ryan C. Gordon wrote:

I worked at improving the support for 4/6 channels off and on this
summer, but I’ve given it up now, since no one seems to be interested.

I wouldn’t say “no one is interested” … it’s definitely something that
should get supported sooner or later.

I am concerned about the legacy code that will break when the
assumptions about 1 vs. 2 channels are no longer accurate, but oh well.

Why should any legacy code break? The only difference to the API is
that where some SDL function lets you specify either 1 or 2 for the
number of channels, with the changes, you can specify 1, 2, 4, or 6.
That’s it. Legacy code will specify only 1 or 2, and everything will
work just like it used to.

That’s the theory, anyway. But since I knew there would be concern
about this, I tested a variety of games using SDL sound, to see if
problems would crop up. No problems. Furthermore, I modified a
number of games to open SDL for 6 channel sound instead of just
2 channels. Still no problems. Everything still worked.

I’ve documented all this in some detail. The documents are in the
archive with the patches. I wish some of you would just take
a look, and maybe even apply the patches and give it a try, instead
of just assuming that there will be all sorts of problems.

The Mythical SDL 1.3 should really support > 2 channel out of the box,
if you ask me.

Greg Lee


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I’ve documented all this in some detail. The documents are in the
archive with the patches. I wish some of you would just take
a look, and maybe even apply the patches and give it a try, instead
of just assuming that there will be all sorts of problems.

There can (and surely will) be problems.
However, I find the idea of adding more than 2 channel audio to SDL
rather good. But if you want it to be really useful, I think you’ll need
more platforms supported (yes, that probably means windows). SDL is
about portability, a feature supported on just one platform might not be
very attrtactive to developpers.

Stephane

indeed not, especialy when they find out that it is limited platform
supported functionality only when they start porting their finished code to
another OS (:> ----- Original Message -----

From: stephane.marchesin@wanadoo.fr (Stephane Marchesin)
To: "A list for developers using the SDL library. (includes SDL-announce)"

Sent: Wednesday, August 11, 2004 4:21 PM
Subject: Re: [SDL] sdl sound

I’ve documented all this in some detail. The documents are in the
archive with the patches. I wish some of you would just take
a look, and maybe even apply the patches and give it a try, instead
of just assuming that there will be all sorts of problems.

There can (and surely will) be problems.
However, I find the idea of adding more than 2 channel audio to SDL
rather good. But if you want it to be really useful, I think you’ll need
more platforms supported (yes, that probably means windows). SDL is
about portability, a feature supported on just one platform might not be
very attrtactive to developpers.

Stephane


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

There can (and surely will) be problems.
However, I find the idea of adding more than 2 channel audio to SDL
rather good. But if you want it to be really useful, I think you’ll need
more platforms supported (yes, that probably means windows). SDL is
about portability, a feature supported on just one platform might not be
very attrtactive to developpers.

Well, sure. How about pitching in? I can’t write and test drivers for
other systems, because I don’t have or know anything about other systems.

Modifying the Alsa driver for more analog channels was trivial. Maybe
the others will be easy, too.

Greg Lee <@Greg_Lee>On Thu, 12 Aug 2004, Stephane Marchesin wrote:

check out this code

if(numchannels==1)
//1 channel sound code
else
//2 channel sound code

if it supports more than 1 and 2 channels, the above code would break if
more than 2 channels were used because it assumes there are only 2 options;
mono and stereo.

these legacy code assumptions are what he’s talking about

I don’t follow the example. If it’s legacy code, how did more than 2 channels
come to be used? If the contents of “numchannels” is 6, how did that value
get assigned? Not by a legacy application.

If you mean that there will be problems as applications are migrated to take
advantage of SDL’s new support for surround sound, well, I guess this is
obvious enough. But this is not in the category of breaking legacy code,
is it?

Greg Lee <@Greg_Lee>On Wed, 11 Aug 2004, Alan Wolfe wrote:

Greg Lee wrote:>On Thu, 12 Aug 2004, Stephane Marchesin wrote:

There can (and surely will) be problems.
However, I find the idea of adding more than 2 channel audio to SDL
rather good. But if you want it to be really useful, I think you’ll need
more platforms supported (yes, that probably means windows). SDL is
about portability, a feature supported on just one platform might not be
very attrtactive to developpers.

Well, sure. How about pitching in? I can’t write and test drivers for
other systems, because I don’t have or know anything about other systems.

Modifying the Alsa driver for more analog channels was trivial. Maybe
the others will be easy, too.

Well, that’s the problem that was implicit in my previous mail : not
many people seem to want/know/like to do windows development.
Hopefully windows gurus around here will step up for the task :slight_smile:

Stephane

I don’t follow the example. If it’s legacy code, how did more than 2 channels
come to be used? If the contents of “numchannels” is 6, how did that value
get assigned? Not by a legacy application.

int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);

Specify something non-NULL for “obtained” and you could get 6 in a
legacy app that is dynamically linked to SDL.

Future expansion will find (say) a Revolution 7.1 card on MacOSX that
can’t be set to stereo output and expects you to write silence to
channels you don’t use. It makes total sense for “obtained” to report 8
channels in this case.

SDL_MixAudio() also takes data “in the playing audio format”, which
means you could be passing a mono-else-stereo buffer to this function
and end up with a segfault.

Here’s a choice comment from SDL_mixer that is patently false when you
have 4.1 output:

/*

  • if there’s only a mono channnel (the only way we wouldn’t have
  • a len divisible by 2 here), then left_f and right_f are always
  • 1.0, and are therefore throwaways.
    */

–ryan.

I don’t follow the example. If it’s legacy code, how did more than 2 channels
come to be used? If the contents of “numchannels” is 6, how did that value
get assigned? Not by a legacy application.

int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);

Specify something non-NULL for “obtained” and you could get 6 in a
legacy app that is dynamically linked to SDL.

Future expansion will find (say) a Revolution 7.1 card on MacOSX that
can’t be set to stereo output and expects you to write silence to
channels you don’t use. It makes total sense for “obtained” to report 8
channels in this case.

I don’t see the problem here. I don’t provide for 8 channels, but
in the comparable case where *desired is 2 and *obtained is 6, e.g.,
2 channel input from the application should be automatically upconverted
to 6 channels (by copying channels). I admit, though, I haven’t
tested this specific case. When, in the future, we want to implement 8
channels, it seems to me that adding the necessary conversion routines
to SDL_audiocvt.c is all that will be necessary.

It’s remarkable how easy it has been to add extra channels. SDL is
very well structured. There just are not that many places where the
code depends on number-of-channels having a specific value.

SDL_MixAudio() also takes data “in the playing audio format”, which
means you could be passing a mono-else-stereo buffer to this function
and end up with a segfault.

How? Just as now SDL knows how to convert back and forth between
1 and 2 channel streams, so with my changes it knows to convert among
those and 4 and 6 channel streams also. I added the necessary routines
to SDL_audiocvt.c. (Well, there is one conversion missing – going from
6 down to 4 channels has so far defeated me.)

Here’s a choice comment from SDL_mixer that is patently false when you
have 4.1 output:

/*

  • if there’s only a mono channnel (the only way we wouldn’t have
  • a len divisible by 2 here), then left_f and right_f are always
  • 1.0, and are therefore throwaways.
    */

My changes do not provide for 4.1 output. Only 1, 2, 4, or 6 channels. I saw
this comment, of course, but didn’t see a problem. If there is a problem
here, after all, then that’s my mistake.

Greg Lee <@Greg_Lee>On Thu, 12 Aug 2004, Ryan C. Gordon wrote: