comparison spandsp-0.0.3/spandsp-0.0.3/tests/make_line_models.c @ 5:f762bf195c4b

import spandsp-0.0.3
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 16:00:21 +0200
parents
children
comparison
equal deleted inserted replaced
4:26cd8f1ef0b1 5:f762bf195c4b
1 /*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * make_line_models.c
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2004 Steve Underwood
9 *
10 * All rights reserved.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2, as
14 * published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 * $Id: make_line_models.c,v 1.19 2006/11/23 15:48:09 steveu Exp $
26 */
27
28 /*! \page make_line_models_page Telephony line model construction
29 \section make_line_models_page_sec_1 What does it do?
30 ???.
31
32 \section make_line_models_page_sec_2 How does it work?
33 ???.
34 */
35
36 #ifdef HAVE_CONFIG_H
37 #include "config.h"
38 #endif
39
40 #include <inttypes.h>
41 #include <string.h>
42 #include <stdio.h>
43 #include <stdlib.h>
44 #if defined(HAVE_FFTW3_H)
45 #include <fftw3.h>
46 #else
47 #include <fftw.h>
48 #endif
49 #if defined(HAVE_TGMATH_H)
50 #include <tgmath.h>
51 #endif
52 #if defined(HAVE_MATH_H)
53 #include <math.h>
54 #endif
55 #include <tiffio.h>
56
57 #include "spandsp.h"
58
59 #if !defined(M_PI)
60 # define M_PI 3.14159265358979323846 /* pi */
61 #endif
62
63 #define SAMPLE_RATE 8000
64
65 #define LINE_FILTER_SIZE 129
66 #define FFT_SIZE 1024
67
68 /* Tabulated medium range telephone line response
69 (from p 537, Digital Communication, John G. Proakis */
70 /*
71 amp 1.0 -> 2.15, freq = 3000 Hz -> 3.2, by 0.2 increments
72 delay = 4 ms -> 2.2
73 */
74
75 struct
76 {
77 int frequency;
78 float amp;
79 float delay;
80 } proakis[] =
81 {
82 { 0, 0.00, 4.80},
83 { 200, 0.90, 3.50},
84 { 400, 1.40, 2.20},
85 { 600, 1.80, 0.90},
86 { 800, 2.00, 0.50},
87 {1000, 2.10, 0.25},
88 {1200, 2.30, 0.10},
89 {1400, 2.30, 0.05},
90 {1600, 2.20, 0.00},
91 {1800, 2.10, 0.00},
92 {2000, 2.00, 0.00},
93 {2200, 1.85, 0.05},
94 {2400, 1.75, 0.10},
95 {2600, 1.55, 0.20},
96 {2800, 1.30, 0.40},
97 {3000, 1.10, 0.50},
98 {3200, 0.80, 0.90},
99 {3400, 0.55, 1.20},
100 {3600, 0.25, 2.20},
101 {3800, 0.05, 3.20},
102 {4000, 0.05, 4.20},
103 {4200, 0.05, 5.20}
104 };
105
106 #define CPE_TO_CO_ATTENUATION 0 /* In dB */
107 #define CPE_TO_CO_DELAY 1 /* In us */
108 #define CPE_TO_CO_IMPEDANCE 2 /* In ohms */
109 #define CPE_TO_CO_PHASE 3 /* In degrees */
110 #define CO_TO_CPE_IMPEDANCE 4 /* In ohms */
111 #define CO_TO_CPE_PHASE 5 /* In degrees */
112 #define CO_TO_CPE_ATTENUATION 6 /* In dB */
113 #define CO_TO_CPE_DELAY 7 /* In us */
114
115 /* Terms used, for V.56bis:
116 AD = attenuation distortion
117 EDD = envelope delay distortion */
118
119 /* V.56bis EIA LL-1, non-loaded loop */
120
121 struct
122 {
123 int freq;
124 float ad[8];
125 } eia_ll1[] =
126 {
127 { 200, {0.0, 0.4, 767, -1.4, 767, -1.4, 0.0, 0.4}},
128 { 300, {0.0, 0.7, 766, -2.0, 766, -2.0, 0.0, 0.7}},
129 { 400, {0.0, 0.5, 763, -2.8, 763, -2.8, 0.0, 0.5}},
130 { 500, {0.0, 0.6, 765, -3.4, 765, -3.4, 0.0, 0.6}},
131 { 600, {0.0, 0.2, 764, -4.1, 764, -4.1, 0.0, 0.2}},
132 { 700, {0.0, 0.4, 764, -4.7, 764, -4.7, 0.0, 0.4}},
133 { 800, {0.0, 0.4, 762, -5.4, 762, -5.4, 0.0, 0.4}},
134 { 900, {0.0, 0.2, 762, -6.0, 762, -6.0, 0.0, 0.2}},
135 {1000, {1.2, 0.5, 761, -6.7, 761, -6.7, 1.2, 0.5}},
136 {1100, {0.0, 0.6, 759, -7.4, 759, -7.4, 0.0, 0.6}},
137 {1200, {0.0, 0.4, 757, -8.1, 757, -8.1, 0.0, 0.4}},
138 {1300, {0.0, 0.1, 757, -8.6, 757, -8.6, 0.0, 0.1}},
139 {1400, {0.0, 0.3, 755, -9.3, 755, -9.3, 0.0, 0.3}},
140 {1500, {0.0, 0.4, 753, -10.0, 753, -10.0, 0.0, 0.4}},
141 {1600, {0.0, 0.3, 751, -10.7, 751, -10.7, 0.0, 0.3}},
142 {1700, {0.0, 0.1, 748, -11.3, 748, -11.3, 0.0, 0.1}},
143 {1800, {0.0, 11.0, 748, -11.9, 748, -11.9, 0.0, 11.0}},
144 {1900, {0.1, 0.1, 745, -12.5, 745, -12.5, 0.1, 0.1}},
145 {2000, {0.1, 0.3, 743, -13.9, 743, -13.9, 0.1, 0.3}},
146 {2100, {0.1, 0.3, 740, -13.9, 740, -13.9, 0.1, 0.3}},
147 {2200, {0.1, 0.3, 737, -14.5, 737, -14.5, 0.1, 0.3}},
148 {2300, {0.1, 0.3, 734, -15.2, 734, -15.2, 0.1, 0.3}},
149 {2400, {0.1, 0.2, 731, -15.8, 731, -15.8, 0.1, 0.2}},
150 {2500, {0.1, 0.0, 728, -16.4, 728, -16.4, 0.1, 0.0}},
151 {2600, {0.1, 0.0, 729, -16.8, 729, -16.8, 0.1, 0.0}},
152 {2700, {0.2, 0.1, 726, -17.4, 726, -17.4, 0.2, 0.1}},
153 {2800, {0.2, 0.2, 722, -18.0, 722, -18.0, 0.2, 0.2}},
154 {2900, {0.2, 0.3, 719, -18.6, 719, -18.6, 0.2, 0.3}},
155 {3000, {0.2, 0.4, 715, -19.3, 715, -19.3, 0.2, 0.4}},
156 {3100, {0.2, 0.4, 712, -19.9, 712, -19.9, 0.2, 0.4}},
157 {3200, {0.2, 0.5, 708, -20.5, 708, -20.5, 0.2, 0.5}},
158 {3300, {0.2, 0.5, 704, -21.1, 704, -21.1, 0.2, 0.5}},
159 {3400, {0.2, 0.5, 700, -21.7, 700, -21.7, 0.2, 0.5}},
160 {3500, {0.2, 0.5, 696, -22.3, 696, -22.3, 0.2, 0.5}},
161 {3600, {0.2, 0.4, 692, -22.9, 692, -22.9, 0.2, 0.4}},
162 {3700, {0.2, 0.3, 688, -23.5, 688, -23.5, 0.2, 0.3}},
163 {3800, {0.2, 0.2, 684, -24.1, 684, -24.1, 0.2, 0.2}},
164 {3900, {0.2, 0.1, 680, -24.7, 680, -24.7, 0.2, 0.1}},
165 {4000, {0.2, -0.1, 676, -25.2, 676, -25.2, 0.2, -0.1}}
166 };
167
168 /* V.56bis EIA LL-2, non-loaded loop */
169
170 struct
171 {
172 int freq;
173 float ad[8];
174 } eia_ll2[] =
175 {
176 { 200, {-0.2, 6.6, 1086, -4.9, 1085, -5.6, -0.2, 6.6}},
177 { 300, {-0.2, 7.7, 1079, -7.3, 1077, -8.3, -0.2, 7.7}},
178 { 400, {-0.2, 6.7, 1062, -9.9, 1058, -11.2, -0.2, 6.7}},
179 { 500, {-0.2, 7.1, 1059, -12.0, 1053, -13.6, -0.2, 7.1}},
180 { 600, {-0.1, 5.2, 1041, -14.4, 1034, -16.3, -0.1, 5.2}},
181 { 700, {-0.1, 5.8, 1030, -16.5, 1020, -18.6, -0.1, 5.8}},
182 { 800, {-0.1, 5.4, 1010, -18.7, 998, -21.0, -0.1, 5.4}},
183 { 900, { 0.0, 4.5, 997, -20.5, 982, -23.1, 0.0, 4.5}},
184 {1000, { 3.2, 5.1, 976, -22.5, 959, -25.3, 3.2, 5.1}},
185 {1100, { 0.1, 5.0, 954, -24.5, 934, -27.4, 0.1, 5.0}},
186 {1200, { 0.1, 4.0, 931, -26.2, 909, -29.4, 0.1, 4.0}},
187 {1300, { 0.2, 2.7, 918, -27.6, 894, -30.9, 0.2, 2.7}},
188 {1400, { 0.2, 2.8, 897, -29.2, 871, -32.6, 0.2, 2.8}},
189 {1500, { 0.3, 2.6, 874, -30.7, 847, -34.3, 0.3, 2.6}},
190 {1600, { 0.3, 2.0, 852, -32.1, 823, -35.8, 0.3, 2.0}},
191 {1700, { 0.4, 0.9, 831, -33.4, 800, -37.2, 0.4, 0.9}},
192 {1800, { 0.5, 40.8, 816, -34.4, 783, -38.4, 0.5, 40.8}},
193 {1900, { 0.6, 0.0, 796, -35.6, 762, -39.6, 0.6, 0.0}},
194 {2000, { 0.6, -0.2, 776, -36.6, 741, -40.7, 0.6, -0.2}},
195 {2100, { 0.7, -0.6, 756, -37.6, 720, -41.8, 0.7, -0.6}},
196 {2200, { 0.8, -1.1, 737, -38.6, 700, -42.9, 0.8, -1.1}},
197 {2300, { 0.9, -1.8, 719, -39.4, 681, -43.8, 0.9, -1.8}},
198 {2400, { 1.0, -2.6, 701, -40.2, 663, -44.7, 1.0, -2.6}},
199 {2500, { 1.0, -3.7, 684, -41.0, 646, -45.5, 1.0, -3.7}},
200 {2600, { 1.1, -4.1, 678, -41.3, 639, -45.9, 1.1, -4.1}},
201 {2700, { 1.2, -4.3, 663, -42.0, 623, -46.6, 1.2, -4.3}},
202 {2800, { 1.3, -4.5, 647, -42.6, 607, -47.3, 1.3, -4.5}},
203 {2900, { 1.4, -4.8, 632, -43.1, 591, -47.9, 1.4, -4.8}},
204 {3000, { 1.5, -5.2, 617, -43.6, 576, -48.4, 1.5, -5.2}},
205 {3100, { 1.6, -5.6, 603, -44.1, 562, -49.0, 1.6, -5.6}},
206 {3200, { 1.7, -6.0, 589, -44.5, 548, -49.5, 1.7, -6.0}},
207 {3300, { 1.8, -6.5, 576, -44.9, 535, -49.9, 1.8, -6.5}},
208 {3400, { 1.9, -7.1, 563, -45.3, 522, -50.3, 1.9, -7.1}},
209 {3500, { 2.0, -7.7, 551, -45.6, 509, -50.7, 2.0, -7.7}},
210 {3600, { 2.1, -8.4, 539, -45.9, 498, -51.0, 2.1, -8.4}},
211 {3700, { 2.2, -9.1, 528, -46.2, 486, -51.3, 2.2, -9.1}},
212 {3800, { 2.3, -9.9, 518, -46.4, 476, -51.6, 2.3, -9.9}},
213 {3900, { 2.4, -10.6, 507, -46.6, 466, -51.9, 2.4, -10.6}},
214 {4000, { 2.5, -11.5, 498, -46.8, 456, -52.1, 2.5, -11.5}}
215 };
216
217 /* V.56bis EIA LL-3, non-loaded loop */
218
219 struct
220 {
221 int freq;
222 float ad[8];
223 } eia_ll3[] =
224 {
225 { 200, {-0.3, 10.5, 1176, -5.9, 1173, -7.4, -0.3, 10.5}},
226 { 300, {-0.3, 11.5, 1165, -8.8, 1159, -11.0, -0.3, 11.5}},
227 { 400, {-0.3, 10.6, 1140, -11.8, 1130, -14.7, -0.3, 10.6}},
228 { 500, {-0.3, 11.0, 1133, -14.3, 1117, -17.8, -0.3, 11.0}},
229 { 600, {-0.2, 8.5, 1108, -17.1, 1086, -21.2, -0.2, 8.5}},
230 { 700, {-0.2, 8.5, 1090, -19.4, 1062, -24.0, -0.2, 8.5}},
231 { 800, {-0.1, 8.4, 1062, -21.9, 1029, -27.0, -0.1, 8.4}},
232 { 900, { 0.0, 7.1, 1042, -23.9, 1003, -29.4, 0.0, 7.1}},
233 {1000, { 3.8, 7.7, 1013, -23.0, 969, -31.9, 3.8, 7.7}},
234 {1100, { 0.1, 7.4, 982, -28.1, 934, -34.3, 0.1, 7.4}},
235 {1200, { 0.1, 6.0, 953, -29.9, 900, -36.5, 0.1, 6.0}},
236 {1300, { 0.2, 4.2, 935, -31.3, 878, -38.1, 0.2, 4.2}},
237 {1400, { 0.3, 4.2, 907, -32.8, 847, -40.0, 0.3, 4.2}},
238 {1500, { 0.4, 3.7, 880, -34.3, 817, -41.7, 0.4, 3.7}},
239 {1600, { 0.5, 2.7, 853, -35.6, 787, -43.2, 0.5, 2.7}},
240 {1700, { 0.6, 1.2, 827, -36.8, 760, -44.6, 0.6, 1.2}},
241 {1800, { 0.7, 48.7, 809, -37.8, 739, -45.8, 0.7, 48.7}},
242 {1900, { 0.8, -0.2, 785, -38.8, 715, -47.0, 0.8, -0.2}},
243 {2000, { 0.9, -0.7, 763, -39.7, 691, -48.0, 0.9, -0.7}},
244 {2100, { 1.0, -1.3, 741, -40.5, 668, -49.1, 1.0, -1.3}},
245 {2200, { 1.1, -2.1, 719, -41.3, 647, -50.0, 1.1, -2.1}},
246 {2300, { 1.2, -2.1, 699, -42.0, 625, -50.8, 1.2, -2.1}},
247 {2400, { 1.2, -4.3, 680, -42.6, 606, -51.6, 1.2, -4.3}},
248 {2500, { 1.3, -5.6, 663, -43.2, 588, -52.3, 1.3, -5.6}},
249 {2600, { 1.6, -6.2, 656, -43.4, 581, -52.7, 1.6, -6.2}},
250 {2700, { 1.7, -6.6, 640, -43.9, 564, -53.3, 1.7, -6.6}},
251 {2800, { 1.8, -7.0, 624, -44.3, 548, -53.9, 1.8, -7.0}},
252 {2900, { 1.9, -7.5, 609, -44.7, 533, -54.4, 1.9, -7.5}},
253 {3000, { 2.0, -8.0, 594, -45.0, 518, -54.8, 2.0, -8.0}},
254 {3100, { 2.2, -8.6, 580, -45.3, 504, -55.3, 2.2, -8.6}},
255 {3200, { 2.3, -9.2, 566, -45.6, 490, -55.7, 2.3, -9.2}},
256 {3300, { 2.4, -9.9, 553, -45.8, 477, -56.0, 2.4, -9.9}},
257 {3400, { 2.6, -10.7, 540, -46.0, 465, -56.3, 2.6, -10.7}},
258 {3500, { 2.7, -11.4, 529, -46.2, 454, -56.6, 2.7, -11.4}},
259 {3600, { 2.8, -12.3, 517, -46.3, 443, -56.9, 2.8, -12.3}},
260 {3700, { 3.0, -13.1, 507, -46.4, 432, -57.1, 3.0, -13.1}},
261 {3800, { 3.1, -14.0, 497, -46.5, 422, -57.3, 3.1, -14.0}},
262 {3900, { 3.2, -14.9, 487, -46.6, 413, -57.5, 3.2, -14.9}},
263 {4000, { 3.3, -15.9, 478, -46.6, 404, -57.7, 3.3, -15.9}}
264 };
265
266
267 /* V.56bis EIA LL-4, non-loaded loop */
268
269 struct
270 {
271 int freq;
272 float ad[8];
273 } eia_ll4[] =
274 {
275 { 200, {-0.8, 31.0, 1564, -10.7, 1564, -10.7, -0.8, 31.0}},
276 { 300, {-0.8, 32.6, 1520, -15.6, 1520, -15.6, -0.8, 32.6}},
277 { 400, {-0.8, 29.8, 1447, -20.5, 1447, -20.5, -0.8, 29.8}},
278 { 500, {-0.6, 29.7, 1402, -24.3, 1402, -24.3, -0.6, 29.7}},
279 { 600, {-0.5, 24.9, 1328, -28.1, 1328, -28.1, -0.5, 24.9}},
280 { 700, {-0.4, 24.8, 1270, -31.2, 1270, -31.2, -0.4, 24.8}},
281 { 800, {-0.3, 22.7, 1200, -34.0, 1200, -34.0, -0.3, 22.7}},
282 { 900, {-0.1, 19.8, 1148, -36.2, 1148, -36.2, -0.1, 19.8}},
283 {1000, { 6.1, 19.3, 1086, -38.3, 1086, -38.3, 6.1, 19.3}},
284 {1100, { 0.1, 17.5, 1027, -40.1, 1027, -40.1, 0.1, 17.5}},
285 {1200, { 0.3, 14.3, 974, -41.6, 974, -41.6, 0.3, 14.3}},
286 {1300, { 0.5, 10.9, 941, -42.6, 941, -42.6, 0.5, 10.9}},
287 {1400, { 0.7, 9.6, 897, -43.7, 897, -43.7, 0.7, 9.6}},
288 {1500, { 0.9, 7.7, 856, -44.6, 856, -44.6, 0.9, 7.7}},
289 {1600, { 1.1, 5.3, 818, -45.3, 818, -45.3, 1.1, 5.3}},
290 {1700, { 1.3, 2.4, 784, -45.9, 784, -45.9, 1.3, 2.4}},
291 {1800, { 1.4, 69.1, 761, -46.3, 761, -46.3, 1.4, 69.1}},
292 {1900, { 1.7, -1.3, 732, -46.6, 732, -46.6, 1.7, -1.3}},
293 {2000, { 1.9, -2.7, 706, -46.9, 706, -46.9, 1.9, -2.7}},
294 {2100, { 2.1, -4.3, 682, -47.1, 682, -47.1, 2.1, -4.3}},
295 {2200, { 2.3, -6.0, 659, -47.3, 659, -47.3, 2.3, -6.0}},
296 {2300, { 2.5, -7.9, 638, -47.4, 638, -47.4, 2.5, -7.9}},
297 {2400, { 2.7, -9.9, 619, -47.4, 619, -47.4, 2.7, -9.9}},
298 {2500, { 2.9, -12.0, 602, -47.5, 602, -47.5, 2.9, -12.0}},
299 {2600, { 3.1, -13.0, 596, -47.4, 596, -47.4, 3.1, -13.0}},
300 {2700, { 3.3, -13.9, 580, -47.4, 580, -47.4, 3.3, -13.9}},
301 {2800, { 3.5, -14.8, 566, -47.3, 566, -47.3, 3.5, -14.8}},
302 {2900, { 3.7, -15.7, 552, -47.2, 552, -47.2, 3.7, -15.7}},
303 {3000, { 3.9, -16.7, 539, -47.1, 539, -47.1, 3.9, -16.7}},
304 {3100, { 4.1, -17.7, 526, -47.0, 526, -47.0, 4.1, -17.7}},
305 {3200, { 4.3, -18.7, 515, -46.8, 515, -46.8, 4.3, -18.7}},
306 {3300, { 4.5, -19.8, 504, -46.7, 504, -46.7, 4.5, -19.8}},
307 {3400, { 4.7, -20.8, 493, -46.5, 493, -46.5, 4.7, -20.8}},
308 {3500, { 4.9, -21.8, 484, -46.4, 484, -46.4, 4.9, -21.8}},
309 {3600, { 5.1, -22.9, 475, -46.2, 475, -46.2, 5.1, -22.9}},
310 {3700, { 5.3, -23.9, 466, -46.0, 466, -46.0, 5.3, -23.9}},
311 {3800, { 5.5, -25.0, 458, -45.9, 458, -45.9, 5.5, -25.0}},
312 {3900, { 5.6, -26.1, 451, -45.7, 451, -45.7, 5.6, -26.1}},
313 {4000, { 5.8, -27.2, 444, -45.5, 444, -45.5, 5.8, -27.2}}
314 };
315
316
317 /* V.56bis EIA LL-5, non-loaded loop */
318
319 struct
320 {
321 int freq;
322 float ad[8];
323 } eia_ll5[] =
324 {
325 { 200, {-1.4, 55.8, 1607, -12.7, 1574, -17.4, -1.4, 55.8}},
326 { 300, {-1.3, 57.2, 1541, -18.3, 1478, -24.8, -1.3, 57.2}},
327 { 400, {-1.2, 52.2, 1443, -23.6, 1350, -31.5, -1.2, 52.2}},
328 { 500, {-1.0, 51.0, 1379, -27.5, 1261, -36.4, -1.0, 51.0}},
329 { 600, {-0.9, 43.2, 1287, -31.2, 1150, -40.7, -0.9, 43.2}},
330 { 700, {-0.7, 41.8, 1216, -34.0, 1066, -44.0, -0.7, 41.8}},
331 { 800, {-0.5, 37.4, 1137, -36.5, 979, -46.9, -0.5, 37.4}},
332 { 900, {-0.2, 32.4, 1080, -38.3, 915, -48.9, -0.2, 32.4}},
333 {1000, { 7.0, 30.5, 1015, -39.8, 848, -50.7, 7.0, 30.5}},
334 {1100, { 0.3, 26.8, 956, -41.1, 788, -52.2, 0.3, 26.8}},
335 {1200, { 0.5, 21.5, 904, -42.1, 736, -53.3, 0.5, 21.5}},
336 {1300, { 0.8, 16.6, 873, -42.7, 703, -54.1, 0.8, 16.6}},
337 {1400, { 1.0, 14.1, 832, -43.2, 663, -54.8, 1.0, 14.1}},
338 {1500, { 1.3, 10.9, 795, -43.7, 627, -55.3, 1.3, 10.9}},
339 {1600, { 1.6, 7.3, 762, -44.0, 595, -55.7, 1.6, 7.3}},
340 {1700, { 1.9, 3.2, 733, -44.2, 567, -56.0, 1.9, 3.2}},
341 {1800, { 2.2, 81.5, 713, -44.3, 547, -56.2, 2.2, 81.5}},
342 {1900, { 2.4, -1.9, 689, -44.4, 524, -56.4, 2.4, -1.9}},
343 {2000, { 2.7, -3.9, 667, -44.4, 503, -56.5, 2.7, -3.9}},
344 {2100, { 3.0, -6.1, 646, -44.4, 485, -56.5, 3.0, -6.1}},
345 {2200, { 3.3, -8.3, 628, -44.4, 466, -56.5, 3.3, -8.3}},
346 {2300, { 3.6, -10.7, 610, -44.3, 450, -56.5, 3.6, -10.7}},
347 {2400, { 3.8, -13.1, 595, -44.2, 436, -56.4, 3.8, -13.1}},
348 {2500, { 4.1, -15.5, 581, -44.1, 422, -56.3, 4.1, -15.5}},
349 {2600, { 4.3, -16.7, 577, -44.0, 417, -56.2, 4.3, -16.7}},
350 {2700, { 4.6, -17.7, 565, -43.9, 406, -56.1, 4.6, -17.7}},
351 {2800, { 4.8, -18.8, 553, -43.8, 395, -56.0, 4.8, -18.8}},
352 {2900, { 5.1, -19.9, 542, -43.7, 395, -55.9, 5.1, -19.9}},
353 {3000, { 5.4, -21.0, 531, -43.6, 375, -55.7, 5.4, -21.0}},
354 {3100, { 5.6, -22.1, 521, -43.5, 366, -55.6, 5.6, -22.1}},
355 {3200, { 5.9, -23.2, 511, -43.4, 357, -55.4, 5.9, -23.2}},
356 {3300, { 6.1, -24.3, 502, -43.3, 349, -55.3, 6.1, -24.3}},
357 {3400, { 6.4, -25.4, 494, -43.2, 341, -55.1, 6.4, -25.4}},
358 {3500, { 6.6, -26.5, 486, -43.1, 334, -55.0, 6.6, -26.5}},
359 {3600, { 6.9, -27.6, 478, -43.0, 327, -54.8, 6.9, -27.6}},
360 {3700, { 7.1, -28.7, 471, -42.9, 321, -54.7, 7.1, -28.7}},
361 {3800, { 7.3, -29.9, 464, -42.8, 315, -54.6, 7.3, -29.9}},
362 {3900, { 7.5, -31.0, 458, -42.7, 310, -54.4, 7.5, -31.0}},
363 {4000, { 7.8, -32.1, 452, -42.7, 304, -54.3, 7.8, -32.1}}
364 };
365
366
367 /* V.56bis EIA LL-6, non-loaded loop */
368
369 struct
370 {
371 int freq;
372 float ad[8];
373 } eia_ll6[] =
374 {
375 { 200, {-0.2, -39.3, 1756, -12.0, 1748, -19.8, -0.2, -39.3}},
376 { 300, {-0.2, -31.7, 1642, -15.9, 1689, -26.9, -0.2, -31.7}},
377 { 400, {-0.2, -37.5, 1506, -18.4, 1427, -33.4, -0.2, -37.5}},
378 { 500, {-0.1, -34.7, 1442, -19.5, 1301, -37.7, -0.1, -34.7}},
379 { 600, {-0.1, -46.0, 1363, -20.1, 1153, -40.7, -0.1, -46.0}},
380 { 700, { 0.0, -40.8, 1320, -20.7, 1045, -42.2, 0.0, -40.8}},
381 { 800, { 0.0, -40.1, 1269, -21.5, 943, -42.3, 0.0, -40.1}},
382 { 900, { 0.0, -40.6, 1227, -22.5, 878, -41.3, 0.0, -40.6}},
383 {1000, { 6.6, -28.0, 1161, -23.4, 825, -39.3, 6.6, -28.0}},
384 {1100, { 0.0, -16.5, 1082, -23.5, 797, -36.8, 0.0, -16.5}},
385 {1200, {-0.1, 0.3, 1000, -22.2, 798, -34.4, -0.1, 0.3}},
386 {1300, { 0.0, -2.3, 943, -19.3, 826, -33.2, 0.0, -2.3}},
387 {1400, { 0.0, 13.5, 896, -14.0, 870, -33.8, 0.0, 13.5}},
388 {1500, { 0.1, 22.6, 890, -7.2, 916, -36.8, 0.1, 22.6}},
389 {1600, { 0.3, 30.3, 940, -0.3, 938, -42.0, 0.3, 30.3}},
390 {1700, { 0.5, 12.5, 1052, 4.6, 929, -48.0, 0.5, 12.5}},
391 {1800, { 0.8, 458.6, 1212, 6.9, 880, -52.8, 0.8, 458.6}},
392 {1900, { 1.1, -5.1, 1410, 3.5, 814, -56.5, 1.1, -5.1}},
393 {2000, { 1.4, -5.0, 1579, -3.6, 747, -58.5, 1.4, -5.0}},
394 {2100, { 1.5, 6.1, 1618, -13.2, 688, -58.8, 1.5, 6.1}},
395 {2200, { 1.5, 33.5, 1491, -21.5, 646, -57.7, 1.5, 33.5}},
396 {2300, { 1.4, 80.5, 1275, -24.9, 625, -55.6, 1.4, 80.5}},
397 {2400, { 1.3, 142.3, 1078, -20.8, 633, -53.8, 1.3, 142.3}},
398 {2500, { 1.4, 196.5, 985, -9.3, 664, -54.5, 1.4, 196.5}},
399 {2600, { 1.6, 214.5, 1045, 2.4, 692, -57.6, 1.6, 214.5}},
400 {2700, { 2.4, 196.8, 1326, 13.7, 684, -63.5, 2.4, 196.8}},
401 {2800, { 3.4, 150.4, 1887, 14.7, 637, -68.3, 3.4, 150.4}},
402 {2900, { 4.3, 125.3, 2608, 1.3, 501, -70.7, 4.3, 125.3}},
403 {3000, { 4.9, 174.6, 2730, -21.8, 533, -70.6, 4.9, 174.6}},
404 {3100, { 4.9, 380.0, 2094, -33.7, 506, -68.5, 4.9, 380.0}},
405 {3200, { 5.2, 759.3, 1642, -21.3, 522, -67.0, 5.2, 759.3}},
406 {3300, { 8.0, 680.1, 2348, 0.5, 531, -72.9, 8.0, 680.1}},
407 {3400, {13.1, 237.8, 4510, -20.9, 482, -77.3, 13.1, 237.8}},
408 {3500, {18.2, -18.8, 4116, -59.6, 439, -78.0, 18.2, -18.8}},
409 {3600, {22.7, -145.4, 3041, -74.4, 487, -77.7, 22.7, -145.4}},
410 {3700, {26.8, -214.5, 2427, -80.1, 383, -77.1, 26.8, -214.5}},
411 {3800, {30.4, -257.0, 2054, -82.7, 364, -76.4, 30.4, -257.0}},
412 {3900, {33.7, -285.6, 1803, -84.2, 348, -75.0, 33.7, -285.6}},
413 {4000, {36.8, -306.2, 1621, -85.1, 334, -75.7, 36.8, -306.2}}
414 };
415
416
417 /* V.56bis EIA LL-7, non-loaded loop */
418
419 struct
420 {
421 int freq;
422 float ad[8];
423 } eia_ll7[] =
424 {
425 { 200, { 0.4, -81.3, 1848, -10.5, 1737, -15.6, 0.4, -81.3}},
426 { 300, { 0.3, -68.9, 1785, -16.2, 1585, -21.6, 0.3, -68.9}},
427 { 400, { 0.2, -68.1, 1646, -22.0, 1388, -25.8, 0.2, -68.1}},
428 { 500, { 0.1, -57.0, 1528, -26.2, 1247, -27.7, 0.1, -57.0}},
429 { 600, { 0.0, -59.8, 1349, -28.9, 1087, -27.3, 0.0, -59.8}},
430 { 700, { 0.0, -45.0, 1205, -29.1, 975, -24.8, 0.0, -45.0}},
431 { 800, {-0.1, -36.9, 1064, -26.8, 885, -19.7, -0.1, -36.9}},
432 { 900, {-0.1, -37.1, 989, -22.6, 846, -13.5, -0.1, -37.1}},
433 {1000, { 5.9, -29.2, 944, -16.6, 847, -6.1, 5.9, -29.2}},
434 {1100, { 0.1, -30.8, 951, -10.5, 900, 0.3, 0.1, -30.8}},
435 {1200, { 0.2, -40.7, 1008, -5.9, 999, 4.9, 0.2, -40.7}},
436 {1300, { 0.4, -53.3, 1897, -4.0, 1122, 4.6, 0.4, -53.3}},
437 {1400, { 0.5, -52.7, 1197, -4.8, 1253, 1.9, 0.5, -52.7}},
438 {1500, { 0.6, -48.3, 1269, -8.4, 1339, -3.8, 0.6, -48.3}},
439 {1600, { 0.6, -38.0, 1274, -13.2, 1337, -10.4, 0.6, -38.0}},
440 {1700, { 0.5, -21.6, 1208, -16.9, 1250, -15.2, 0.5, -21.6}},
441 {1800, { 0.4, 539.7, 1119, -17.8, 1143, -16.6, 0.4, 539.7}},
442 {1900, { 0.3, 35.4, 1027, -14.7, 1036, -13.7, 0.3, 35.4}},
443 {2000, { 0.3, 64.1, 989, -7.9, 998, -6.9, 0.3, 64.1}},
444 {2100, { 0.4, 76.1, 1045, 0.1, 1040, 1.0, 0.4, 76.1}},
445 {2200, { 0.6, 69.8, 1210, 5.3, 1197, 6.9, 0.6, 69.8}},
446 {2300, { 1.0, 55.9, 1460, 4.6, 1430, 5.4, 1.0, 55.9}},
447 {2400, { 1.2, 51.3, 1692, -2.8, 1640, -1.7, 1.2, 51.3}},
448 {2500, { 1.3, 72.6, 1730, -13.4, 1666, -11.5, 1.3, 72.6}},
449 {2600, { 1.3, 117.1, 1613, -49.6, 1556, -16.9, 1.3, 117.1}},
450 {2700, { 1.1, 222.5, 1371, -19.5, 1334, -16.1, 1.1, 222.5}},
451 {2800, { 1.1, 332.3, 1258, -8.9, 1243, -5.1, 1.1, 332.3}},
452 {2900, { 1.7, 356.1, 1474, 4.8, 1480, 8.4, 1.7, 356.1}},
453 {3000, { 2.8, 299.9, 2128, 6.6, 2143, 9.8, 2.8, 299.9}},
454 {3100, { 3.9, 309.4, 2813, -10.5, 2882, -7.1, 3.9, 309.4}},
455 {3200, { 4.4, 576.4, 2490, -27.7, 2487, -22.2, 4.4, 576.4}},
456 {3300, { 5.6, 1030.6, 2237, -17.4, 2385, -9.0, 5.6, 1030.6}},
457 {3400, {10.7, 570.2, 3882, -19.2, 4855, -14.9, 10.7, 570.2}},
458 {3500, {17.3, 83.5, 4116, -57.4, 4649, -63.5, 17.3, 83.5}},
459 {3600, {23.2, -130.6, 3057, -74.0, 3175, -78.6, 23.2, -130.6}},
460 {3700, {28.3, -153.9, 2432, -80.0, 2471, -83.1, 28.3, -153.9}},
461 {3800, {32.8, -292.4, 2055, -82.8, 2072, -85.1, 32.8, -292.4}},
462 {3900, {36.9, -249.9, 1803, -84.2, 1811, -86.1, 36.9, -249.9}},
463 {4000, {40.7, -356.2, 1621, -85.1, 1625, -86.7, 40.7, -356.2}}
464 };
465
466
467 /* V.56bis ETSI LL-1, non-loaded loop */
468
469 struct
470 {
471 int freq;
472 float ad[8];
473 } etsi_ll1[] =
474 {
475 { 200, {-0.78, 14.0, 1248.5, -9.7, 1248.5, -9.7, -0.78, 14.0}},
476 { 300, {-0.74, 10.0, 1220.9, -14.3, 1220.9, -14.3, -0.74, 10.0}},
477 { 400, {-0.68, 8.0, 1185.2, -18.6, 1185.2, -18.6, -0.68, 8.0}},
478 { 500, {-0.60, 7.0, 1143.9, -22.6, 1143.9, -22.6, -0.60, 7.0}},
479 { 600, {-0.51, 6.0, 1099.0, -26.2, 1099.0, -26.2, -0.51, 6.0}},
480 { 700, {-0.40, 5.6, 1052.5, -29.5, 1052.5, -29.5, -0.40, 5.6}},
481 { 800, {-0.28, 5.3, 1005.9, -32.4, 1005.9, -32.4, -0.28, 5.3}},
482 { 900, {-0.14, 5.0, 960.3, -35.0, 960.3, -35.0, -0.14, 5.0}},
483 {1000, { 4.7, 4.6, 916.4, -37.3, 916.4, -37.3, 4.7, 4.6}},
484 {1100, { 0.16, 4.3, 874.6, -39.3, 874.6, -39.3, 0.16, 4.3}},
485 {1200, { 0.33, 3.6, 835.3, -41.1, 835.3, -41.1, 0.33, 3.6}},
486 {1300, { 0.49, 2.6, 798.5, -42.6, 798.5, -42.6, 0.49, 2.6}},
487 {1400, { 0.67, 2.0, 764.2, -43.9, 764.2, -43.9, 0.67, 2.0}},
488 {1500, { 0.85, 1.0, 732.3, -45.1, 732.3, -45.1, 0.85, 1.0}},
489 {1600, { 1.04, 0.6, 702.7, -46.1, 702.7, -46.1, 1.04, 0.6}},
490 {1700, { 1.23, 0.3, 675.3, -47.0, 675.3, -47.0, 1.23, 0.3}},
491 {1800, { 1.43, 40.0, 649.8, -47.7, 649.8, -47.7, 1.43, 40.0}},
492 {1900, { 1.63, -1.0, 626.2, -48.4, 626.2, -48.4, 1.63, -1.0}},
493 {2000, { 1.83, -2.0, 604.3, -48.9, 604.3, -48.9, 1.83, -2.0}},
494 {2100, { 2.03, -3.3, 584.0, -49.4, 584.0, -49.4, 2.03, -3.3}},
495 {2200, { 2.23, -3.6, 565.1, -49.8, 565.1, -49.8, 2.23, -3.6}},
496 {2300, { 2.44, -4.3, 547.5, -50.1, 547.5, -50.1, 2.44, -4.3}},
497 {2400, { 2.64, -5.0, 531.1, -50.4, 531.1, -50.4, 2.64, -5.0}},
498 {2500, { 2.84, -6.1, 515.9, -50.6, 515.9, -50.6, 2.84, -6.1}},
499 {2600, { 3.05, -6.6, 501.6, -50.8, 501.6, -50.8, 3.05, -6.6}},
500 {2700, { 3.25, -7.3, 488.2, -51.0, 488.2, -51.0, 3.25, -7.3}},
501 {2800, { 3.45, -7.6, 475.7, -51.1, 475.7, -51.1, 3.45, -7.6}},
502 {2900, { 3.65, -8.3, 464.0, -51.1, 464.0, -51.1, 3.65, -8.3}},
503 {3000, { 3.85, -8.6, 453.0, -51.2, 453.0, -51.2, 3.85, -8.6}},
504 {3100, { 4.04, -9.3, 442.6, -51.2, 442.6, -51.2, 4.04, -9.3}},
505 {3200, { 4.24, -10.3, 432.9, -51.2, 432.9, -51.2, 4.24, -10.3}},
506 {3300, { 4.43, -10.6, 423.7, -51.2, 423.7, -51.2, 4.43, -10.6}},
507 {3400, { 4.62, -11.3, 415.1, -51.2, 415.1, -51.2, 4.62, -11.3}},
508 {3500, { 4.81, -11.6, 406.9, -51.1, 406.9, -51.1, 4.81, -11.6}},
509 {3600, { 5.00, -12.3, 399.1, -51.1, 399.1, -51.1, 5.00, -12.3}},
510 {3700, { 5.19, -13.0, 391.8, -51.0, 391.8, -51.0, 5.19, -13.0}},
511 {3800, { 5.37, -13.4, 384.9, -51.0, 384.9, -51.0, 5.37, -13.4}},
512 {3900, { 5.56, -13.8, 378.3, -50.9, 378.3, -50.9, 5.56, -13.8}},
513 {4000, { 5.74, -14.4, 372.0, -50.8, 372.0, -50.8, 5.74, -14.4}}
514 };
515
516
517 /* V.56bis ETSI LL-2, non-loaded loop */
518
519 struct
520 {
521 int freq;
522 float ad[8];
523 } etsi_ll2[] =
524 {
525 { 200, {-0.10, 15.0, 850.3, -3.4, 850.3, -3.4, -0.10, 15.0}},
526 { 300, {-0.09, 8.0, 848.1, -5.1, 848.1, -5.1, -0.09, 8.0}},
527 { 400, {-0.09, 7.0, 845.1, -6.7, 845.1, -6.7, -0.09, 7.0}},
528 { 500, {-0.08, 5.0, 841.3, -8.4, 841.3, -8.4, -0.08, 5.0}},
529 { 600, {-0.07, 4.6, 836.7, -10.0, 836.7, -10.0, -0.07, 4.6}},
530 { 700, {-0.06, 4.3, 831.3, -11.6, 831.3, -11.6, -0.06, 4.3}},
531 { 800, {-0.04, 3.8, 825.3, -13.2, 825.3, -13.2, -0.04, 3.8}},
532 { 900, {-0.02, 3.4, 818.6, -14.8, 818.6, -14.8, -0.02, 3.4}},
533 {1000, { 1.80, 3.0, 811.4, -16.3, 811.4, -16.3, 1.8, 3.0}},
534 {1100, { 0.02, 2.6, 803.6, -17.8, 803.6, -17.8, 0.02, 2.6}},
535 {1200, { 0.04, 2.3, 795.3, -19.3, 795.3, -19.3, 0.04, 2.3}},
536 {1300, { 0.06, 1.3, 786.6, -20.7, 786.6, -20.7, 0.06, 1.3}},
537 {1400, { 0.09, 0.9, 777.5, -22.1, 777.5, -22.1, 0.09, 0.9}},
538 {1500, { 0.12, 0.6, 768.1, -23.5, 768.1, -23.5, 0.12, 0.6}},
539 {1600, { 0.15, 0.3, 758.4, -24.8, 758.4, -24.8, 0.15, 0.3}},
540 {1700, { 0.18, 0.0, 748.4, -26.1, 748.4, -26.1, 0.18, 0.0}},
541 {1800, { 0.21, 15, 738.4, -27.3, 738.4, -27.3, 0.21, 15.0}},
542 {1900, { 0.24, -1.0, 728.1, -28.5, 728.1, -28.5, 0.24, -1.0}},
543 {2000, { 0.28, -2.3, 717.8, -29.7, 717.8, -29.7, 0.28, -2.3}},
544 {2100, { 0.32, -2.6, 707.4, -30.8, 707.4, -30.8, 0.32, -2.6}},
545 {2200, { 0.36, -3.0, 697.0, -31.9, 697.0, -31.9, 0.36, -3.0}},
546 {2300, { 0.40, -3.3, 686.6, -33.0, 686.6, -33.0, 0.40, -3.3}},
547 {2400, { 0.44, -3.6, 676.2, -34.0, 676.2, -34.0, 0.44, -3.6}},
548 {2500, { 0.48, -4.5, 665.9, -35.0, 665.9, -35.0, 0.48, -4.5}},
549 {2600, { 0.53, -5.4, 655.6, -35.9, 655.6, -35.9, 0.53, -5.4}},
550 {2700, { 0.57, -6.3, 645.5, -36.8, 645.5, -36.8, 0.57, -6.3}},
551 {2800, { 0.62, -6.6, 635.5, -37.7, 635.5, -37.7, 0.62, -6.6}},
552 {2900, { 0.67, -6.9, 625.6, -38.6, 625.6, -38.6, 0.67, -6.9}},
553 {3000, { 0.72, -7.5, 615.8, -39.4, 615.8, -39.4, 0.72, -7.5}},
554 {3100, { 0.77, -8.3, 606.2, -40.2, 606.2, -40.2, 0.77, -8.3}},
555 {3200, { 0.82, -8.6, 596.7, -40.9, 596.7, -40.9, 0.82, -8.6}},
556 {3300, { 0.87, -9.3, 587.4, -41.6, 587.4, -41.6, 0.87, -9.3}},
557 {3400, { 0.92, -9.6, 578.3, -42.3, 578.3, -42.3, 0.92, -9.6}},
558 {3500, { 0.98, -10.3, 569.3, -43.0, 569.3, -43.0, 0.98, -10.3}},
559 {3600, { 1.03, -10.6, 560.6, -43.7, 560.6, -43.7, 1.03, -10.6}},
560 {3700, { 1.09, -11.3, 552.0, -44.3, 552.0, -44.3, 1.09, -11.3}},
561 {3800, { 1.14, -11.6, 543.5, -44.9, 543.5, -44.9, 1.14, -11.6}},
562 {3900, { 1.20, -12.3, 535.3, -45.4, 535.3, -45.4, 1.20, -12.3}},
563 {4000, { 1.26, -13.3, 527.2, -46.0, 527.2, -46.0, 1.26, -13.3}}
564 };
565
566 /* V.56bis AD-1 AD-5 AD-6 AD-7 AD-8 AD-9 */
567
568 struct
569 {
570 int freq;
571 float ad[6];
572 } ad[] =
573 {
574 { 0, {90.0, 90.0, 90.0, 90.0, 90.0, 90.0}},
575 { 200, { 6.0, 3.2, 3.0, 2.9, 11.6, 23.3}},
576 { 300, { 1.3, 1.4, 1.2, 1.1, 6.9, 13.9}},
577 { 400, { 0.0, 0.4, 0.3, 0.3, 4.0, 7.9}},
578 { 500, { 0.0, -0.1, 0.0, 0.1, 2.0, 4.1}},
579 { 600, { 0.0, -0.1, 0.0, 0.1, 1.2, 2.4}},
580 { 700, { 0.0, 0.1, 0.0, 0.0, 0.8, 1.7}},
581 { 800, { 0.0, 0.0, 0.0, -0.1, 0.5, 1.1}},
582 { 900, { 0.0, 0.0, 0.0, -0.1, 0.2, 0.4}},
583 {1000, { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}},
584 {1100, { 0.0, 0.0, 0.1, 0.0, -0.1, -0.2}},
585 {1200, { 0.0, 0.0, 0.1, 0.1, -0.1, -0.2}},
586 {1300, { 0.0, 0.1, 0.2, 0.3, -0.1, -0.2}},
587 {1400, { 0.0, 0.2, 0.3, 0.4, -0.1, -0.3}},
588 {1500, { 0.0, 0.2, 0.3, 0.4, -0.2, -0.4}},
589 {1600, { 0.0, 0.3, 0.5, 0.5, -0.1, -0.3}},
590 {1700, { 0.0, 0.3, 0.5, 0.6, -0.1, -0.1}},
591 {1800, { 0.0, 0.3, 0.5, 0.6, 0.0, 0.0}},
592 {1900, { 0.0, 0.4, 0.7, 0.7, 0.1, 0.2}},
593 {2000, { 0.0, 0.5, 0.8, 0.9, 0.2, 0.5}},
594 {2100, { 0.1, 0.6, 1.0, 1.0, 0.5, 0.9}},
595 {2200, { 0.2, 0.7, 1.1, 1.1, 0.6, 1.1}},
596 {2300, { 0.3, 0.9, 1.2, 1.4, 0.8, 1.5}},
597 {2400, { 0.4, 1.1, 1.5, 1.6, 0.9, 1.8}},
598 {2500, { 0.5, 1.3, 1.8, 2.0, 1.1, 2.3}},
599 {2600, { 0.6, 1.6, 2.4, 2.7, 1.4, 2.8}},
600 {2700, { 0.7, 2.0, 3.0, 3.5, 1.7, 3.4}},
601 {2800, { 0.7, 2.3, 3.5, 4.3, 2.0, 4.0}},
602 {2900, { 0.9, 2.8, 4.2, 5.0, 2.4, 4.9}},
603 {3000, { 1.1, 3.2, 4.9, 5.8, 3.0, 5.9}},
604 {3100, { 1.2, 3.5, 5.6, 6.7, 3.4, 6.8}},
605 {3200, { 1.3, 4.1, 6.7, 8.0, 3.9, 7.7}},
606 {3300, { 1.6, 4.8, 8.0, 9.6, 4.6, 9.2}},
607 {3400, { 1.8, 5.3, 9.1, 11.0, 5.4, 10.7}},
608 {3500, { 2.4, 5.7, 10.3, 12.2, 6.3, 12.6}},
609 {3600, { 3.0, 6.6, 12.1, 13.9, 7.8, 15.5}},
610 {3700, { 5.7, 8.9, 15.8, 17.3, 10.3, 20.5}},
611 {3800, {13.5, 15.7, 24.4, 25.7, 16.2, 32.4}},
612 {3900, {31.2, 31.1, 42.2, 43.3, 29.9, 59.9}},
613 {4000, {31.2, 31.1, 42.2, 43.3, 29.9, 59.9}}
614 };
615
616 /* V.56bis EDD-1 EDD-2 EDD-3 */
617
618 struct
619 {
620 int freq;
621 float edd[3];
622 } edd[] =
623 {
624 { 0, {3.98, 3.76, 8.00}},
625 { 200, {3.98, 3.76, 8.00}},
626 { 300, {2.70, 3.76, 8.00}},
627 { 400, {1.69, 2.20, 6.90}},
628 { 500, {1.15, 1.36, 5.50}},
629 { 600, {0.80, 0.91, 4.40}},
630 { 700, {0.60, 0.64, 3.40}},
631 { 800, {0.50, 0.46, 2.80}},
632 { 900, {0.40, 0.34, 2.00}},
633 {1000, {0.30, 0.24, 1.50}},
634 {1100, {0.20, 0.16, 1.00}},
635 {1200, {0.20, 0.11, 0.70}},
636 {1300, {0.10, 0.07, 0.40}},
637 {1400, {0.05, 0.05, 0.30}},
638 {1500, {0.00, 0.03, 0.20}},
639 {1600, {0.00, 0.01, 0.10}},
640 {1700, {0.00, 0.00, 0.10}},
641 {1800, {0.00, 0.00, 0.00}},
642 {1900, {0.00, 0.02, 0.10}},
643 {2000, {0.00, 0.04, 0.10}},
644 {2100, {0.02, 0.08, 0.10}},
645 {2200, {0.02, 0.12, 0.20}},
646 {2300, {0.02, 0.16, 0.20}},
647 {2400, {0.02, 0.20, 0.30}},
648 {2500, {0.10, 0.27, 0.40}},
649 {2600, {0.12, 0.36, 0.50}},
650 {2700, {0.15, 0.47, 0.80}},
651 {2800, {0.20, 0.60, 1.10}},
652 {2900, {0.27, 0.77, 1.50}},
653 {3000, {0.40, 1.01, 2.00}},
654 {3100, {0.56, 1.32, 2.60}},
655 {3200, {0.83, 1.78, 3.20}},
656 {3300, {1.07, 1.78, 4.00}},
657 {3400, {1.39, 1.78, 4.00}},
658 {3500, {1.39, 1.78, 4.00}},
659 {3600, {1.39, 1.78, 4.00}},
660 {3700, {1.39, 1.78, 4.00}},
661 {3800, {1.39, 1.78, 4.00}},
662 {3900, {1.39, 1.78, 4.00}},
663 {4000, {1.39, 1.78, 4.00}}
664 };
665
666 /* V.56bis PCM AD-1, AD-2, AD-3 */
667
668 struct
669 {
670 int freq;
671 float ad[3];
672 } pcm_ad[] =
673 {
674 { 50, {41.4, 77.8, 114.2}},
675 { 100, {15.5, 27.7, 39.9}},
676 { 150, { 3.7, 6.1, 8.6}},
677 { 200, { 0.5, 0.8, 1.0}},
678 { 250, {-0.2, -0.2, -0.3}},
679 { 300, {-0.2, -0.3, -0.4}},
680 { 400, { 0.0, -0.2, -0.3}},
681 { 500, {-0.2, -0.4, -0.5}},
682 { 600, {-0.2, -0.3, -0.5}},
683 { 700, {-0.2, -0.3, -0.5}},
684 { 800, {-0.2, -0.4, -0.5}},
685 { 900, {-0.2, -0.3, -0.4}},
686 {1000, {-0.1, -0.2, -0.3}},
687 {1100, {-0.2, -0.3, -0.3}},
688 {1200, {-0.2, -0.3, -0.4}},
689 {1300, {-0.2, -0.3, -0.5}},
690 {1400, {-0.1, -0.3, -0.4}},
691 {1500, {-0.1, -0.3, -0.4}},
692 {1600, {-0.1, -0.2, -0.3}},
693 {1700, {-0.1, -0.3, -0.4}},
694 {1800, {-0.2, -0.3, -0.4}},
695 {1900, {-0.2, -0.3, -0.3}},
696 {2000, {-0.1, -0.2, -0.3}},
697 {2100, {-0.1, -0.2, -0.3}},
698 {2200, {-0.1, -0.3, -0.4}},
699 {2300, {-0.1, -0.1, -0.2}},
700 {2400, {-0.1, -0.1, -0.2}},
701 {2500, { 0.0, -0.1, -0.1}},
702 {2600, { 0.0, -0.1, -0.1}},
703 {2700, { 0.0, 0.0, 0.1}},
704 {2800, { 0.0, 0.0, 0.1}},
705 {2900, { 0.1, 0.2, 0.2}},
706 {3000, { 0.0, 0.0, 0.1}},
707 {3100, { 0.0, 0.0, 0.0}},
708 {3200, { 0.0, 0.0, 0.1}},
709 {3300, { 0.3, 0.7, 1.0}},
710 {3400, { 1.2, 2.4, 3.6}},
711 {3500, { 3.2, 6.3, 9.5}},
712 {3550, { 5.0, 9.6, 14.3}},
713 {3600, { 7.0, 13.5, 19.9}},
714 {3650, {10.0, 18.7, 27.5}},
715 {3700, {13.4, 24.6, 35.8}},
716 {3750, {18.1, 32.1, 46.2}},
717 {3800, {24.3, 41.2, 58.2}},
718 {3850, {32.5, 52.6, 72.7}},
719 {3900, {43.4, 66.6, 89.8}},
720 {4000, {43.4, 66.6, 89.8}}
721 };
722
723 /* V.56bis PCM EDD-1, EDD-2, EDD-3 */
724
725 struct
726 {
727 int freq;
728 float edd[3];
729 } pcm_edd[] =
730 {
731 { 150, { 2.76, 5.5, 8.3}},
732 { 200, { 1.70, 3.4, 5.1}},
733 { 250, { 0.92, 1.8, 2.8}},
734 { 300, { 0.55, 1.1, 1.7}},
735 { 400, { 0.25, 0.5, 0.7}},
736 { 500, { 0.12, 0.2, 0.4}},
737 { 600, { 0.06, 0.1, 0.2}},
738 { 700, { 0.03, 0.1, 0.1}},
739 { 800, { 0.01, 0.0, 0.0}},
740 { 900, { 0.00, 0.0, 0.0}},
741 {1000, {-0.01, 0.0, 0.0}},
742 {1100, {-0.01, 0.0, 0.0}},
743 {1200, {-0.02, 0.0, -0.1}},
744 {1300, {-0.02, 0.0, -0.1}},
745 {1400, {-0.01, 0.0, 0.0}},
746 {1500, {-0.01, 0.0, 0.0}},
747 {1600, { 0.00, 0.0, 0.0}},
748 {1700, { 0.00, 0.0, 0.0}},
749 {1800, { 0.01, 0.0, 0.0}},
750 {1900, { 0.02, 0.0, 0.0}},
751 {2000, { 0.02, 0.0, 0.1}},
752 {2100, { 0.04, 0.1, 0.1}},
753 {2200, { 0.05, 0.1, 0.2}},
754 {2300, { 0.06, 0.1, 0.2}},
755 {2400, { 0.07, 0.1, 0.2}},
756 {2500, { 0.10, 0.2, 0.3}},
757 {2600, { 0.11, 0.2, 0.3}},
758 {2700, { 0.14, 0.3, 0.4}},
759 {2800, { 0.18, 0.4, 0.5}},
760 {2900, { 0.22, 0.4, 0.6}},
761 {3000, { 0.27, 0.5, 0.8}},
762 {3100, { 0.34, 0.7, 1.0}},
763 {3200, { 0.45, 0.9, 1.4}},
764 {3250, { 0.52, 1.0, 1.6}},
765 {3300, { 0.60, 1.2, 1.8}},
766 {3350, { 0.66, 1.3, 2.0}},
767 {3400, { 0.74, 1.5, 2.2}},
768 {3450, { 0.79, 1.6, 2.4}},
769 {3500, { 0.83, 1.7, 2.5}},
770 {3550, { 0.84, 1.7, 2.5}},
771 {3600, { 0.81, 1.6, 2.4}},
772 {3700, { 0.81, 1.6, 2.4}},
773 {3800, { 0.81, 1.6, 2.4}},
774 {3900, { 0.81, 1.6, 2.4}},
775 {4000, { 0.81, 1.6, 2.4}}
776 };
777
778 FILE *outfile;
779
780 float impulse_responses[100][LINE_FILTER_SIZE];
781 int filter_sets = 0;
782
783 static void generate_ad_edd(void)
784 {
785 float f;
786 float offset;
787 float amp;
788 float phase;
789 float delay;
790 float pw;
791 #if defined(HAVE_FFTW3_H)
792 double in[FFT_SIZE][2];
793 double out[FFT_SIZE][2];
794 #else
795 fftw_complex in[FFT_SIZE];
796 fftw_complex out[FFT_SIZE];
797 #endif
798 fftw_plan p;
799 int i;
800 int j;
801 int k;
802 int l;
803
804 #if defined(HAVE_FFTW3_H)
805 p = fftw_plan_dft_1d(FFT_SIZE, in, out, FFTW_BACKWARD, FFTW_ESTIMATE);
806 #else
807 p = fftw_create_plan(FFT_SIZE, FFTW_BACKWARD, FFTW_ESTIMATE);
808 #endif
809 for (j = 0; j < 6; j++)
810 {
811 for (k = 0; k < 3; k++)
812 {
813 for (i = 0; i < FFT_SIZE; i++)
814 {
815 #if defined(HAVE_FFTW3_H)
816 in[i][0] =
817 in[i][1] = 0.0;
818 #else
819 in[i].re =
820 in[i].im = 0.0;
821 #endif
822 }
823 for (i = 1; i < FFT_SIZE/2; i++)
824 {
825 f = (float) i*SAMPLE_RATE/FFT_SIZE;
826 amp = 0.0;
827 for (l = 0; l < (int) (sizeof(ad)/sizeof(ad[0])); l++)
828 {
829 if (f < ad[l].freq)
830 break;
831 }
832 if (l < (int) (sizeof(ad)/sizeof(ad[0])))
833 {
834 offset = (f - ad[l - 1].freq)/(ad[l].freq - ad[l - 1].freq);
835 amp = (1.0 - offset)*ad[l - 1].ad[j] + offset*ad[l].ad[j];
836 amp = pow(10.0, -amp/20.0);
837 }
838 delay = 0.0;
839 for (l = 0; l < (int) (sizeof(edd)/sizeof(edd[0])); l++)
840 {
841 if (f < edd[l].freq)
842 break;
843 }
844 if (l < (int) (sizeof(edd)/sizeof(edd[0])))
845 {
846 offset = (f - edd[l - 1].freq)/(edd[l].freq - edd[l - 1].freq);
847 delay = (1.0 - offset)*edd[l - 1].edd[k] + offset*edd[l].edd[k];
848 }
849 phase = 2.0*M_PI*f*delay*0.001;
850
851 #if defined(HAVE_FFTW3_H)
852 in[i][0] = amp*cos(phase);
853 in[i][1] = amp*sin(phase);
854 in[FFT_SIZE - i][0] = in[i][0];
855 in[FFT_SIZE - i][1] = -in[i][1];
856 #else
857 in[i].re = amp*cos(phase);
858 in[i].im = amp*sin(phase);
859 in[FFT_SIZE - i].re = in[i].re;
860 in[FFT_SIZE - i].im = -in[i].im;
861 #endif
862 }
863 #if 0
864 for (i = 0; i < FFT_SIZE; i++)
865 fprintf(outfile, "%5d %15.5f,%15.5f\n", i, in[i].re, in[i].im);
866 #endif
867 #if defined(HAVE_FFTW3_H)
868 fftw_execute(p);
869 #else
870 fftw_one(p, in, out);
871 #endif
872
873 fprintf(outfile, "/* V.56bis AD-%d, EDD%d */\n", (j == 0) ? 1 : j + 4, k + 1);
874
875 fprintf(outfile, "float ad_%d_edd_%d_model[] =\n", (j == 0) ? 1 : j + 4, k + 1);
876 fprintf(outfile, "{\n");
877 /* Normalise the filter's gain */
878 pw = 0.0;
879 l = FFT_SIZE - (LINE_FILTER_SIZE - 1)/2;
880 for (i = 0; i < LINE_FILTER_SIZE; i++)
881 {
882 #if defined(HAVE_FFTW3_H)
883 pw += out[l][0]*out[l][0];
884 #else
885 pw += out[l].re*out[l].re;
886 #endif
887 if (++l == FFT_SIZE)
888 l = 0;
889 }
890 pw = sqrt(pw);
891 l = FFT_SIZE - (LINE_FILTER_SIZE - 1)/2;
892 for (i = 0; i < LINE_FILTER_SIZE; i++)
893 {
894
895 #if defined(HAVE_FFTW3_H)
896 impulse_responses[filter_sets][i] = out[l][0]/pw;
897 #else
898 impulse_responses[filter_sets][i] = out[l].re/pw;
899 #endif
900 fprintf(outfile, "%15.5f,\n", impulse_responses[filter_sets][i]);
901 if (++l == FFT_SIZE)
902 l = 0;
903 }
904 fprintf(outfile, "};\n\n");
905 filter_sets++;
906 }
907 }
908 }
909
910 static void generate_proakis(void)
911 {
912 float f;
913 float f1;
914 float offset;
915 float amp;
916 float phase;
917 float delay;
918 float pw;
919 int index;
920 int i;
921 int l;
922 #if defined(HAVE_FFTW3_H)
923 double in[FFT_SIZE][2];
924 double out[FFT_SIZE][2];
925 #else
926 fftw_complex in[FFT_SIZE];
927 fftw_complex out[FFT_SIZE];
928 #endif
929 fftw_plan p;
930
931 #if defined(HAVE_FFTW3_H)
932 p = fftw_plan_dft_1d(FFT_SIZE, in, out, FFTW_BACKWARD, FFTW_ESTIMATE);
933 #else
934 p = fftw_create_plan(FFT_SIZE, FFTW_BACKWARD, FFTW_ESTIMATE);
935 #endif
936 for (i = 0; i < FFT_SIZE; i++)
937 {
938 #if defined(HAVE_FFTW3_H)
939 in[i][0] =
940 in[i][1] = 0.0;
941 #else
942 in[i].re =
943 in[i].im = 0.0;
944 #endif
945 }
946 for (i = 1; i < FFT_SIZE/2; i++)
947 {
948 f = (float) i*SAMPLE_RATE/FFT_SIZE;
949 f1 = f/200.0;
950 offset = f1 - floor(f1);
951 index = (int) floor(f1);
952
953 /* Linear interpolation */
954 amp = ((1.0 - offset)*proakis[index].amp + offset*proakis[index + 1].amp)/2.3;
955 delay = (1.0 - offset)*proakis[index].delay + offset*proakis[index + 1].delay;
956 phase = 2.0*M_PI*f*delay*0.001;
957
958 #if defined(HAVE_FFTW3_H)
959 in[i][0] = amp*cos(phase);
960 in[i][1] = amp*sin(phase);
961 in[FFT_SIZE - i][0] = in[i][0];
962 in[FFT_SIZE - i][1] = -in[i][1];
963 #else
964 in[i].re = amp*cos(phase);
965 in[i].im = amp*sin(phase);
966 in[FFT_SIZE - i].re = in[i].re;
967 in[FFT_SIZE - i].im = -in[i].im;
968 #endif
969 }
970
971 #if defined(HAVE_FFTW3_H)
972 fftw_execute(p);
973 #else
974 fftw_one(p, in, out);
975 #endif
976
977 fprintf(outfile, "/* Medium range telephone line response\n");
978 fprintf(outfile, " (from p 537, Digital Communication, John G. Proakis */\n");
979
980 fprintf(outfile, "float proakis_line_model[] =\n");
981 fprintf(outfile, "{\n");
982 /* Normalise the filter's gain */
983 pw = 0.0;
984 l = FFT_SIZE - (LINE_FILTER_SIZE - 1)/2;
985 for (i = 0; i < LINE_FILTER_SIZE; i++)
986 {
987 #if defined(HAVE_FFTW3_H)
988 pw += out[l][0]*out[l][0];
989 #else
990 pw += out[l].re*out[l].re;
991 #endif
992 if (++l == FFT_SIZE)
993 l = 0;
994 }
995 pw = sqrt(pw);
996 l = FFT_SIZE - (LINE_FILTER_SIZE - 1)/2;
997 for (i = 0; i < LINE_FILTER_SIZE; i++)
998 {
999 #if defined(HAVE_FFTW3_H)
1000 impulse_responses[filter_sets][i] = out[l][0]/pw;
1001 #else
1002 impulse_responses[filter_sets][i] = out[l].re/pw;
1003 #endif
1004 fprintf(outfile, "%15.5f,\n", impulse_responses[filter_sets][i]);
1005 if (++l == FFT_SIZE)
1006 l = 0;
1007 }
1008 fprintf(outfile, "};\n\n");
1009 filter_sets++;
1010 }
1011
1012 int main(int argc, char *argv[])
1013 {
1014 int i;
1015 int j;
1016
1017 if ((outfile = fopen("line_models.h", "w")) == NULL)
1018 {
1019 fprintf(stderr, "Failed to open %s\n", "line_model.txt");
1020 exit(2);
1021 }
1022
1023 generate_proakis();
1024 generate_ad_edd();
1025
1026 fclose(outfile);
1027
1028 if (argc > 1)
1029 {
1030 for (i = 0; i < LINE_FILTER_SIZE; i++)
1031 {
1032 printf("%d, ", i);
1033 for (j = 0; j < filter_sets; j++)
1034 {
1035 printf("%15.5f, ", impulse_responses[j][i]);
1036 }
1037 printf("\n");
1038 }
1039 }
1040 return 0;
1041 }

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.