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:
 
/********************************************************/
 
/*
 *  printwave.c
 *  WaveAsText
 *
 *  Created by Christopher Dobrian on Wed Jan 14 2004.
 *  Modified by Faisal Bihi on Wed Jan 21 2004
 *
 */
 
#include <stdio.h>
#include <math.h>
 
#define NUM_SECONDS	(1.)
#define SAMPLE_RATE     (44100.)
#define TWOPI          	(6.283185307179586)
#define MAXAMP          (1.)
#define FREQUENCY       (1000.)
 
int        main(void);
 
int main(void) {
    float amplitude = MAXAMP;
    float amp = 2*MAXAMP;
    float frequency = FREQUENCY;
    float freq = 2*FREQUENCY;
    float phase = 0.;
    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);
    }
 
    return 0;
}

 

Hosted by www.Geocities.ws

1