-
Notifications
You must be signed in to change notification settings - Fork 306
Tips_ClickingNoises
If there is a discontinuity in the audio, for example a jump from zero to half the maximum signal level in one sample, you will hear a clicking sound. These discontinuities are commonly caused by one of the following:
-
Discontinuity in Audio Data: either the sound file or waveform you are using has a discontinuity, or you've created a discontinuity with some sort of processing. For example, if you change volume suddenly, you may hear a click as the resulting waveform jumps from one value to another. The solution is usually to "ramp" your volume or other processing parameters so that the change is made gradually over several samples, rather than all at once. There are a number of ways to do this, the easiest of which is to just to change the value linearly over the course of, say, 20 to 100 samples. So instead of jumping from a gain coefficient of .1 to .2, you go from .1 to .101 to .102 to ... to .198 to .199 to .2.
-
Dropouts: if your software and CPU are unable to provide audio data fast enough for the hardware, the hardware is forced to substitute zeros or other data to fill in the gaps. !PortAudio can detect these dropouts on some platforms, but it does not do so reliably on all platforms. Make sure you have ample CPU power for the processing you are trying to do, and make sure you follow the advice for your platform about latency and threading. Choosing a good buffer size can help a lot, both with keeping CPU usage down and improving reliability of playback. If you are unsure how to set the buffer size, try using paFramesPerBufferUnspecified, and !PortAudio will do it's best to use an optimal (an possibly changing) buffer size.
An effective way to detect dropouts is to record or play back 30 seconds to one minute of a low-frequency sine wave (about 100 Hz) and listen on a speaker. Any discontinuity in the sine wave will be readily apparent with a noticeable click in the audio. This has proven to be more effective than listening for dropouts in complex waveforms such as music or speech. The low frequency of the sine wave is fairly easy on the ears.
Note that an extremely loud pop or click can be damaging not only to your speakers, but also your ears, so keep the volume low while you are writing new software!