I have a problem with the sound effects in my SDL program. I’m running
out of ideas, and I’m hoping someone here might recognize the problem.
I have an SDL game with a number of sound effects. (Most of the sound
effects are less than a second long.) The game’s clock ticks 20 times
a second; at each tick, the keyboard is polled and the display is
updated, etc. Since new sound effects can be set off at every tick,
the program uses a fairly small value for the SDL_AudioSpec.samples
field when SDL_OpenAudio() is called.
The sound effects sound just fine on my machine. However, after
getting some bug reports, I discovered that on some machines, my sound
effects are “echoing”. There is a delay of approximately one second
between each sound and its echo. The echo is a little quieter and
tinny-sounding.
Currently my program calls SDL_OpenAudio() requesting freq = 22050,
fmt = AUDIO_S16LSB, and channels = 1. (And, on my test machine, the
obtained SDL_AudioSpec’s field is the same.) The value of the samples
field is calculated from the freq field – for 22050, samples is set
to 512.
One thing I’ve discovered is that changing the requested freq alters
the delay of the echo. (That is, requesting a freq of 11025 seems to
double the echo’s delay time, and requesting a freq of 44100 halves
it.)
Also, on the test machine the sound effects are of poor quality. The
sound is broken-up. It sounds as if it is due to drop-outs. However, I
don’t know if this is related to the echo problem or not. (The
descriptions of the problem that I’ve gotten from my users are
generally a little vague and confused, but I have the impression that
the echoing problem and the poor-quality problem do not always appear
together.)
There doesn’t seem to be a correlation between the “broken-up” sound
and slow machines, however. If anything, it seems to be people with
newer machines that are having problems. The test machine on which I
can reproduce the problem is a Sony Vaio running Windows XP.
Any ideas or suggestions on what might be causing this, or how I
should proceed?
b