Skip to content

Instantly share code, notes, and snippets.

void genTone(){
// fill out the array
for (int i = 0; i < numSamples; ++i) {
// sample[i] = Math.sin(2 * Math.PI * i / (sampleRate/freqOfTone));
sample[i] = Math.sin((2 * Math.PI - .001) * i / (sampleRate/freqOfTone));
}
// convert to 16 bit pcm sound array
// assumes the sample buffer is normalised.
int idx = 0;