I\'m trying to use AudioTrack to generate sine, square, and sawtooth waves. However, the audio this is creating doesn\'t sound like a pure sine wave, but like it has some kind o
None of these anwers fixes the problem. The buffer length should be a multiple of the sample rate, or at least the length of one rotation. Let's break it in ton of variables to show we understand things:
int sampleRate = 44100;
int bitsPerChannel = 16;
int bytesPerChannel = bitsPerChannel / 8;
int channelCount = 1;
int bytesPerSample = channelCount * bytesPerChannel;
int bytesPerRotation = sampleRate * bytesPerSample * (1d / (double) frequency);
Then you can multiply this bytesPerRotation
by anything, it won't change a fact: there won't be glitch in the sound.