1

I'm looping this sound file: http://engy.us/misc/ThrusterLoop.wav . It plays perfectly in Windows on any number of players, but when I load it in as a SoundEffect in XNA it has these annoying clicks at the start and end of playback.

If I loop it for a while it doesn't do any of these annoying clicks in the middle. If I play it as a standalone sound, it will still click at the start. It's doing this clicking both in the emulator and on my physical device.

Why is it doing this? Is there something wrong with my sound file? It's a 16-bit Stereo 44.1 kHz PCM WAV file, which I assumed was pretty standard.

(edit2) I captured the sound produced through playback through XNA and compared it with the original waveform. Take a look:

http://engy.us/pics/Waveform_Original.png
http://engy.us/pics/Waveform_EmulatorXNA.png

Something is pretty screwed up with that playback! The two large amplitude changes must have been the clicks I heard. It seems to scramble up the first bit somewhat. Putting silence at the start probably helped some people because scrambled up silence doesn't produce any clicks.

RandomEngy
  • 14,931
  • 5
  • 70
  • 113

1 Answers1

1

Use a program like Audacity to take a look at the waveform of your sound. You can reduce or eliminate 'clicking' by properly lining up the waveform so that it starts and ends at the 0db mark (center line). In Audacity you can do this by using the Fade In and Fade Out at the front and back respectively, though this will cause the volume of your sound to 'pulse'. To get around that, zoom in as much as possible and only use Fade In / Out on the smallest possible selectable area at the front and back.

One thing to note is that you want the wave to continue to... wave, when it loops. As in, if your waveform is pointing up at the beginning of the sound (it starts by going up from 0db), it should be coming up to 0db from below at the end, so that if you were to copy+paste the sound right after itself, it forms a nice wave instead of a peak.

A-Type
  • 1,148
  • 1
  • 7
  • 17
  • Edited question to show the start of the sound. I deliberately cut it to start quite close to 0 and it does not click when playing the sound in WMP, Audacity, or in any normal media player. It only does so when played as a SoundEffect in XNA. When I get home I will capture what it actually sounds like in the emulator and contrast it with the source. Oh and I did edit it to continue to wave on loop: I cut the start and crossfaded it with the end so I get a seamless loop. How the actual loop sounds is not the problem. The clicks at the start of playback in XNA are. – RandomEngy Jun 06 '12 at 18:52
  • The right channel looks a little displaced. Zooming down to the sample level will show whether that is so. Even the smallest offset tends to make a click. I've definitely noticed XNA does it more noticeably than other media players; I assume this is due to compression of sound files for games. If you really can't figure it out you could always make the sound fade in programmatically using the volume parameter of the soundeffect. Anyways, I presume because the click only occurs at the beginning and you have crossfaded the loop, that the issue is jumping from 0db to whatever your start is. – A-Type Jun 06 '12 at 21:12
  • Edited question to show the waveform of the original file versus the waveform of playback within XNA. The clicks are definitely getting introduced in XNA! – RandomEngy Jun 07 '12 at 00:02
  • Ah, I see. Yes, that's substantially different. It has to be due to the compression or inaccuracy from the content processor... I'm afraid I wouldn't be able to help with that. This could possibly be of use if you can change your sound file type: http://xnawavpack.codeplex.com/. It skips the content importer entirely. – A-Type Jun 07 '12 at 19:44