Unexpected frequency/sample rate modulations when playing simple tones
I'm trying to make a simple synthesizer using cpal, but I am getting strange artifacts/modulations when playing back a simple sine wave. It initially plays the correct tone, but after a few seconds other sounds start appearing until the pitch changes randomly, and then this keeps happening. I'm not sure if something is going wrong with the sample rate or what but it's very strange. I am on Windows 10 using WASAPI.
I can upload a recording of what it sounds like if need be.
Code: main_rs.txt
Hmm there could be a couple of reasons ... are there other programs running that might request a different sample rate ? Your code doesn't seem dependent on a fixed blocksize, but if it was, WASAPI has a variable blocksize.
Also, what do you mean by other sounds ? Glitches, overtones ? Does it sound broken, or just a different pitch ?
Glitches, strange overtones, it definitely sounds broken.
Also, I tried switching to ASIO and the problem still occurred, so it probably isn't specific to WASAPI.
Hello kyragit,
I test your code: 10 seconds with A4 frequency then change to low freq between G#4 and A4.