summaryrefslogtreecommitdiffstats
path: root/TOOLS/alaw-gen.c
blob: 92769015d1b81e774c96da18e3359ce64f3261d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <stdio.h>
#include <stdlib.h>

// sox -t raw -A -r 8000 -b alaw.alaw -t sw alaw.out

int main(void){
int i;
FILE *f;

f=fopen("alaw.dat","wb");
for(i=0;i<256;i++) fwrite(&i,1,1,f);
fclose(f);

system("sox -t raw -A -r 8000 -b alaw.dat -t sw alaw.out");

printf("// Generated by TOOLS/alaw-gen.c\n\n");

printf("#ifndef MPLAYER_ALAW_H\n");
printf("#define MPLAYER_ALAW_H\n");

printf("\nconst short alaw2short[]={\n");

f=fopen("alaw.out","rb");
for(i=0;i<256;i++){
  signed short x;
  fread(&x,2,1,f);
  printf("%7d",x);
  if(i!=255) putchar(',');
  if((i&7)==7) printf("\n");
}
fclose(f);
printf("};\n");

system("sox -t raw -U -r 8000 -b alaw.dat -t sw alaw.out");

printf("\nconst short ulaw2short[]={\n");

f=fopen("alaw.out","rb");
for(i=0;i<256;i++){
  signed short x;
  fread(&x,2,1,f);
  printf("%7d",x);
  if(i!=255) putchar(',');
  if((i&7)==7) printf("\n");
}
fclose(f);
printf("};\n\n");

printf("#endif /* MPLAYER_ALAW_H */\n");

return 0;
}