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