Clicks generally happen when there is an abrupt change in sound sample amplitude. This often can be when there are gaps in the audio buffer. In your case its probably because you are not zeroing the phase of your sine waves when you start them playing and not fading them out when they stop playing. Also, I don’t see you clamping the audio amplitude of the samples to 1.0f which you need to do to avoid clipping (which can also sound like a click).
Hope this helps…
thanks for your help. i was aware that the clicks were by abrupt sound changes, that’s why i tried the one pole filter. the one solution i think can zero the clicks is fading in/out, that will envolve adding more vars to the class, and making a fading engine for each additive voice, i was trying to bypass that, but might be worth implementing…
zeroing the phase of the sound makes also some gaps in frequency content, that’s why i am using the while loop to try make it continuous, while the phase is above TWO_PI, subtract TWO_PI (because @44.1khz the phase rapidly goes up and sin doesnt cope well with it)
the problem with the one pole filter is that is needs to be very low damping, otherwise the frequency content of the sound gets changed a lot. even with a low param to the filter it gets changed. perhaps i need to dig in better filters, like a two pole, or other stuff…
a simple lowpass filter in the volume of the sonic voice gets it just right.
in the voice i added volume and targetvolume vars; volume keeps current state, and targetvolume keeps future state, the filter goes smoothly from one to the other.