I'm trying to generate a simple sine wave in rtaudio to verify I understand what's going on. However, it is coming out wrong.
I have a global float timec
, and a callback invoked with openStream
which should fill a buffer with samples.
float freq = 440; // center frequency
int SAMPLE_RATE = 44100;
for (int i = 0; i < numFrames; i++) {
float v = sin(2 * M_PI * freq * (timec / SAMPLE_RATE));
outputbuffer[i] = v;
timec++;
}
What have I done wrong? Instead of a sine wave, I hear a low grinding sound.