Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/private/v22bis.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 15:50:58 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
---|---|
1 /* | |
2 * SpanDSP - a series of DSP components for telephony | |
3 * | |
4 * private/v22bis.h - ITU V.22bis modem | |
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 Lesser General Public License version 2.1, | |
14 * as 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 Lesser General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU Lesser General Public | |
22 * License along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 * | |
25 * $Id: v22bis.h,v 1.12 2009/11/04 15:52:06 steveu Exp $ | |
26 */ | |
27 | |
28 #if !defined(_SPANDSP_PRIVATE_V22BIS_H_) | |
29 #define _SPANDSP_PRIVATE_V22BIS_H_ | |
30 | |
31 /*! The number of steps to the left and to the right of the target position in the equalizer buffer. */ | |
32 #define V22BIS_EQUALIZER_LEN 7 | |
33 /*! One less than a power of 2 >= (2*V22BIS_EQUALIZER_LEN + 1) */ | |
34 #define V22BIS_EQUALIZER_MASK 15 | |
35 | |
36 /*! The number of taps in the transmit pulse shaping filter */ | |
37 #define V22BIS_TX_FILTER_STEPS 9 | |
38 | |
39 /*! The number of taps in the receive pulse shaping/bandpass filter */ | |
40 #define V22BIS_RX_FILTER_STEPS 37 | |
41 | |
42 /*! Segments of the training sequence on the receive side */ | |
43 enum | |
44 { | |
45 V22BIS_RX_TRAINING_STAGE_NORMAL_OPERATION, | |
46 V22BIS_RX_TRAINING_STAGE_SYMBOL_ACQUISITION, | |
47 V22BIS_RX_TRAINING_STAGE_LOG_PHASE, | |
48 V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES, | |
49 V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES_SUSTAINING, | |
50 V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200, | |
51 V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200_SUSTAINING, | |
52 V22BIS_RX_TRAINING_STAGE_WAIT_FOR_SCRAMBLED_ONES_AT_2400, | |
53 V22BIS_RX_TRAINING_STAGE_PARKED | |
54 }; | |
55 | |
56 /*! Segments of the training sequence on the transmit side */ | |
57 enum | |
58 { | |
59 V22BIS_TX_TRAINING_STAGE_NORMAL_OPERATION = 0, | |
60 V22BIS_TX_TRAINING_STAGE_INITIAL_TIMED_SILENCE, | |
61 V22BIS_TX_TRAINING_STAGE_INITIAL_SILENCE, | |
62 V22BIS_TX_TRAINING_STAGE_U11, | |
63 V22BIS_TX_TRAINING_STAGE_U0011, | |
64 V22BIS_TX_TRAINING_STAGE_S11, | |
65 V22BIS_TX_TRAINING_STAGE_TIMED_S11, | |
66 V22BIS_TX_TRAINING_STAGE_S1111, | |
67 V22BIS_TX_TRAINING_STAGE_PARKED | |
68 }; | |
69 | |
70 /*! | |
71 V.22bis modem descriptor. This defines the working state for a single instance | |
72 of a V.22bis modem. | |
73 */ | |
74 struct v22bis_state_s | |
75 { | |
76 /*! \brief The maximum permitted bit rate of the modem. Valid values are 1200 and 2400. */ | |
77 int bit_rate; | |
78 /*! \brief TRUE is this is the calling side modem. */ | |
79 int calling_party; | |
80 /*! \brief The callback function used to get the next bit to be transmitted. */ | |
81 get_bit_func_t get_bit; | |
82 /*! \brief A user specified opaque pointer passed to the get_bit callback routine. */ | |
83 void *get_bit_user_data; | |
84 /*! \brief The callback function used to put each bit received. */ | |
85 put_bit_func_t put_bit; | |
86 /*! \brief A user specified opaque pointer passed to the put_bit callback routine. */ | |
87 void *put_bit_user_data; | |
88 /*! \brief The callback function used to report modem status changes. */ | |
89 modem_rx_status_func_t status_handler; | |
90 /*! \brief A user specified opaque pointer passed to the status function. */ | |
91 void *status_user_data; | |
92 | |
93 int negotiated_bit_rate; | |
94 | |
95 /* Receive section */ | |
96 struct | |
97 { | |
98 /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ | |
99 float rrc_filter[2*V22BIS_RX_FILTER_STEPS]; | |
100 /*! \brief Current offset into the RRC pulse shaping filter buffer. */ | |
101 int rrc_filter_step; | |
102 | |
103 /*! \brief The register for the data scrambler. */ | |
104 unsigned int scramble_reg; | |
105 /*! \brief A counter for the number of consecutive bits of repeating pattern through | |
106 the scrambler. */ | |
107 int scrambler_pattern_count; | |
108 | |
109 /*! \brief 0 if receiving user data. A training stage value during training */ | |
110 int training; | |
111 /*! \brief A count of how far through the current training step we are. */ | |
112 int training_count; | |
113 | |
114 /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.22bis signal. */ | |
115 int signal_present; | |
116 | |
117 /*! \brief A measure of how much mismatch there is between the real constellation, | |
118 and the decoded symbol positions. */ | |
119 float training_error; | |
120 | |
121 /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ | |
122 uint32_t carrier_phase; | |
123 /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ | |
124 int32_t carrier_phase_rate; | |
125 /*! \brief The proportional part of the carrier tracking filter. */ | |
126 float carrier_track_p; | |
127 /*! \brief The integral part of the carrier tracking filter. */ | |
128 float carrier_track_i; | |
129 | |
130 /*! \brief A callback function which may be enabled to report every symbol's | |
131 constellation position. */ | |
132 qam_report_handler_t qam_report; | |
133 /*! \brief A user specified opaque pointer passed to the qam_report callback | |
134 routine. */ | |
135 void *qam_user_data; | |
136 | |
137 /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ | |
138 power_meter_t rx_power; | |
139 /*! \brief The power meter level at which carrier on is declared. */ | |
140 int32_t carrier_on_power; | |
141 /*! \brief The power meter level at which carrier off is declared. */ | |
142 int32_t carrier_off_power; | |
143 /*! \brief The scaling factor accessed by the AGC algorithm. */ | |
144 float agc_scaling; | |
145 | |
146 int constellation_state; | |
147 | |
148 /*! \brief The current delta factor for updating the equalizer coefficients. */ | |
149 float eq_delta; | |
150 #if defined(SPANDSP_USE_FIXED_POINTx) | |
151 /*! \brief The adaptive equalizer coefficients. */ | |
152 complexi_t eq_coeff[2*V22BIS_EQUALIZER_LEN + 1]; | |
153 /*! \brief The equalizer signal buffer. */ | |
154 complexi_t eq_buf[V22BIS_EQUALIZER_MASK + 1]; | |
155 #else | |
156 complexf_t eq_coeff[2*V22BIS_EQUALIZER_LEN + 1]; | |
157 complexf_t eq_buf[V22BIS_EQUALIZER_MASK + 1]; | |
158 #endif | |
159 /*! \brief Current offset into the equalizer buffer. */ | |
160 int eq_step; | |
161 /*! \brief Current write offset into the equalizer buffer. */ | |
162 int eq_put_step; | |
163 | |
164 /*! \brief Integration variable for damping the Gardner algorithm tests. */ | |
165 int gardner_integrate; | |
166 /*! \brief Current step size of Gardner algorithm integration. */ | |
167 int gardner_step; | |
168 /*! \brief The total symbol timing correction since the carrier came up. | |
169 This is only for performance analysis purposes. */ | |
170 int total_baud_timing_correction; | |
171 /*! \brief The current fractional phase of the baud timing. */ | |
172 int baud_phase; | |
173 | |
174 int sixteen_way_decisions; | |
175 | |
176 int pattern_repeats; | |
177 int last_raw_bits; | |
178 } rx; | |
179 | |
180 /* Transmit section */ | |
181 struct | |
182 { | |
183 /*! \brief The gain factor needed to achieve the specified output power. */ | |
184 float gain; | |
185 | |
186 /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ | |
187 complexf_t rrc_filter[2*V22BIS_TX_FILTER_STEPS]; | |
188 /*! \brief Current offset into the RRC pulse shaping filter buffer. */ | |
189 int rrc_filter_step; | |
190 | |
191 /*! \brief The register for the data scrambler. */ | |
192 unsigned int scramble_reg; | |
193 /*! \brief A counter for the number of consecutive bits of repeating pattern through | |
194 the scrambler. */ | |
195 int scrambler_pattern_count; | |
196 | |
197 /*! \brief 0 if transmitting user data. A training stage value during training */ | |
198 int training; | |
199 /*! \brief A counter used to track progress through sending the training sequence. */ | |
200 int training_count; | |
201 /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ | |
202 uint32_t carrier_phase; | |
203 /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ | |
204 int32_t carrier_phase_rate; | |
205 /*! \brief The current phase of the guard tone (i.e. the DDS parameter). */ | |
206 uint32_t guard_phase; | |
207 /*! \brief The update rate for the phase of the guard tone (i.e. the DDS increment). */ | |
208 int32_t guard_phase_rate; | |
209 float guard_level; | |
210 /*! \brief The current fractional phase of the baud timing. */ | |
211 int baud_phase; | |
212 /*! \brief The code number for the current position in the constellation. */ | |
213 int constellation_state; | |
214 /*! \brief An indicator to mark that we are tidying up to stop transmission. */ | |
215 int shutdown; | |
216 /*! \brief The get_bit function in use at any instant. */ | |
217 get_bit_func_t current_get_bit; | |
218 } tx; | |
219 | |
220 /*! \brief Error and flow logging control */ | |
221 logging_state_t logging; | |
222 }; | |
223 | |
224 #if defined(__cplusplus) | |
225 extern "C" | |
226 { | |
227 #endif | |
228 | |
229 /*! Reinitialise an existing V.22bis modem receive context. | |
230 \brief Reinitialise an existing V.22bis modem receive context. | |
231 \param s The modem context. | |
232 \return 0 for OK, -1 for bad parameter */ | |
233 int v22bis_rx_restart(v22bis_state_t *s); | |
234 | |
235 void v22bis_report_status_change(v22bis_state_t *s, int status); | |
236 | |
237 void v22bis_equalizer_coefficient_reset(v22bis_state_t *s); | |
238 | |
239 #if defined(__cplusplus) | |
240 } | |
241 #endif | |
242 | |
243 #endif | |
244 /*- End of file ------------------------------------------------------------*/ |