/* * printwave.c * WaveAsText * * Created by Christopher Dobrian on Wed Jan 14 2004. * */ #include #include #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 frequency = 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 y; // the current sample value for( n = 0 ; n < totalsamples ; n++ ) { y = amplitude*sin(twopiFoverR*n+phase); fprintf( stdout, "%f\n", y); } return 0; }