/* a440.c by Michael Thorpe 2009-07-13 */ #include #include #include #define SAMPLES_PER_SECOND 44100 #define SAMPLES_PER_BLOCK (SAMPLES_PER_SECOND/100) #define MAX_VOLUME 32767 struct note { double freq; double phase; }; const char usage[]="usage: a440 [ [..]]\n"; int main(int argc,char **argv) { const double samplelength=1.0/(double)SAMPLES_PER_SECOND; const double freqmultiplier=samplelength*2*M_PI; signed short samples[SAMPLES_PER_BLOCK]; int i,j,numnotes; long l; struct note *notes; long transpose=0; char *tmp; tmp=getenv("A440_TRANSPOSE"); if(tmp) { transpose=strtol(tmp,&tmp,10); if(*tmp) { fputs("A440_TRANSPOSE must be a valid integer\n",stderr); transpose=0; } } if(argc<=1) { fputs(usage,stderr); return(1); } numnotes=argc-1; notes=(struct note *)calloc(numnotes,sizeof(struct note)); if(!notes) { perror("calloc"); return(1); } for(j=0;j