Glitches in certain frequencies I am trying to produce some simple audio waves using WASAPI (Windows Audio Session API). If I skip all the abstractions, my program basically receives a buffer from the API, then writes results of a sine function (or some other simple function) of a selected frequency to the buffer sample by sample, while counting the samples to keep track of time. When it goes to the next buffer it continues with an offset of the samples passed. So in theory, it should be a simple quantization of the sine wave.

The problem is, that some frequencies work and some don't. In particular, multiples of 50 work perfectly fine, while all the other frequencies sound glitchy.

Any ideas on what problem this could be related to? Is it some quantization error maybe? Should I look into some concepts like signal-to-noise ratio? Or are these problems a matter of the DAC and not my concern.

Edit:

I agree with the comments bellow, that my code being wrong is more probable, but after trying to inspect every detail of the code and also noticing this strange behavior I just thought I might ask some more experienced people, and hope that this behavior might be suspicious of some more general problem. If it sounds like a problem specific to my implementation, then I'll try to post a simplified example of my code. (Only if this community is a right place to post such questions of course.)
I resolved my issue. The problem was with timing. My samples were rendered correctly, but the problem was with waiting for the buffer. I switched to event driven approach instead of manually calculating the buffer length and waiting, and the problem was resolved.

I don't know whether this question might be useful for someone. If not or if the source of the problem is not related to DSP, I will delete it. But for now I'm keeping it here with my answer.