7 fprintf(stderr
,"tone <frequency_Hz>,[<amplitude>] [<frequency_Hz>,[<amplitude>]...]\n");
11 int main (int argc
,char *argv
[]){
18 f
=alloca(sizeof(*f
)*(argc
-1));
19 amp
=alloca(sizeof(*amp
)*(argc
-1));
23 char *pos
=strchr(argv
[i
+1],',');
27 amp
[i
]=atof(pos
+1)*32767.f
;
31 fprintf(stderr
,"%g Hz, %g amp\n",f
[i
],amp
[i
]);
36 for(i
=0;i
<44100*10;i
++){
40 val
+=amp
[j
]*sin(i
/44100.f
*f
[j
]*2*M_PI
);
43 if(ival
>32767.f
)ival
=32767.f
;
44 if(ival
<-32768.f
)ival
=-32768.f
;
46 fprintf(stdout
,"%c%c%c%c",
48 (char)((ival
>>8)&0xff),
50 (char)((ival
>>8)&0xff));