5
|
1 /*
|
|
2 * SpanDSP - a series of DSP components for telephony
|
|
3 *
|
|
4 * line_model.h - Model a telephone line.
|
|
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: line_model.h,v 1.12 2006/10/24 13:45:29 steveu Exp $
|
|
26 */
|
|
27
|
|
28 /*! \file */
|
|
29
|
|
30 /*! \page line_model_page Telephone line model
|
|
31 \section line_model_page_sec_1 What does it do?
|
|
32 The telephone line modelling module provides simple modelling of one way and two
|
|
33 way telephone lines.
|
|
34
|
|
35 The path being modelled is:
|
|
36
|
|
37 - terminal
|
|
38 - | < hybrid echo (2-way models)
|
|
39 - |
|
|
40 - | < noise and filtering
|
|
41 - |
|
|
42 - | < hybrid echo (2-way models)
|
|
43 - CO
|
|
44 - |
|
|
45 - | < A-law distortion + bulk delay
|
|
46 - |
|
|
47 - CO
|
|
48 - | < hybrid echo (2-way models)
|
|
49 - |
|
|
50 - | < noise and filtering
|
|
51 - |
|
|
52 - | < hybrid echo (2-way models)
|
|
53 - terminal
|
|
54 */
|
|
55
|
|
56 #if !defined(_LINE_MODEL_H_)
|
|
57 #define _LINE_MODEL_H_
|
|
58
|
|
59 #define LINE_FILTER_SIZE 129
|
|
60
|
|
61 /*!
|
|
62 One way line model descriptor. This holds the complete state of
|
|
63 a line model with transmission in only one direction.
|
|
64 */
|
|
65 typedef struct
|
|
66 {
|
|
67 codec_munge_state_t *munge;
|
|
68
|
|
69 /*! The coefficients for the near end analogue section simulation filter */
|
|
70 float *near_filter;
|
|
71 /*! The number of coefficients for the near end analogue section simulation filter */
|
|
72 int near_filter_len;
|
|
73 /*! Last transmitted samples (ring buffer, used by the line filter) */
|
|
74 float near_buf[LINE_FILTER_SIZE];
|
|
75 /*! Pointer of the last transmitted sample in buf */
|
|
76 int near_buf_ptr;
|
|
77 /*! The noise source for local analogue section of the line */
|
|
78 awgn_state_t near_noise;
|
|
79
|
|
80 /*! The bulk delay of the path, in samples */
|
|
81 int bulk_delay;
|
|
82 /*! A pointer to the current write position in the bulk delay store. */
|
|
83 int bulk_delay_ptr;
|
|
84 /*! The data store for simulating the bulk delay */
|
|
85 int16_t bulk_delay_buf[8000];
|
|
86
|
|
87 /*! The coefficients for the far end analogue section simulation filter */
|
|
88 float *far_filter;
|
|
89 /*! The number of coefficients for the far end analogue section simulation filter */
|
|
90 int far_filter_len;
|
|
91 /*! Last transmitted samples (ring buffer, used by the line filter) */
|
|
92 float far_buf[LINE_FILTER_SIZE];
|
|
93 /*! Pointer of the last transmitted sample in buf */
|
|
94 int far_buf_ptr;
|
|
95 /*! The noise source for distant analogue section of the line */
|
|
96 awgn_state_t far_noise;
|
|
97
|
|
98 /*! The scaling factor for the local CPE hybrid echo */
|
|
99 float near_cpe_hybrid_echo;
|
|
100 /*! The scaling factor for the local CO hybrid echo */
|
|
101 float near_co_hybrid_echo;
|
|
102
|
|
103 /*! The scaling factor for the far CPE hybrid echo */
|
|
104 float far_cpe_hybrid_echo;
|
|
105 /*! The scaling factor for the far CO hybrid echo */
|
|
106 float far_co_hybrid_echo;
|
|
107 } one_way_line_model_state_t;
|
|
108
|
|
109 /*!
|
|
110 Two way line model descriptor. This holds the complete state of
|
|
111 a line model with transmission in both directions.
|
|
112 */
|
|
113 typedef struct
|
|
114 {
|
|
115 one_way_line_model_state_t line1;
|
|
116 one_way_line_model_state_t line2;
|
|
117 float fout1;
|
|
118 float fout2;
|
|
119 } both_ways_line_model_state_t;
|
|
120
|
|
121 #ifdef __cplusplus
|
|
122 extern "C" {
|
|
123 #endif
|
|
124
|
|
125 void both_ways_line_model(both_ways_line_model_state_t *s,
|
|
126 int16_t *output1,
|
|
127 const int16_t *input1,
|
|
128 int16_t *output2,
|
|
129 const int16_t *input2,
|
|
130 int samples);
|
|
131
|
|
132 both_ways_line_model_state_t *both_ways_line_model_init(int model1,
|
|
133 float noise1,
|
|
134 int model2,
|
|
135 float noise2,
|
|
136 int codec);
|
|
137
|
|
138 int both_ways_line_model_release(both_ways_line_model_state_t *s);
|
|
139
|
|
140 void one_way_line_model(one_way_line_model_state_t *s,
|
|
141 int16_t *output,
|
|
142 const int16_t *input,
|
|
143 int samples);
|
|
144
|
|
145 one_way_line_model_state_t *one_way_line_model_init(int model, float noise, int codec);
|
|
146
|
|
147 int one_way_line_model_release(one_way_line_model_state_t *s);
|
|
148
|
|
149 #ifdef __cplusplus
|
|
150 }
|
|
151 #endif
|
|
152
|
|
153 #endif
|
|
154 /*- End of file ------------------------------------------------------------*/
|