Sine Wave Generator
Generates a sine wave ampliture*sin(angularfrequency * time) by plotting every sample
/*************************************************************************************************************
sineWaveGeneration
*************************************************************************************************************/
void sineWaveGeneration(unsigned long amplitude, unsigned long frequency, unsigned long time)
{
const double angularfrequency = (2.0 * pi) * (double)frequency;
const double pi = 3.141592654;
double timeperiod;
const double samplingrate = 48000;
double displacement;
//declare values
//obtain omega(the angular frequency)
// creates a 'for' loop that continues until 'endtime'
for (timeperiod = 0; timeperiod <= (double)time; timeperiod = timeperiod+(1/samplingrate))
{
//creates the sine wave A*sin(wt) by plotting every sample.
displacement = sin(angularfrequency * timeperiod) * amplitude;
}
return;
}