Original Post

I wrote a PCM mixer last week and it’s running great but when starting from silence, the sounds generated always start with a very noticeable “pop” at the beginning and end. Is there a way to prevent this? The effects themselves contain no such artifacts, but I’ve tried introducing a fade in/out, and also tried leaving the DC value wherever it leaves off instead of resetting to zero, but neither of those techniques seem to work. It doesn’t seem to matter what the first or last sample is; that irritating pop is always there.

I did a capture from the headphone jack in Audacity for reference, attached. Any ideas? DogP? Guy Perfect?

6 Replies

By silence, do you mean SSTOP? Is it any different if you just set the volume of each channel to 0?

Ah, good question. No, I only set SSTOP when I initialize the DC waveform, then I reset SSTOP and from then on just leave LRV of each channel at 0 unless there are samples played.

Using SSTOP for SFX silence isn’t an option for me since I have music playing in the other channels.

Does it also occur in an emulator or just the hardware?

I didn’t encounter this when doing PCM of my own last year:

I have a hypothesis as to why, and I think it has to do with your source data. It’s a characteristic phenomenon of PCM processing on any architecture that if you don’t start and stop a sound on silence, you’ll hear a pop when it abruptly switches between states. The same is true when pausing and unpausing an audio stream mid-playback, but it’s less noticeable the higher the sampling rate and/or bit depth are (plus, either the media player or the hardware tends to apply a super-fast fade when the playback state changes).

Try it yourself: load up some sound in your editor and find a spot with a sample with a value far from zero:

Silence the track at that point, but don’t delete the remainder outright (to prevent any hardware-based fade). You might have to listen closely, but there’s definitely an itty-bitty high-pitched pop if you do that.

So that’s my advice. Check your source data, and if it doesn’t begin and end on silence, use a short fade yourself that’s too fast to hear. That should hopefully solve your issue.

Thanks Guy Perfect!

In my first post I tried adding a fade in/out to my sound files as you suggested but that had no effect on the popping. However, what you said got me to take a closer look at the raw sound data, and that got me thinking (always a scary thing). My mixer was resetting LRV to 0 when there were no samples to play, and my sound data is converted from unsigned 8-bit PCM to unsigned 4-bit. *But,* unsigned PCM is more like “offset PCM,” centered around 0x80, not 0 as I had incorrectly assumed. So… I added a tiny bit of code that resets LRV to 0x88 when no samples are present, and now the pops are gone, both on hardware and in Mednafen. 🙂

 

Write a reply

You must be logged in to reply to this topic.