OpenAL clicking

Member
Posts: 64
Joined: 2008.10
Post: #1
I reciently noticed all my OpenAL sounds have a small click noise at the start. It's quite subtle, so you hardly notice, but it is there. It only happens on a random basis. It seems to only happen on the speaker, not earphones. Anyone else have similiar problem?
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #2
Audio "clicks" in digital audio systems are always because of abrupt sample amplitude changes. The reason it is apparently random is because the audio signal varies rapidly, and the condition at which the click is heard depends on exactly when and where in the waveform the abrupt change happens in the overall audio stream. There are several possible causes of something like that, and some of them might be because of poor audio hardware or poor system software, which you cannot control, and some of them might be because of your sound effects or the way you play them.

As you probably already know, the audio is a waveform which centers around an imaginary zero. Let's say the range is between 0 and 255 and zero is 127. Assuming your sound effect starts at 127, if the current audio stream is at 0 and your sound starts playing, an audible "click" will be heard because it jumped from 0 to 127 in one sample. The larger the jump the louder the "click". One way you can help minimize such an occurrence is to make sure that your sound effects don't start with a loud amplitude. Go into something like Audacity and make sure the sound effect starts at zero and then quickly pans to full volume over a few samples, as needed. It can be done in such a way that you can't even hear the difference, but it can help eliminate clicks.

Another possible problem might be if you let sound effects interrupt other sound effects instead of letting them play over each other. That might happen if you're using OpenAL and reusing the same source before it finishes playing. What might happen in that case is that the previous sound effect might be at a loud amplitude of say 255, and the next sound interrupts it and starts at 0, which again, will sound like a click.

The reason why it might sound different on the speaker than in the earphones is because of the way the D/A converter works, which is likely a different converter than for the earphones. Also some software feeding the hardware can filter out the clicks, while some might not.
Quote this message in a reply
Member
Posts: 64
Joined: 2008.10
Post: #3
Thanks for the answer.
All my sound effects have a small fade in, so they should start around zero. However I do stop some sounds in mid stream and then play a wind-down sound. Maybe that's what's causing the problem.
On windows I'm playing the exact same sounds on OpenAL with no clicking artifacts.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #4
(Aug 5, 2010 12:04 PM)captainfreedom Wrote:  On windows I'm playing the exact same sounds on OpenAL with no clicking artifacts.

Yeah, well, like I said, it really depends on what the system software is doing to filter out those clicks, if anything, and what the D/A converter does. Filtering does come at the cost of audio fidelity, since it's filtering out what is essentially a high frequency, high amplitude signal for that instant. The D/A converter on your Windows box might be different from other machines, so just because it sounds right on one box, doesn't mean it won't click on another. The OpenAL implementation alone may be responsible for the difference though, so perhaps it is the same on all Windows machines.

For instance, the particular implementation of the OpenAL library knows that a sound is already playing and that you're playing something else in place of that particular source, so it can blend in the new sound over the old one over the course of like ten samples to avoid the click. I have a library of my own called sfxLite, in which I do a few little tricks like that when playing or stopping sounds. IOW, it doesn't stop immediately and the sounds all get a few samples blending to start. This was my first attempt at software audio rendering so it's an old library now and there are still a few rendering mistakes. Like one that I didn't realize would be a problem is panning from side to side. If you go immediately from one speaker to the next, it also makes a little click. I figured out how to blend that too, but that's not in this version. My point in bringing this up is that dealing with abrupt amplitude changes may or may not be taken care of for you. OpenAL has to be implemented on each platform it's on so there's no way to know what measures have been taken to ensure consistency in filtering out clicks behind the scenes from one platform to the next. Beyond the OpenAL implementation, there is probably also a low-level A/D driver which may be responsible for some filtering as well.

If you change your playing technique to use a fresh source for each sound effect so they can layer on top of each other and you're still getting clicks in the playback on the speaker, I would say file a bug!
Quote this message in a reply
Post Reply