FreeCalypso > hg > freecalypso-tools
annotate ffstools/tiaud/compile.c @ 509:49ee210fc4fb
loadtools/scripts/*.config: new flash config
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 28 May 2019 07:42:39 +0000 |
parents | 2abc086b13ed |
children | c458e33060bf |
rev | line source |
---|---|
240
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This utility compiles a TI audio mode config file from our ASCII source |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * format into the binary for uploading into Calypso device FFS. |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/file.h> |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <ctype.h> |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <string.h> |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <strings.h> |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdio.h> |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdint.h> |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <endian.h> |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <stdlib.h> |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <unistd.h> |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "binstruct.h" |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 struct audio_cfg_bin bin; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 char *infname; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 FILE *inf; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 int lineno; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 init_nonzero_defaults() |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 bin.mic_bytes[0] = 3; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 bin.mic_fir[0] = 0x4000; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 bin.speaker_fir[0] = 0x4000; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 bin.sidetone_gain = -5; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 static long |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 strtol_wrap(arg) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 char *arg; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 char *endptr; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 long ret; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 ret = strtol(arg, &endptr, 0); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 if (*endptr) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 fprintf(stderr, "%s line %d: \"%s\" is not a valid number\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 infname, lineno, arg); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 return(ret); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 mic_gain_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 "%s line %d: mic gain setting requires an argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 if (*cp != '\0' && *cp != '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 "%s line %d: mic gain setting takes only one argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 bin.mic_bytes[0] = strtol_wrap(np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 mic_extra_gain_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 if (bin.mic_mode != AUDIO_MICROPHONE_HANDFREE) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 "%s line %d: mic extra-gain setting is only valid in aux mode\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 "%s line %d: mic extra-gain setting requires an argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 if (*cp != '\0' && *cp != '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 "%s line %d: mic extra-gain setting takes only one argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 bin.mic_bytes[1] = strtol_wrap(np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 mic_output_bias_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 int idx; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 "%s line %d: mic output-bias setting requires an argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 if (*cp != '\0' && *cp != '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 "%s line %d: mic output-bias setting takes only one argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 if (bin.mic_mode != AUDIO_MICROPHONE_HANDFREE) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 idx = 1; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 else |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 idx = 2; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 bin.mic_bytes[idx] = strtol_wrap(np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 mic_fir_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 int idx, start_idx; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 missing_arg: fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 "%s line %d: mic fir setting requires two or more arguments\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 start_idx = strtol_wrap(np); |
246
2abc086b13ed
tiaud-compile: max FIR coefficient number is 30, not 31
Mychaela Falconia <falcon@freecalypso.org>
parents:
240
diff
changeset
|
166 if (start_idx < 0 || start_idx > 30) { |
240
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 fprintf(stderr, |
246
2abc086b13ed
tiaud-compile: max FIR coefficient number is 30, not 31
Mychaela Falconia <falcon@freecalypso.org>
parents:
240
diff
changeset
|
168 "%s line %d: FIR coefficient number must be between 0 and 30\n", |
240
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 for (idx = start_idx; ; idx++) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 if (idx == start_idx) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 goto missing_arg; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 break; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 } |
246
2abc086b13ed
tiaud-compile: max FIR coefficient number is 30, not 31
Mychaela Falconia <falcon@freecalypso.org>
parents:
240
diff
changeset
|
180 if (idx > 30) { |
240
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 fprintf(stderr, |
246
2abc086b13ed
tiaud-compile: max FIR coefficient number is 30, not 31
Mychaela Falconia <falcon@freecalypso.org>
parents:
240
diff
changeset
|
182 "%s line %d: spill past FIR coefficient 30\n", |
240
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 bin.mic_fir[idx] = htole16(strtol_wrap(np)); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 mic_head_line(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 char linebuf[512]; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 "%s line %d: mic setting requires a mode argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 if (!strcmp(np, "default")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 bin.mic_mode = AUDIO_MICROPHONE_HANDHELD; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 else if (!strcmp(np, "aux")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 bin.mic_mode = AUDIO_MICROPHONE_HANDFREE; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 else if (!strcmp(np, "headset")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 bin.mic_mode = AUDIO_MICROPHONE_HEADSET; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 else { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 fprintf(stderr, "%s line %d: unknown mic mode \"%s\"\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 infname, lineno, np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 if (*cp == '\0' || *cp == '#') |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 return; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 if (*cp != '{') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 "%s line %d: invalid syntax on the mic head line\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 for (;;) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 if (!fgets(linebuf, sizeof linebuf, inf)) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 fprintf(stderr, "%s: unexpected EOF in mic section\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 infname); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 lineno++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 for (cp = linebuf; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 if (*cp == '\0' || *cp == '#') |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 continue; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 if (!strcmp(np, "gain")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 mic_gain_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 else if (!strcmp(np, "extra-gain")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 mic_extra_gain_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 else if (!strcmp(np, "output-bias")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 mic_output_bias_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 else if (!strcmp(np, "fir")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 mic_fir_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 else if (!strcmp(np, "}")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 break; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 else { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 "%s line %d: unknown mic setting \"%s\"\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 infname, lineno, np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 speaker_gain_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 if (bin.speaker_mode == AUDIO_SPEAKER_BUZZER) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 "%s line %d: speaker gain setting is not valid in buzzer mode\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 "%s line %d: speaker gain setting requires an argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 if (*cp != '\0' && *cp != '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 "%s line %d: speaker gain setting takes only one argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 bin.speaker_bytes[0] = strtol_wrap(np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 speaker_audio_filter_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 if (bin.speaker_mode == AUDIO_SPEAKER_BUZZER) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 "%s line %d: speaker audio-filter setting is not valid in buzzer mode\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 "%s line %d: speaker audio-filter setting requires an argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 if (*cp != '\0' && *cp != '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 "%s line %d: speaker audio-filter setting takes only one argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 bin.speaker_bytes[1] = strtol_wrap(np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 speaker_fir_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 int idx, start_idx; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 if (bin.speaker_mode == AUDIO_SPEAKER_BUZZER) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 "%s line %d: speaker fir setting is not valid in buzzer mode\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 missing_arg: fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 "%s line %d: speaker fir setting requires two or more arguments\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 start_idx = strtol_wrap(np); |
246
2abc086b13ed
tiaud-compile: max FIR coefficient number is 30, not 31
Mychaela Falconia <falcon@freecalypso.org>
parents:
240
diff
changeset
|
364 if (start_idx < 0 || start_idx > 30) { |
240
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 fprintf(stderr, |
246
2abc086b13ed
tiaud-compile: max FIR coefficient number is 30, not 31
Mychaela Falconia <falcon@freecalypso.org>
parents:
240
diff
changeset
|
366 "%s line %d: FIR coefficient number must be between 0 and 30\n", |
240
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 for (idx = start_idx; ; idx++) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 if (idx == start_idx) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 goto missing_arg; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 break; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 } |
246
2abc086b13ed
tiaud-compile: max FIR coefficient number is 30, not 31
Mychaela Falconia <falcon@freecalypso.org>
parents:
240
diff
changeset
|
378 if (idx > 30) { |
240
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 fprintf(stderr, |
246
2abc086b13ed
tiaud-compile: max FIR coefficient number is 30, not 31
Mychaela Falconia <falcon@freecalypso.org>
parents:
240
diff
changeset
|
380 "%s line %d: spill past FIR coefficient 30\n", |
240
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 bin.speaker_fir[idx] = htole16(strtol_wrap(np)); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 speaker_activate_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 if (bin.speaker_mode != AUDIO_SPEAKER_BUZZER) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 "%s line %d: speaker activate setting is only valid in buzzer mode\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 "%s line %d: speaker activate setting requires an argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 if (*cp != '\0' && *cp != '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 "%s line %d: speaker activate setting takes only one argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 bin.speaker_bytes[0] = strtol_wrap(np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 speaker_head_line(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 char linebuf[512]; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 "%s line %d: speaker setting requires a mode argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 if (!strcmp(np, "ear")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 bin.speaker_mode = AUDIO_SPEAKER_HANDHELD; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 else if (!strcmp(np, "aux")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
449 bin.speaker_mode = AUDIO_SPEAKER_HANDFREE; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 else if (!strcmp(np, "headset")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 bin.speaker_mode = AUDIO_SPEAKER_HEADSET; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 else if (!strcmp(np, "buzzer")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
453 bin.speaker_mode = AUDIO_SPEAKER_BUZZER; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 else if (!strcmp(np, "ear+aux")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 bin.speaker_mode = AUDIO_SPEAKER_HANDHELD_HANDFREE; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 else { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 fprintf(stderr, "%s line %d: unknown speaker mode \"%s\"\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 infname, lineno, np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 if (*cp == '\0' || *cp == '#') |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 return; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 if (*cp != '{') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 "%s line %d: invalid syntax on the speaker head line\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 for (;;) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 if (!fgets(linebuf, sizeof linebuf, inf)) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 "%s: unexpected EOF in speaker section\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 infname); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 lineno++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 for (cp = linebuf; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 if (*cp == '\0' || *cp == '#') |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 continue; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 if (!strcmp(np, "gain")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 speaker_gain_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 else if (!strcmp(np, "audio-filter")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 speaker_audio_filter_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 else if (!strcmp(np, "fir")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 speaker_fir_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 else if (!strcmp(np, "activate")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 speaker_activate_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 else if (!strcmp(np, "}")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 break; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 else { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 "%s line %d: unknown speaker setting \"%s\"\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 infname, lineno, np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
505 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 voice_path_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 "%s line %d: voice-path setting requires an argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
526 if (*cp != '\0' && *cp != '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
527 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
528 "%s line %d: voice-path setting takes only one argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
529 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
530 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
531 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
532 bin.voice_path = strtol_wrap(np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
533 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 sidetone_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 for (cp = args; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
542 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
543 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
544 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
545 "%s line %d: sidetone setting requires an argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
546 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
547 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
548 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
549 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
550 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
551 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
552 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
553 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
554 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
555 if (*cp != '\0' && *cp != '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
556 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
557 "%s line %d: sidetone setting takes only one argument\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
558 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
559 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
560 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
561 bin.sidetone_gain = strtol_wrap(np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
562 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
563 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
564 static void |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
565 aec_setting(args) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
566 char *args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
567 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
568 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
569 int n; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
570 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
571 cp = args; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
572 for (n = 0; n < 5; n++) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
573 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
574 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
575 if (*cp == '\0' || *cp == '#') { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
576 argcount_err: fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
577 "%s line %d: aec setting takes 5 arguments\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
578 infname, lineno); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
579 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
580 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
581 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
582 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
583 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
584 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
585 bin.aec_words[n] = htole16(strtol_wrap(np)); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
586 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
587 while (isspace(*cp)) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
588 cp++; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
589 if (*cp != '\0' && *cp != '#') |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
590 goto argcount_err; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
591 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
592 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
593 read_input_main() |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
594 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
595 char linebuf[512]; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
596 char *cp, *np; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
597 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
598 for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
599 for (cp = linebuf; isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
600 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
601 if (*cp == '\0' || *cp == '#') |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
602 continue; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
603 for (np = cp; *cp && !isspace(*cp); cp++) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
604 ; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
605 if (*cp) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
606 *cp++ = '\0'; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
607 if (!strcmp(np, "voice-path")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
608 voice_path_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
609 else if (!strcmp(np, "mic")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
610 mic_head_line(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
611 else if (!strcmp(np, "speaker")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
612 speaker_head_line(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
613 else if (!strcmp(np, "sidetone")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
614 sidetone_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
615 else if (!strcmp(np, "aec")) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
616 aec_setting(cp); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
617 else { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
618 fprintf(stderr, |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
619 "%s line %d: unknown top-level setting \"%s\"\n", |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
620 infname, lineno, np); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
621 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
622 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
623 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
624 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
625 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
626 write_bin_output(filename) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
627 char *filename; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
628 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
629 int fd; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
630 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
631 fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
632 if (fd < 0) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
633 perror(filename); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
634 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
635 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
636 write(fd, &bin, sizeof bin); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
637 close(fd); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
638 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
639 |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
640 main(argc, argv) |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
641 char **argv; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
642 { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
643 if (argc != 3) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
644 fprintf(stderr, "usage: %s infile outfile\n", argv[0]); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
645 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
646 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
647 if (strcmp(argv[1], "-")) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
648 infname = argv[1]; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
649 inf = fopen(infname, "r"); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
650 if (!inf) { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
651 perror(infname); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
652 exit(1); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
653 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
654 } else { |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
655 inf = stdin; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
656 infname = "stdin"; |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
657 } |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
658 init_nonzero_defaults(); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
659 read_input_main(); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
660 write_bin_output(argv[2]); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
661 exit(0); |
2568a2a8a453
tiaud-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
662 } |