How does "buttonClicked event "effects the sound?

@PluginPenguin, @cpr2323
For example, i created a circular buffer to store a part of the input samples. It stores it but after storing and then trying to play it, it adds a bursting sound somewhere in the buffer. I tried to increase the buffer size, use a constant time to store, apply the fadein-fadeout-ramp,… nothing helped. I thought maybe it is because something else. I thought maybe there is an interrupt or something else that causes this issue.
Here is my code :

It has been more than a month but still i couldn’t find a way to get rid of it.