I\'m getting a slight distortion (sounds like buzzing) in the background when I run the following code. Because of its subtle nature it makes believe there is some sort of a
I assume you are calling this code repeatedly to play a long sound.
Is there a chance that the wave you are generating is not getting to complete a full period before it is written?
If the wave gets "cut-off" before it completes a full period and then the next wave is written to the output, you will certainly hear something strange and I assume that may be what is causing the buzzing.
For example:
/-------\ /-------\ /-------\
-----/ \ -----/ \ -----/ \
\ \ \
\----- \----- \-----
Notice the disconnect between parts of this wave. That might be causing the buzzing.