Skip to content

Instantly share code, notes, and snippets.

@enigmaticape
Created January 16, 2014 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enigmaticape/8455411 to your computer and use it in GitHub Desktop.
Save enigmaticape/8455411 to your computer and use it in GitHub Desktop.
Generate sine wave data.
void sineWaveSamples( int num_of_samples, double *buffer) {
double frequency = 260;
double sample_rate = 8000;
double increment = 2.0 * M_PI * (frequency / sample_rate);
double amplitude = 0.25;
static double theta = 0;
for( UInt32 i = 0; i < num_of_samples; i++ ) {
buffer[ i ] = amplitude * sin( theta );
theta = fmod(increment + theta, 2.0 * M_PI);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment