879
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3
|
|
4 // sox -t raw -A -r 8000 -b alaw.alaw -t sw alaw.out
|
|
5
|
|
6 int main(){
|
|
7 int i;
|
|
8 FILE *f;
|
|
9
|
|
10 f=fopen("alaw.dat","wb");
|
|
11 for(i=0;i<256;i++) fwrite(&i,1,1,f);
|
|
12 fclose(f);
|
|
13
|
|
14 system("sox -t raw -A -r 8000 -b alaw.dat -t sw alaw.out");
|
|
15
|
|
16 printf("// Generated by TOOLS/alaw-gen.c\n");
|
|
17
|
|
18 printf("\nshort alaw2short[]={\n");
|
|
19
|
|
20 f=fopen("alaw.out","rb");
|
|
21 for(i=0;i<256;i++){
|
|
22 signed short x;
|
|
23 fread(&x,2,1,f);
|
|
24 printf("%6d",x);
|
|
25 if(i!=255) putchar(',');
|
|
26 if((i&7)==7) printf("\n");
|
|
27 }
|
|
28 fclose(f);
|
880
|
29 printf("};\n");
|
879
|
30
|
|
31 system("sox -t raw -U -r 8000 -b alaw.dat -t sw alaw.out");
|
|
32
|
|
33 printf("\nshort ulaw2short[]={\n");
|
|
34
|
|
35 f=fopen("alaw.out","rb");
|
|
36 for(i=0;i<256;i++){
|
|
37 signed short x;
|
|
38 fread(&x,2,1,f);
|
|
39 printf("%6d",x);
|
|
40 if(i!=255) putchar(',');
|
|
41 if((i&7)==7) printf("\n");
|
|
42 }
|
|
43 fclose(f);
|
880
|
44 printf("};\n");
|
879
|
45
|
|
46
|
|
47 }
|