Import 2.1.42pre1
[davej-history.git] / drivers / net / soundmodem / gentbl.c
blobd617865e3d8f8871f1548698889cea0e6bca3ec0
1 /*****************************************************************************/
3 /*
4 * gentbl.c -- soundcard radio modem driver table generator.
6 * Copyright (C) 1996 Thomas Sailer (sailer@ife.ee.ethz.ch)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * Please note that the GPL allows you to use the driver, NOT the radio.
23 * In order to use the radio, you need a license from the communications
24 * authority of your country.
28 #include <stdio.h>
29 #include <math.h>
30 #include <string.h>
32 /* -------------------------------------------------------------------- */
34 #define OFFSCOSTABBITS 6
35 #define OFFSCOSTABSIZE (1<<OFFSCOSTABBITS)
37 static void gentbl_offscostab(FILE *f)
39 int i;
41 fprintf(f, "\n/*\n * small cosine table in U8 format\n */\n"
42 "#define OFFSCOSTABBITS %u\n"
43 "#define OFFSCOSTABSIZE (1<<OFFSCOSTABBITS)\n\n",
44 OFFSCOSTABBITS);
45 fprintf(f, "static unsigned char offscostab[OFFSCOSTABSIZE] = {\n\t");
46 for (i = 0; i < OFFSCOSTABSIZE; i++) {
47 fprintf(f, "%4u", (int)
48 (128+127.0*cos(i*2.0*M_PI/OFFSCOSTABSIZE)));
49 if (i < OFFSCOSTABSIZE-1)
50 fprintf(f, "%s", (i & 7) == 7 ? ",\n\t" : ",");
52 fprintf(f, "\n};\n\n"
53 "#define OFFSCOS(x) offscostab[((x)>>%d)&0x%x]\n\n",
54 16-OFFSCOSTABBITS, OFFSCOSTABSIZE-1);
57 /* -------------------------------------------------------------------- */
59 #define AFSK12_SAMPLE_RATE 9600
60 #define AFSK12_TX_FREQ_LO 1200
61 #define AFSK12_TX_FREQ_HI 2200
62 #define AFSK12_CORRLEN 8
64 static void gentbl_afsk1200(FILE *f)
66 int i;
68 #define ARGLO(x) 2.0*M_PI*(double)x*(double)AFSK12_TX_FREQ_LO/(double)AFSK12_SAMPLE_RATE
69 #define ARGHI(x) 2.0*M_PI*(double)x*(double)AFSK12_TX_FREQ_HI/(double)AFSK12_SAMPLE_RATE
71 fprintf(f, "\n/*\n * afsk1200 specific tables\n */\n"
72 "#define AFSK12_SAMPLE_RATE %u\n"
73 "#define AFSK12_TX_FREQ_LO %u\n"
74 "#define AFSK12_TX_FREQ_HI %u\n"
75 "#define AFSK12_CORRLEN %u\n\n",
76 AFSK12_SAMPLE_RATE, AFSK12_TX_FREQ_LO,
77 AFSK12_TX_FREQ_HI, AFSK12_CORRLEN);
78 fprintf(f, "#if defined (CONFIG_SOUNDMODEM__AFSK1200_FP) && "
79 "(defined(CONFIG_M586) || defined(CONFIG_M686))\n\n"
80 "static const float afsk12_tx_lo_i_f[] = {\n\t");
81 for(i = 0; i < AFSK12_CORRLEN; i++)
82 fprintf(f, " %7f%c", cos(ARGLO(i)),
83 (i < AFSK12_CORRLEN-1) ? ',' : ' ');
84 fprintf(f, "\n};\n\nstatic const float afsk12_tx_lo_q_f[] = {\n\t");
85 for(i = 0; i < AFSK12_CORRLEN; i++)
86 fprintf(f, " %7f%c", sin(ARGLO(i)),
87 (i < AFSK12_CORRLEN-1) ? ',' : ' ');
88 fprintf(f, "\n};\n\nstatic const float afsk12_tx_hi_i_f[] = {\n\t");
89 for(i = 0; i < AFSK12_CORRLEN; i++)
90 fprintf(f, " %7f%c", cos(ARGHI(i)),
91 (i < AFSK12_CORRLEN-1) ? ',' : ' ');
92 fprintf(f, "\n};\n\nstatic const float afsk12_tx_hi_q_f[] = {\n\t");
93 for(i = 0; i < AFSK12_CORRLEN; i++)
94 fprintf(f, " %7f%c", sin(ARGHI(i)),
95 (i < AFSK12_CORRLEN-1) ? ',' : ' ');
96 fprintf(f, "\n};\n\n#else /* CONFIG_SOUNDMODEM_AFSK1200_FP */\n\n"
97 "static const signed char afsk12_tx_lo_i[] = {\n\t");
98 for(i = 0; i < AFSK12_CORRLEN; i++)
99 fprintf(f, " %4i%c", (int)(127.0*cos(ARGLO(i))),
100 (i < AFSK12_CORRLEN-1) ? ',' : ' ');
101 fprintf(f, "\n};\n\nstatic const signed char afsk12_tx_lo_q[] = {\n\t");
102 for(i = 0; i < AFSK12_CORRLEN; i++)
103 fprintf(f, " %4i%c", (int)(127.0*sin(ARGLO(i))),
104 (i < AFSK12_CORRLEN-1) ? ',' : ' ');
105 fprintf(f, "\n};\n\nstatic const signed char afsk12_tx_hi_i[] = {\n\t");
106 for(i = 0; i < AFSK12_CORRLEN; i++)
107 fprintf(f, " %4i%c", (int)(127.0*cos(ARGHI(i))),
108 (i < AFSK12_CORRLEN-1) ? ',' : ' ');
109 fprintf(f, "\n};\n\nstatic const signed char afsk12_tx_hi_q[] = {\n\t");
110 for(i = 0; i < AFSK12_CORRLEN; i++)
111 fprintf(f, " %4i%c", (int)(127.0*sin(ARGHI(i))),
112 (i < AFSK12_CORRLEN-1) ? ',' : ' ');
113 fprintf(f, "\n};\n\n#endif /* CONFIG_SOUNDMODEM_AFSK1200_FP */\n\n");
114 #undef ARGLO
115 #undef ARGHI
118 /* -------------------------------------------------------------------- */
120 static const float fsk96_tx_coeff_4[32] = {
121 -0.001152, 0.000554, 0.002698, 0.002753,
122 -0.002033, -0.008861, -0.008002, 0.006607,
123 0.023727, 0.018905, -0.018056, -0.057957,
124 -0.044368, 0.055683, 0.207667, 0.322048,
125 0.322048, 0.207667, 0.055683, -0.044368,
126 -0.057957, -0.018056, 0.018905, 0.023727,
127 0.006607, -0.008002, -0.008861, -0.002033,
128 0.002753, 0.002698, 0.000554, -0.001152
131 static const float fsk96_tx_coeff_5[40] = {
132 -0.001009, -0.000048, 0.001376, 0.002547,
133 0.002061, -0.001103, -0.005795, -0.008170,
134 -0.004017, 0.006924, 0.018225, 0.019238,
135 0.002925, -0.025777, -0.048064, -0.039683,
136 0.013760, 0.104144, 0.200355, 0.262346,
137 0.262346, 0.200355, 0.104144, 0.013760,
138 -0.039683, -0.048064, -0.025777, 0.002925,
139 0.019238, 0.018225, 0.006924, -0.004017,
140 -0.008170, -0.005795, -0.001103, 0.002061,
141 0.002547, 0.001376, -0.000048, -0.001009
144 #define HAMMING(x) (0.54-0.46*cos(2*M_PI*(x)));
146 static inline float hamming(float x)
148 return 0.54-0.46*cos(2*M_PI*x);
151 static inline float sinc(float x)
153 if (x == 0)
154 return 1;
155 x *= M_PI;
156 return sin(x)/x;
159 static void gentbl_fsk9600(FILE *f)
161 int i, j, k, l, m;
162 float s;
163 float c[44];
164 float min, max;
166 fprintf(f, "\n/*\n * fsk9600 specific tables\n */\n");
167 min = max = 0;
168 memset(c, 0, sizeof(c));
169 #if 0
170 memcpy(c+2, fsk96_tx_coeff_4, sizeof(fsk96_tx_coeff_4));
171 #else
172 for (i = 0; i < 29; i++)
173 c[3+i] = sinc(1.2*((i-14.0)/4.0))*hamming(i/28.0)/3.5;
174 #endif
175 fprintf(f, "static unsigned char fsk96_txfilt_4[] = {\n\t");
176 for (i = 0; i < 4; i++) {
177 for (j = 0; j < 256; j++) {
178 for (k = 1, s = 0, l = i; k < 256; k <<= 1) {
179 if (j & k) {
180 for (m = 0; m < 4; m++, l++)
181 s += c[l];
182 } else {
183 for (m = 0; m < 4; m++, l++)
184 s -= c[l];
187 s *= 0.75;
188 if (s > max)
189 max = s;
190 if (s < min)
191 min = s;
192 fprintf(f, "%4d", (int)(128+127*s));
193 if (i < 3 || j < 255)
194 fprintf(f, ",%s", (j & 7) == 7
195 ? "\n\t" : "");
198 fprintf(stderr, "fsk9600: txfilt4: min = %f; max = %f\n", min, max);
199 fprintf(f, "\n};\n\n");
200 min = max = 0;
201 memset(c, 0, sizeof(c));
202 #if 0
203 memcpy(c+2, fsk96_tx_coeff_5, sizeof(fsk96_tx_coeff_5));
204 #else
205 for (i = 0; i < 36; i++)
206 c[4+i] = sinc(1.2*((i-17.5)/5.0))*hamming(i/35.0)/4.5;
207 #endif
208 fprintf(f, "static unsigned char fsk96_txfilt_5[] = {\n\t");
209 for (i = 0; i < 5; i++) {
210 for (j = 0; j < 256; j++) {
211 for (k = 1, s = 0, l = i; k < 256; k <<= 1) {
212 if (j & k) {
213 for (m = 0; m < 5; m++, l++)
214 s += c[l];
215 } else {
216 for (m = 0; m < 5; m++, l++)
217 s -= c[l];
220 s *= 0.75;
221 if (s > max)
222 max = s;
223 if (s < min)
224 min = s;
225 fprintf(f, "%4d", (int)(128+127*s));
226 if (i < 4 || j < 255)
227 fprintf(f, ",%s", (j & 7) == 7
228 ? "\n\t" : "");
231 fprintf(stderr, "fsk9600: txfilt5: min = %f; max = %f\n", min, max);
232 fprintf(f, "\n};\n\n");
235 /* -------------------------------------------------------------------- */
237 #define AFSK26_SAMPLERATE 16000
239 #define AFSK26_NUMCAR 2
240 #define AFSK26_FIRSTCAR 2000
241 #define AFSK26_MSK_LEN 6
242 #define AFSK26_RXOVER 2
244 #define AFSK26_DEMCORRLEN (2*AFSK26_MSK_LEN)
246 #define AFSK26_WINDOW(x) ((1-cos(2.0*M_PI*(x)))/2.0)
248 #define AFSK26_AMPL(x) (((x)?1.0:0.7))
250 #undef AFSK26_AMPL
251 #define AFSK26_AMPL(x) 1
253 static void gentbl_afsk2666(FILE *f)
255 int i, j, k, l, o;
256 float window[AFSK26_DEMCORRLEN*AFSK26_RXOVER];
257 int cfreq[AFSK26_NUMCAR];
259 fprintf(f, "\n/*\n * afsk2666 specific tables\n */\n"
260 "#define AFSK26_DEMCORRLEN %d\n"
261 "#define AFSK26_SAMPLERATE %d\n\n", AFSK26_DEMCORRLEN,
262 AFSK26_SAMPLERATE);
263 fprintf(f, "static const unsigned int afsk26_carfreq[%d] = { ",
264 AFSK26_NUMCAR);
265 for (i = 0; i < AFSK26_NUMCAR; i++) {
266 cfreq[i] = 0x10000*AFSK26_FIRSTCAR/AFSK26_SAMPLERATE+
267 0x10000*i/AFSK26_MSK_LEN/2;
268 fprintf(f, "0x%x", cfreq[i]);
269 if (i < AFSK26_NUMCAR-1)
270 fprintf(f, ", ");
272 fprintf(f, " };\n\n");
273 for (i = 0; i < AFSK26_DEMCORRLEN*AFSK26_RXOVER; i++)
274 window[i] = AFSK26_WINDOW(((float)i)/(AFSK26_DEMCORRLEN*
275 AFSK26_RXOVER)) * 127.0;
276 fprintf(f, "\nstatic const struct {\n\t"
277 "signed char i[%d];\n\tsigned char q[%d];\n} afsk26_dem_tables[%d][2] = {\n",
278 AFSK26_DEMCORRLEN, AFSK26_DEMCORRLEN, AFSK26_RXOVER);
279 for (o = AFSK26_RXOVER-1; o >= 0; o--) {
280 fprintf(f, "\t{\n");
281 for (i = 0; i < AFSK26_NUMCAR; i++) {
282 j = cfreq[i];
283 fprintf(f, "\t\t{{ ");
284 for (l = AFSK26_DEMCORRLEN-1,
285 k = (j * o)/AFSK26_RXOVER; l >= 0;
286 l--, k = (k+j)&0xffffu)
287 fprintf(f, "%6d%s", (int)
288 (AFSK26_AMPL(i)*
289 window[l*AFSK26_RXOVER+o]*
290 cos(M_PI*k/32768.0)),
291 l ? ", " : " }, { ");
292 for (l = AFSK26_DEMCORRLEN-1,
293 k = (j * o)/AFSK26_RXOVER; l >= 0;
294 l--, k = (k+j)&0xffffu)
295 fprintf(f, "%6d%s", (int)
296 (AFSK26_AMPL(i)*
297 window[l*AFSK26_RXOVER+o]*
298 sin(M_PI*k/32768.0)),
299 l ? ", " : " }}");
300 if (i < 1)
301 fprintf(f, ",");
302 fprintf(f, "\n");
304 fprintf(f, "\t}%s\n", o ? "," : "");
306 fprintf(f, "};\n\n");
309 /* -------------------------------------------------------------------- */
311 #define COSTABBITS 8
313 static void gentbl_costab(FILE *f)
315 int i;
317 fprintf(f, "\n/*\n * more accurate cosine table\n */\n\n"
318 "static const short costab[%d] = {", (1<<COSTABBITS));
319 for (i = 0; i < (1<<COSTABBITS); i++) {
320 if (!(i & 7))
321 fprintf(f, "\n\t");
322 fprintf(f, "%6d", (int)(32767.0*cos(i*2.0*M_PI/(1<<COSTABBITS))));
323 if (i != ((1<<COSTABBITS)-1))
324 fprintf(f, ", ");
326 fprintf(f, "\n};\n\n#define COS(x) costab[((x)>>%d)&0x%x]\n"
327 "#define SIN(x) COS((x)+0xc000)\n\n", 16-COSTABBITS,
328 (1<<COSTABBITS)-1);
331 /* -------------------------------------------------------------------- */
333 #define ATAN_TABLEN 1024
335 static void gentbl_atantab(FILE *f)
337 int i;
338 short x;
340 fprintf(f, "\n/*\n"
341 " * arctan table (indexed by i/q; should really be indexed by i/(i+q)\n"
342 " */\n""#define ATAN_TABLEN %d\n\n"
343 "static const unsigned short atan_tab[ATAN_TABLEN+2] = {",
344 ATAN_TABLEN);
345 for (i = 0; i <= ATAN_TABLEN; i++) {
346 if (!(i & 7))
347 fprintf(f, "\n\t");
348 x = atan(i / (float)ATAN_TABLEN) / M_PI * 0x8000;
349 fprintf(f, "%6d, ", x);
351 fprintf(f, "%6d\n};\n\n", x);
355 /* -------------------------------------------------------------------- */
357 #define PSK48_TXF_OVERSAMPLING 5
358 #define PSK48_TXF_NUMSAMPLES 16
359 #define PSK48_RXF_LEN 64
361 static const float psk48_tx_coeff[80] = {
362 -0.000379, -0.000640, -0.000000, 0.000772,
363 0.000543, -0.000629, -0.001187, -0.000000,
364 0.001634, 0.001183, -0.001382, -0.002603,
365 -0.000000, 0.003481, 0.002472, -0.002828,
366 -0.005215, -0.000000, 0.006705, 0.004678,
367 -0.005269, -0.009584, -0.000000, 0.012065,
368 0.008360, -0.009375, -0.017028, -0.000000,
369 0.021603, 0.015123, -0.017229, -0.032012,
370 -0.000000, 0.043774, 0.032544, -0.040365,
371 -0.084963, -0.000000, 0.201161, 0.374060,
372 0.374060, 0.201161, -0.000000, -0.084963,
373 -0.040365, 0.032544, 0.043774, -0.000000,
374 -0.032012, -0.017229, 0.015123, 0.021603,
375 -0.000000, -0.017028, -0.009375, 0.008360,
376 0.012065, -0.000000, -0.009584, -0.005269,
377 0.004678, 0.006705, -0.000000, -0.005215,
378 -0.002828, 0.002472, 0.003481, -0.000000,
379 -0.002603, -0.001382, 0.001183, 0.001634,
380 -0.000000, -0.001187, -0.000629, 0.000543,
381 0.000772, -0.000000, -0.000640, -0.000379
384 static const float psk48_rx_coeff[PSK48_RXF_LEN] = {
385 -0.000219, 0.000360, 0.000873, 0.001080,
386 0.000747, -0.000192, -0.001466, -0.002436,
387 -0.002328, -0.000699, 0.002101, 0.004809,
388 0.005696, 0.003492, -0.001633, -0.007660,
389 -0.011316, -0.009627, -0.001780, 0.009712,
390 0.019426, 0.021199, 0.011342, -0.008583,
391 -0.030955, -0.044093, -0.036634, -0.002651,
392 0.054742, 0.123101, 0.184198, 0.220219,
393 0.220219, 0.184198, 0.123101, 0.054742,
394 -0.002651, -0.036634, -0.044093, -0.030955,
395 -0.008583, 0.011342, 0.021199, 0.019426,
396 0.009712, -0.001780, -0.009627, -0.011316,
397 -0.007660, -0.001633, 0.003492, 0.005696,
398 0.004809, 0.002101, -0.000699, -0.002328,
399 -0.002436, -0.001466, -0.000192, 0.000747,
400 0.001080, 0.000873, 0.000360, -0.000219
403 static void gentbl_psk4800(FILE *f)
405 int i, j, k;
406 short x;
408 fprintf(f, "\n/*\n * psk4800 specific tables\n */\n"
409 "#define PSK48_TXF_OVERSAMPLING %d\n"
410 "#define PSK48_TXF_NUMSAMPLES %d\n\n"
411 "#define PSK48_SAMPLERATE 8000\n"
412 "#define PSK48_CAR_FREQ 2000\n"
413 "#define PSK48_PSK_LEN 5\n"
414 "#define PSK48_RXF_LEN %u\n"
415 "#define PSK48_PHASEINC (0x10000*PSK48_CAR_FREQ/PSK48_SAMPLERATE)\n"
416 "#define PSK48_SPHASEINC (0x10000/(2*PSK48_PSK_LEN))\n\n"
417 "static const short psk48_tx_table[PSK48_TXF_OVERSAMPLING*"
418 "PSK48_TXF_NUMSAMPLES*8*2] = {",
419 PSK48_TXF_OVERSAMPLING, PSK48_TXF_NUMSAMPLES, PSK48_RXF_LEN);
420 for (i = 0; i < PSK48_TXF_OVERSAMPLING; i++) {
421 for (j = 0; j < PSK48_TXF_NUMSAMPLES; j++) {
422 fprintf(f, "\n\t");
423 for (k = 0; k < 8; k++) {
424 x = 32767.0 * cos(k*M_PI/4.0) *
425 psk48_tx_coeff[j * PSK48_TXF_OVERSAMPLING + i];
426 fprintf(f, "%6d, ", x);
428 fprintf(f, "\n\t");
429 for (k = 0; k < 8; k++) {
430 x = 32767.0 * sin(k*M_PI/4.0) *
431 psk48_tx_coeff[j * PSK48_TXF_OVERSAMPLING + i];
432 fprintf(f, "%6d", x);
433 if (k != 7 || j != PSK48_TXF_NUMSAMPLES-1 ||
434 i != PSK48_TXF_OVERSAMPLING-1)
435 fprintf(f, ", ");
439 fprintf(f, "\n};\n\n");
441 fprintf(f, "static const short psk48_rx_coeff[PSK48_RXF_LEN] = {\n\t");
442 for (i = 0; i < PSK48_RXF_LEN; i++) {
443 fprintf(f, "%6d", (int)(psk48_rx_coeff[i]*32767.0));
444 if (i < PSK48_RXF_LEN-1)
445 fprintf(f, ",%s", (i & 7) == 7 ? "\n\t" : "");
447 fprintf(f, "\n};\n\n");
450 /* -------------------------------------------------------------------- */
452 static void gentbl_hapn4800(FILE *f)
454 int i, j, k, l;
455 float s;
456 float c[40];
457 float min, max;
459 fprintf(f, "\n/*\n * hapn4800 specific tables\n */\n\n");
461 * firstly generate tables for the FM transmitter modulator
463 min = max = 0;
464 memset(c, 0, sizeof(c));
465 for (i = 0; i < 24; i++)
466 c[8+i] = sinc(1.5*((i-11.5)/8.0))*hamming(i/23.0)/2.4;
467 for (i = 0; i < 24; i++)
468 c[i] -= c[i+8];
469 fprintf(f, "static unsigned char hapn48_txfilt_8[] = {\n\t");
470 for (i = 0; i < 8; i++) {
471 for (j = 0; j < 16; j++) {
472 for (k = 1, s = 0, l = i; k < 16; k <<= 1, l += 8) {
473 if (j & k)
474 s += c[l];
475 else
476 s -= c[l];
478 if (s > max)
479 max = s;
480 if (s < min)
481 min = s;
482 fprintf(f, "%4d", (int)(128+127*s));
483 if (i < 7 || j < 15)
484 fprintf(f, ",%s", (j & 7) == 7
485 ? "\n\t" : "");
488 fprintf(stderr, "hapn4800: txfilt8: min = %f; max = %f\n", min, max);
489 fprintf(f, "\n};\n\n");
490 min = max = 0;
491 memset(c, 0, sizeof(c));
492 for (i = 0; i < 30; i++)
493 c[10+i] = sinc(1.5*((i-14.5)/10.0))*hamming(i/29.0)/2.4;
494 for (i = 0; i < 30; i++)
495 c[i] -= c[i+10];
496 fprintf(f, "static unsigned char hapn48_txfilt_10[] = {\n\t");
497 for (i = 0; i < 10; i++) {
498 for (j = 0; j < 16; j++) {
499 for (k = 1, s = 0, l = i; k < 16; k <<= 1, l += 10) {
500 if (j & k)
501 s += c[l];
502 else
503 s -= c[l];
505 if (s > max)
506 max = s;
507 if (s < min)
508 min = s;
509 fprintf(f, "%4d", (int)(128+127*s));
510 if (i < 9 || j < 15)
511 fprintf(f, ",%s", (j & 7) == 7
512 ? "\n\t" : "");
515 fprintf(stderr, "hapn4800: txfilt10: min = %f; max = %f\n", min, max);
516 fprintf(f, "\n};\n\n");
518 * secondly generate tables for the PM transmitter modulator
520 min = max = 0;
521 memset(c, 0, sizeof(c));
522 for (i = 0; i < 25; i++)
523 c[i] = sinc(1.4*((i-12.0)/8.0))*hamming(i/24.0)/6.3;
524 for (i = 0; i < 25; i++)
525 for (j = 1; j < 8; j++)
526 c[i] += c[i+j];
527 fprintf(f, "static unsigned char hapn48_txfilt_pm8[] = {\n\t");
528 for (i = 0; i < 8; i++) {
529 for (j = 0; j < 16; j++) {
530 for (k = 1, s = 0, l = i; k < 16; k <<= 1, l += 8) {
531 if (j & k)
532 s += c[l];
533 else
534 s -= c[l];
536 if (s > max)
537 max = s;
538 if (s < min)
539 min = s;
540 fprintf(f, "%4d", (int)(128+127*s));
541 if (i < 7 || j < 15)
542 fprintf(f, ",%s", (j & 7) == 7
543 ? "\n\t" : "");
546 fprintf(stderr, "hapn4800: txfiltpm8: min = %f; max = %f\n", min, max);
547 fprintf(f, "\n};\n\n");
548 min = max = 0;
549 memset(c, 0, sizeof(c));
550 for (i = 0; i < 31; i++)
551 c[10+i] = sinc(1.4*((i-15.0)/10.0))*hamming(i/30.0)/7.9;
552 for (i = 0; i < 31; i++)
553 for (j = 1; j < 10; j++)
554 c[i] += c[i+j];
555 fprintf(f, "static unsigned char hapn48_txfilt_pm10[] = {\n\t");
556 for (i = 0; i < 10; i++) {
557 for (j = 0; j < 16; j++) {
558 for (k = 1, s = 0, l = i; k < 16; k <<= 1, l += 10) {
559 if (j & k)
560 s += c[l];
561 else
562 s -= c[l];
564 if (s > max)
565 max = s;
566 if (s < min)
567 min = s;
568 fprintf(f, "%4d", (int)(128+127*s));
569 if (i < 9 || j < 15)
570 fprintf(f, ",%s", (j & 7) == 7
571 ? "\n\t" : "");
574 fprintf(stderr, "hapn4800: txfiltpm10: min = %f; max = %f\n", min, max);
575 fprintf(f, "\n};\n\n");
579 /* -------------------------------------------------------------------- */
581 static char *progname;
583 static void gentbl_banner(FILE *f)
585 fprintf(f, "/*\n * THIS FILE IS GENERATED AUTOMATICALLY BY %s, "
586 "DO NOT EDIT!\n */\n\n", progname);
589 /* -------------------------------------------------------------------- */
591 void main(int argc, char *argv[])
593 FILE *f;
595 progname = argv[0];
596 if (!(f = fopen("sm_tbl_afsk1200.h", "w")))
597 exit(1);
598 gentbl_banner(f);
599 gentbl_offscostab(f);
600 gentbl_afsk1200(f);
601 fclose(f);
602 if (!(f = fopen("sm_tbl_afsk2666.h", "w")))
603 exit(1);
604 gentbl_banner(f);
605 gentbl_offscostab(f);
606 gentbl_afsk2666(f);
607 fclose(f);
608 if (!(f = fopen("sm_tbl_psk4800.h", "w")))
609 exit(1);
610 gentbl_banner(f);
611 gentbl_psk4800(f);
612 gentbl_costab(f);
613 gentbl_atantab(f);
614 fclose(f);
615 if (!(f = fopen("sm_tbl_hapn4800.h", "w")))
616 exit(1);
617 gentbl_banner(f);
618 gentbl_hapn4800(f);
619 fclose(f);
620 if (!(f = fopen("sm_tbl_fsk9600.h", "w")))
621 exit(1);
622 gentbl_banner(f);
623 gentbl_fsk9600(f);
624 fclose(f);
625 exit(0);
629 /* -------------------------------------------------------------------- */