Using professor’s code, I only changed the output function. I defined new amplitude,
which I assigned 2 times the original amplitude. I also defined a frequency,
which I also assigned 2 times the original frequency. I took this new function
and added it to the original function. Although the results were different from
the original function, I do not know what these results mean. I hope to gain some
insight to it in class today, and improve my understanding of the results.
Below is the modified Professor’s code:
/********************************************************/
* Created by Christopher Dobrian on Wed Jan 14 2004.
* Modified by Faisal Bihi on Wed Jan 21 2004
#define SAMPLE_RATE (44100.)
#define TWOPI (6.283185307179586)
#define FREQUENCY (1000.)
float amplitude = MAXAMP;
float frequency = FREQUENCY;
float freq = 2*FREQUENCY;
unsigned long n; // the current sample number
unsigned long totalsamples = (unsigned long)(NUM_SECONDS*SAMPLE_RATE);
float twopiFoverR = TWOPI*frequency/SAMPLE_RATE;
float w = TWOPI*freq/SAMPLE_RATE;
float y; // the current sample value
for( n = 0; n < totalsamples; n++ )
y = amplitude*sin(twopiFoverR*n+phase) + amp*sin(w*n+phase);
fprintf(stdout, "%f\n", y);