Working on a game where I’m using AudioUnits to generate sound effects. I’ve based my sound generation code off of the sample here: http://cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html
I’ve gotten almost everything working, except I get a really annoying popping noise as each tone is starting and ending. Is there any way to filter this out? I’ve been working for hours to try and fix it and I could really use some pointers. What could cause this popping noise?
The popping noise is caused by the constant amplitude of your generated sound. The diaphragm of the speaker has to move instantly from rest position (0 amplitude) to the correct displacement for the amplitude of your first sample. The “jump” that it makes causes a popping sound.
You need to ramp up the amplitude over the first few tens of samples, and likewise ramp down when the sound ends.