FreeCalypso > hg > gsm-codec-lib
annotate hrutil/dec-craft.c @ 548:583dc4cbee95
efrtest: new program gsmefr-decode-tw5-r
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 04 Oct 2024 20:40:42 +0000 |
parents | 6f8abfe253a4 |
children |
rev | line source |
---|---|
518
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program facilitates hand-crafting HRv1 decoder input files (*.dec). |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * It reads a line-based ASCII source and compiles it into binary *.dec format. |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <ctype.h> |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdint.h> |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <string.h> |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <strings.h> |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "../libgsmhr1/tw_gsmhr.h" |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #define MAX_FIELDS 18 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 static char *infname, *outfname; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 static FILE *inf, *outf; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 static int lineno; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 static char linebuf[256]; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 static char *fields[MAX_FIELDS]; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 static unsigned nfields; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 static int16_t dec_frame[GSMHR_NUM_PARAMS_DEC]; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 static unsigned taf_count; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 set_all_0() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 bzero(dec_frame, sizeof(int16_t) * GSMHR_NUM_PARAMS); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 set_dhf() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 bcopy(gsmhr_dhf_params, dec_frame, sizeof(int16_t) * GSMHR_NUM_PARAMS); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 set_sid_cw() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 /* Int_LPC and Mode */ |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 dec_frame[4] = 1; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 dec_frame[5] = 3; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 /* subframe 1 */ |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 dec_frame[6] = 0xFF; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 dec_frame[7] = 0x1FF; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 dec_frame[8] = 0x1F; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 /* subframe 2 */ |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 dec_frame[9] = 0xF; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 dec_frame[10] = 0x1FF; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 dec_frame[11] = 0x1F; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 /* subframe 3 */ |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 dec_frame[12] = 0xF; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 dec_frame[13] = 0x1FF; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 dec_frame[14] = 0x1F; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 /* subframe 4 */ |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 dec_frame[15] = 0xF; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 dec_frame[16] = 0x1FF; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 dec_frame[17] = 0x1F; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 static int |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 get_line() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 char *cp; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 if (!fgets(linebuf, sizeof linebuf, inf)) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 return 1; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 lineno++; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 if (!index(linebuf, '\n')) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 fprintf(stderr, "%s line %d: too long or missing newline\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 nfields = 0; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 for (cp = linebuf; ; ) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 while (isspace(*cp)) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 cp++; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 if (*cp == '\0' || *cp == '#') |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 break; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 if (nfields >= MAX_FIELDS) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 fprintf(stderr, "%s line %d: too many fields\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 fields[nfields++] = cp; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 while (*cp && !isspace(*cp)) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 cp++; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 if (*cp) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 *cp++ = '\0'; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 return 0; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 static int |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 get_line_nonempty() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 int rc; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 for (;;) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 rc = get_line(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 if (rc) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 return rc; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 if (nfields) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 return 0; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 set_speech_params(start_param, start_arg) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 unsigned start_param, start_arg; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 unsigned ni, no; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 u_long val; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 char *cp; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 no = start_param; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 for (ni = start_arg; ni < nfields; ni++) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 if (!isxdigit(fields[ni][0])) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 inv_number: fprintf(stderr, |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 "%s line %d: field \"%s\" is not a valid number\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 infname, lineno, fields[ni]); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 val = strtoul(fields[ni], &cp, 16); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 if (*cp) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 goto inv_number; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 if (val > 0x7FF) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 fprintf(stderr, |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 "%s line %d: number \"%s\" is too large for a speech parameter\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 infname, lineno, fields[ni]); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 dec_frame[no++] = val; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 handle_r0() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 if (nfields != 2) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 fprintf(stderr, "%s line %d: R0 takes one argument\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 set_speech_params(0, 1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 handle_lpc() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 if (nfields != 5) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 fprintf(stderr, "%s line %d: LPC takes 4 arguments\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 set_speech_params(1, 1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 handle_mode() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 if (nfields != 2) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 fprintf(stderr, "%s line %d: Mode takes one argument\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 set_speech_params(5, 1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 handle_sf() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 unsigned sf_0_based; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 if (nfields != 5) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 fprintf(stderr, "%s line %d: sf takes 4 arguments\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 if (fields[1][0] < '1' || fields[1][0] > '4' || fields[1][1]) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 fprintf(stderr, |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 "%s line %d: first argument to sf must be in range [1,4]\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 } |
519
6f8abfe253a4
gsmhr-dec-craft: works after bugfix
Mychaela Falconia <falcon@freecalypso.org>
parents:
518
diff
changeset
|
189 sf_0_based = fields[1][0] - '1'; |
518
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 set_speech_params(6 + sf_0_based * 3, 2); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 handle_bfi() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 if (nfields != 2) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 fprintf(stderr, "%s line %d: BFI takes one argument\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 if (fields[1][0] < '0' || fields[1][0] > '1' || fields[1][1]) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 fprintf(stderr, |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 "%s line %d: invalid BFI argument \"%s\" (must be 0 or 1)\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 infname, lineno, fields[1]); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 dec_frame[18] = fields[1][0] - '0'; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 handle_ufi() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 if (nfields != 2) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 fprintf(stderr, "%s line %d: UFI takes one argument\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 if (fields[1][0] < '0' || fields[1][0] > '1' || fields[1][1]) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 fprintf(stderr, |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 "%s line %d: invalid UFI argument \"%s\" (must be 0 or 1)\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 infname, lineno, fields[1]); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 dec_frame[19] = fields[1][0] - '0'; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 handle_sid() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 if (nfields != 2) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 fprintf(stderr, "%s line %d: SID takes one argument\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 if (fields[1][0] < '0' || fields[1][0] > '2' || fields[1][1]) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 fprintf(stderr, |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 "%s line %d: invalid SID argument \"%s\" (must be 0, 1 or 2)\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 infname, lineno, fields[1]); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 dec_frame[20] = fields[1][0] - '0'; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 set_taf_count() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 if (nfields != 2) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 fprintf(stderr, "%s line %d: taf-count takes one argument\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 taf_count = atoi(fields[1]); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 if (taf_count > 11) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 fprintf(stderr, |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 "%s line %d: taf-count argument \"%s\" is invalid\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 infname, lineno, fields[1]); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 static void |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 emit_frame() |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 if (gsmhr_check_common_params(dec_frame) < 0) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 fprintf(stderr, |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 "%s line %d: one of the preceding speech parameters is out of range\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 infname, lineno); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 dec_frame[21] = (taf_count == 11); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 fwrite(dec_frame, 2, GSMHR_NUM_PARAMS_DEC, outf); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 taf_count++; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 if (taf_count >= 12) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 taf_count = 0; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 main(argc, argv) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 char **argv; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 int rc; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 if (argc != 3) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 fprintf(stderr, "usage: %s input.src output.dec\n", argv[0]); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 infname = argv[1]; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 outfname = argv[2]; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 inf = fopen(infname, "r"); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 if (!inf) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 perror(infname); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 outf = fopen(outfname, "w"); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 if (!outf) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 perror(outfname); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 for (;;) { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 rc = get_line_nonempty(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 if (rc) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 break; |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 if (!strcasecmp(fields[0], "all-0")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 set_all_0(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 else if (!strcasecmp(fields[0], "dhf")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 set_dhf(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 else if (!strcasecmp(fields[0], "r0")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 handle_r0(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 else if (!strcasecmp(fields[0], "lpc")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 handle_lpc(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 else if (!strcasecmp(fields[0], "mode")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 handle_mode(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 else if (!strcasecmp(fields[0], "sf")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 handle_sf(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 else if (!strcasecmp(fields[0], "bfi")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 handle_bfi(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 else if (!strcasecmp(fields[0], "ufi")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 handle_ufi(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 else if (!strcasecmp(fields[0], "sid")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 handle_sid(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 else if (!strcasecmp(fields[0], "sid-cw")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 set_sid_cw(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 else if (!strcasecmp(fields[0], "taf-count")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 set_taf_count(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 else if (!strcasecmp(fields[0], "emit-frame")) |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 emit_frame(); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 else { |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 fprintf(stderr, |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 "%s line %d: non-understood keyword \"%s\"\n", |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 infname, lineno, fields[0]); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 exit(1); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 } |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 exit(0); |
087a88d25ba2
new program gsmhr-dec-craft
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 } |