This project has moved. For the latest updates, please go here.

clicks/pops/static when playing short tones at a high rate

Apr 12 at 4:05 AM
We're generating brief audio tones at varying frequencies at a high rate. This is used for audible feedback. We used the sample SineWaveProvider class along with the WasapiOut class. On each request, we set this up, play the tone, the SineWaveProvider fills in the buffer as requested and the sound plays at the specified frequency.

What we get, though, when playing many brief tones in sequence are these clicking/popping/static type noises along side the sounds.

Not sure what's causing them. Anyone else have a similar experience? Any ideas?
Apr 17 at 6:27 PM
Got this working thanks to a helpful suggestion from Mark Heath. We're now doing the following and don't have the problem of clicking/popping artifacts when playing tones at a high rate.

1) We're using the FadeInOutSampleProvider in between the SineWaveProvider and the output player object. When requested to play a tone by the application, this is used to do a 5ms fade in and then fade out after the tone.

2) After the fade-out, we no longer call Stop() on the output player object. We just let it continue playing at 0 volume and then use a timer which, if no tones are requested for a period of time (1s) then calls Stop(). If another tone is requested before this times expires, we reset the timer, etc. This way we're not starting/stopping the player at such a high rate which was another source of the clicking/popping artifacts.

Hope this helps someone else!