/* *** sin.c: sine wave *** * *** usage *** * % sin [-f] [-s] [-t] [-r] [] * *** compilation *** * % cc -o sin sin.c wavout.o -lm * (see also "make sin" in Makefile) */ #include "wav.h" WAVFMT fmt; int sampling = 44100; double frequency = 440.0; double tlength = 1.0; double range = 0.8; FILE *fd; // FILE *fd = stdout; void sinewave() { int it; int nsample = (int)((double)sampling * tlength); double tunit = 1.0/(double)sampling; for (it = 0; it < nsample; it++) { double t = (double)it * tunit; double w = sin(2.0*M_PI*frequency*t) * range; int iw = (int)((double)AMP2 * w); wavdata(fd, iw, 2); } } // void int main(argc, argv) int argc; char **argv; { int i; fd = stdout; default_format(&fmt); for (i=1; i