[Openal] Popping and Chirping When Playing Short Sounds on Windows
Michael Buckley
thebuckley at gmail.com
Sun Apr 26 12:40:18 PDT 2009
Greetings,
I am currently developing a multi-platform (Windows, OS X, Linux)
computer game using OpenAL to handle music and sound effects. OpenAL
has been very easy to work with, and thus everything is going great
with the exception of two small problems on Windows XP and Vista. I
have confirmed these problems on 3 different computers: an Intel Mac
Mini running Windows XP (using Boot Camp), a Dell desktop running
Windows XP, and an HP laptop running Windows Vista. These problems do
not happen on the same Intel Mac Mini when it is booted into OS X.
The first problem is that there is popping and chirping when the 3
shortest sound effects play. These sound effects are loaded from WAV
files, and all of them fade out over the length of the sound. That is,
I am not using OpenAL to fade the sounds out, but that the amplitude
of the sound wave decreases.
One of these sounds is 0.2 seconds long. This sound has less problems
than the other two. There is merely an audible pop or click when the
sound finishes.
The other two sounds cause a chirping effect. These sounds are
shorter, being 0.86 seconds each.
All of the other sound effects in the game are > 0.25 seconds in
length, and do not cause any problems.
I am not using any attenuation on the sounds. I have tried setting the
position and velocity (to 0) of the sound and the listener explicitly,
but there was no difference. Using the debugger, I have made sure that
I am getting the right data, frequency, format and size from the WAV
file. All I am doing is creating a source, setting the pitch and gain
on it, creating a buffer, filling it with the data from the WAV file,
associating the source with the buffer, and calling alSourcePlay to
play the source.
So far, I have tried creating a buffer, three things to fix the
problem. The first is to set the gain of the source to 0 or 0.001 when
the sound has finished playing. This had no effect. Next, I attempted
to make the buffer a minimum of 0.5 seconds. I did this by mallocing
an ALvoid array of size 0.5 * frequency * 2, memsetting it to 0, and
then copying the WAV data into the start of the array. I made sure
that I was passing the size of the WAV file, and not the size of the
array, to memcmp. This had no affect on OS X, and it did not fix the
problem on WIndows. However, I noticed that the longer I made the
buffer, the worse the problem became. Finally, I tried OpenAL Soft.
This eliminated the problem with the longer of the three sound
effects, and made the chirping less noticeable for the other two, but
did not completely solve the problem.
My other problem is perhaps not a problem with OpenAL itself. I am
using OpenGL to do the graphics for the game, and SDL to set up the
graphics context and handle input. If the game is in Windowed mode,
and the player moves the window or minimizes it, the sound cuts out.
Sources played with alSourcePlay after this point will play, but
anything playing before the window is moved gets cut off. Again, this
is not a problem on OS X, and using OpenAL Soft did not fix the issue.
I would appreciate any help in solving either of these problems.
- Michael Buckley
More information about the Openal
mailing list