Audio saturation

Hi all,

I am experiencing a rather strange situation : our app, running on RedHat
Linux 8.0 and using SDL and SDL_mixer, when run for a long time (several
hours), starts saturating its audio output (all sounds start feeling a
little crunchy, like when you put the volume of a cheap speaker to loud or
use a distortion effect).

If I stop the app and restart it, everything becomes fine again. Weirder :
if, while the app is still running, I start xmms and play a short sample
(even for a mere fraction of second) the saturation completely disappears
in my app, then re-appears as suddenly after a few seconds… As long as I
keep playing sound in xmms, no saturation occurs in my app, but as soon as
I stop xmms the saturation restarts a few seconds later… I also noticed
that, if instead of the default eSound output plugin, I set xmms to use the
OSS plugin, playing sound in xmms no longer “cures” the saturation in my
app. As soon as I revert xmms to eSound output, it works again.

We tried on 2 different machines having not exactly the same configuration
(both are DELL dimension 340 workstations, one uses the sound card on its
mother board (driver: i810_audio, desc: “Intel Corp.|82801BA/BAM AC’97
Audio”) , the other uses a standard creative SoundBlaster Live! (linux
driver emu10k1). The same problem happens on both machines, although the
saturation effect is stronger on the soundblaster…

Any help, hint, whatever… welcome !

Thanks in advance !

Willy

PS : is there a way to select which audio output lib SDL will use, without
recompiling it ? Something like xmms’s output plug-in selector. I took a
look at SDL’s and SDL_mixer’s APIs, but found nothing like that…

Xavier Wielemans

Alterface
Avenue Alexander Fleming 10
B-1348 Louvain-la-Neuve
Belgium
http://www.alterface.com

phone: +32 10 48 00 63
fax: +32 10 48 00 69

Xavier Wielemans wrote:

PS : is there a way to select which audio output lib SDL will use,
without recompiling it ? Something like xmms’s output plug-in
selector. I took a look at SDL’s and SDL_mixer’s APIs, but found
nothing like that…

IIRC, you can set SDL_AUDIODRIVER environment variable to the
desired driver prior to starting your app.

clemens

This looks like an issue with the application. I have an idea of what is
happening, an will explain my take on it. I hope it helps.
It sounds like your audio bias is “creaping” up. For example, using 16 bit
unsigned audio, the zero level (silence) is at 32768. After each sample or
piece of audio played, the level should return to this value. When mixing
audio, more than one audio channel is added together and sent to the sound
card. If one of those channels ends at something other than 32768, it will
push the level up of the mixed set. This will cause a clipping effect
when values over 65535 are created.

Running the sound through eSound (along with xmms) can fix this, somewhat.
eSound also adds all of the audio streams together and sends them to the
sound card. To avoid clipping, it scales down every channel so when added
together it will not exceed the 65535 limit. As soon as xmms connects to
esound, esound scales them both down removing the clipping problem with
your application. (I am not sure how eSound would get it unclipped, maybe
something with the eSound libraries)

I am not sure how you are playing sound, but try looking for this bias
creap and see what you find.

Jamie

|---------±------------------------------------->
| | Xavier Wielemans |
| | |
| | |
| | Sent by: |
| | sdl-admin at libsdl.org |
| | |
| | |
| | |
| | 05/23/03 11:32 AM |
| | Please respond to sdl |
| | |
|---------±------------------------------------->

----------------------------------------------------------------------------------------------------|
| |
| T |
| To: sdl at libsdl.org |
| cc: Marichal Xavier <xavier.marichal at alterface.com>, Deltenre St?phane |
| <stephane.deltenre at alterface.com>, Ergo David <david.ergo at alterface.com> |
| |
| bcc: |
| Subject: [SDL] audio saturation |
----------------------------------------------------------------------------------------------------|

Hi all,

I am experiencing a rather strange situation : our app, running on RedHat
Linux 8.0 and using SDL and SDL_mixer, when run for a long time (several
hours), starts saturating its audio output (all sounds start feeling a
little crunchy, like when you put the volume of a cheap speaker to loud or
use a distortion effect).

If I stop the app and restart it, everything becomes fine again. Weirder :

if, while the app is still running, I start xmms and play a short sample
(even for a mere fraction of second) the saturation completely disappears
in my app, then re-appears as suddenly after a few seconds… As long as I

keep playing sound in xmms, no saturation occurs in my app, but as soon as
I stop xmms the saturation restarts a few seconds later… I also noticed
that, if instead of the default eSound output plugin, I set xmms to use the

OSS plugin, playing sound in xmms no longer “cures” the saturation in my
app. As soon as I revert xmms to eSound output, it works again.

We tried on 2 different machines having not exactly the same configuration
(both are DELL dimension 340 workstations, one uses the sound card on its
mother board (driver: i810_audio, desc: “Intel Corp.|82801BA/BAM AC’97
Audio”) , the other uses a standard creative SoundBlaster Live! (linux
driver emu10k1). The same problem happens on both machines, although the
saturation effect is stronger on the soundblaster…

Any help, hint, whatever… welcome !

Thanks in advance !

Willy

PS : is there a way to select which audio output lib SDL will use, without
recompiling it ? Something like xmms’s output plug-in selector. I took a
look at SDL’s and SDL_mixer’s APIs, but found nothing like that…

Xavier Wielemans

Alterface
Avenue Alexander Fleming 10
B-1348 Louvain-la-Neuve
Belgium
http://www.alterface.com

phone: +32 10 48 00 63
fax: +32 10 48 00 69_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

that, if instead of the default eSound output plugin, I set xmms to use the
OSS plugin, playing sound in xmms no longer “cures” the saturation in my
app. As soon as I revert xmms to eSound output, it works again.

This is an esound bug. You might be the first one ever to play several
hours of audio in one esound stream. Seriously.

PS : is there a way to select which audio output lib SDL will use, without
recompiling it ? Something like xmms’s output plug-in selector. I took a
look at SDL’s and SDL_mixer’s APIs, but found nothing like that…

Set the SDL_AUDIODRIVER environment variable. Ideally, SDL selects the
best output driver for you based on what is available and what is compiled
in, but there are reasons to override it (the “disk” and “dummy” output
targets, for example)…generally (or, at least, historically), this is
best left to the end user.

Some targets:

export SDL_AUDIODRIVER=dsp
export SDL_AUDIODRIVER=alsa
export SDL_AUDIODRIVER=disk
export SDL_AUDIODRIVER=dummy
export SDL_AUDIODRIVER=esd
export SDL_AUDIODRIVER=arts
export SDL_AUDIODRIVER=nas
(…and more, like “waveout” on win32, etc…)

Please refer to the source for specific target strings and their
nuances…not sure if those are all accurate.

–ryan.