Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/private/v17rx.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/v17rx.h - ITU V.17 modem receive part | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2003 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: v17rx.h,v 1.2.4.1 2009/12/24 16:52:30 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 #if !defined(_SPANDSP_PRIVATE_V17RX_H_) | |
| 29 #define _SPANDSP_PRIVATE_V17RX_H_ | |
| 30 | |
| 31 /* Target length for the equalizer is about 63 taps, to deal with the worst stuff | |
| 32 in V.56bis. */ | |
| 33 /*! Samples before the target position in the equalizer buffer */ | |
| 34 #define V17_EQUALIZER_PRE_LEN 8 | |
| 35 /*! Samples after the target position in the equalizer buffer */ | |
| 36 #define V17_EQUALIZER_POST_LEN 8 | |
| 37 | |
| 38 /*! The number of taps in the pulse shaping/bandpass filter */ | |
| 39 #define V17_RX_FILTER_STEPS 27 | |
| 40 | |
| 41 /* We can store more trellis depth that we look back over, so that we can push out a group | |
| 42 of symbols in one go, giving greater processing efficiency, at the expense of a bit more | |
| 43 latency through the modem. */ | |
| 44 /* Right now we don't take advantage of this optimisation. */ | |
| 45 /*! The depth of the trellis buffer */ | |
| 46 #define V17_TRELLIS_STORAGE_DEPTH 16 | |
| 47 /*! How far we look back into history for trellis decisions */ | |
| 48 #define V17_TRELLIS_LOOKBACK_DEPTH 16 | |
| 49 | |
| 50 /*! | |
| 51 V.17 modem receive side descriptor. This defines the working state for a | |
| 52 single instance of a V.17 modem receiver. | |
| 53 */ | |
| 54 struct v17_rx_state_s | |
| 55 { | |
| 56 /*! \brief The bit rate of the modem. Valid values are 7200 9600, 12000 and 14400. */ | |
| 57 int bit_rate; | |
| 58 /*! \brief The callback function used to put each bit received. */ | |
| 59 put_bit_func_t put_bit; | |
| 60 /*! \brief A user specified opaque pointer passed to the put_but routine. */ | |
| 61 void *put_bit_user_data; | |
| 62 | |
| 63 /*! \brief The callback function used to report modem status changes. */ | |
| 64 modem_rx_status_func_t status_handler; | |
| 65 /*! \brief A user specified opaque pointer passed to the status function. */ | |
| 66 void *status_user_data; | |
| 67 | |
| 68 /*! \brief A callback function which may be enabled to report every symbol's | |
| 69 constellation position. */ | |
| 70 qam_report_handler_t qam_report; | |
| 71 /*! \brief A user specified opaque pointer passed to the qam_report callback | |
| 72 routine. */ | |
| 73 void *qam_user_data; | |
| 74 | |
| 75 /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ | |
| 76 #if defined(SPANDSP_USE_FIXED_POINT) | |
| 77 int16_t rrc_filter[V17_RX_FILTER_STEPS]; | |
| 78 #else | |
| 79 float rrc_filter[V17_RX_FILTER_STEPS]; | |
| 80 #endif | |
| 81 /*! \brief Current offset into the RRC pulse shaping filter buffer. */ | |
| 82 int rrc_filter_step; | |
| 83 | |
| 84 /*! \brief The state of the differential decoder */ | |
| 85 int diff; | |
| 86 /*! \brief The register for the data scrambler. */ | |
| 87 uint32_t scramble_reg; | |
| 88 /*! \brief Scrambler tap */ | |
| 89 //int scrambler_tap; | |
| 90 | |
| 91 /*! \brief TRUE if the short training sequence is to be used. */ | |
| 92 int short_train; | |
| 93 /*! \brief The section of the training data we are currently in. */ | |
| 94 int training_stage; | |
| 95 /*! \brief A count of how far through the current training step we are. */ | |
| 96 int training_count; | |
| 97 /*! \brief A measure of how much mismatch there is between the real constellation, | |
| 98 and the decoded symbol positions. */ | |
| 99 float training_error; | |
| 100 /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ | |
| 101 int16_t last_sample; | |
| 102 /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.17 signal. */ | |
| 103 int signal_present; | |
| 104 /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */ | |
| 105 int carrier_drop_pending; | |
| 106 /*! \brief A count of the current consecutive samples below the carrier off threshold. */ | |
| 107 int low_samples; | |
| 108 /*! \brief A highest magnitude sample seen. */ | |
| 109 int16_t high_sample; | |
| 110 | |
| 111 /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ | |
| 112 uint32_t carrier_phase; | |
| 113 /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ | |
| 114 int32_t carrier_phase_rate; | |
| 115 /*! \brief The carrier update rate saved for reuse when using short training. */ | |
| 116 int32_t carrier_phase_rate_save; | |
| 117 #if defined(SPANDSP_USE_FIXED_POINTx) | |
| 118 /*! \brief The proportional part of the carrier tracking filter. */ | |
| 119 float carrier_track_p; | |
| 120 /*! \brief The integral part of the carrier tracking filter. */ | |
| 121 float carrier_track_i; | |
| 122 #else | |
| 123 /*! \brief The proportional part of the carrier tracking filter. */ | |
| 124 float carrier_track_p; | |
| 125 /*! \brief The integral part of the carrier tracking filter. */ | |
| 126 float carrier_track_i; | |
| 127 #endif | |
| 128 | |
| 129 /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ | |
| 130 power_meter_t power; | |
| 131 /*! \brief The power meter level at which carrier on is declared. */ | |
| 132 int32_t carrier_on_power; | |
| 133 /*! \brief The power meter level at which carrier off is declared. */ | |
| 134 int32_t carrier_off_power; | |
| 135 | |
| 136 /*! \brief Current read offset into the equalizer buffer. */ | |
| 137 int eq_step; | |
| 138 /*! \brief Current write offset into the equalizer buffer. */ | |
| 139 int eq_put_step; | |
| 140 /*! \brief Symbol counter to the next equalizer update. */ | |
| 141 int eq_skip; | |
| 142 | |
| 143 /*! \brief The current half of the baud. */ | |
| 144 int baud_half; | |
| 145 | |
| 146 #if defined(SPANDSP_USE_FIXED_POINTx) | |
| 147 /*! \brief The scaling factor accessed by the AGC algorithm. */ | |
| 148 float agc_scaling; | |
| 149 /*! \brief The previous value of agc_scaling, needed to reuse old training. */ | |
| 150 float agc_scaling_save; | |
| 151 | |
| 152 /*! \brief The current delta factor for updating the equalizer coefficients. */ | |
| 153 float eq_delta; | |
| 154 /*! \brief The adaptive equalizer coefficients. */ | |
| 155 complexi16_t eq_coeff[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; | |
| 156 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ | |
| 157 complexi16_t eq_coeff_save[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; | |
| 158 /*! \brief The equalizer signal buffer. */ | |
| 159 complexi16_t eq_buf[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; | |
| 160 | |
| 161 /*! Low band edge filter for symbol sync. */ | |
| 162 int32_t symbol_sync_low[2]; | |
| 163 /*! High band edge filter for symbol sync. */ | |
| 164 int32_t symbol_sync_high[2]; | |
| 165 /*! DC filter for symbol sync. */ | |
| 166 int32_t symbol_sync_dc_filter[2]; | |
| 167 /*! Baud phase for symbol sync. */ | |
| 168 int32_t baud_phase; | |
| 169 #else | |
| 170 /*! \brief The scaling factor accessed by the AGC algorithm. */ | |
| 171 float agc_scaling; | |
| 172 /*! \brief The previous value of agc_scaling, needed to reuse old training. */ | |
| 173 float agc_scaling_save; | |
| 174 | |
| 175 /*! \brief The current delta factor for updating the equalizer coefficients. */ | |
| 176 float eq_delta; | |
| 177 /*! \brief The adaptive equalizer coefficients. */ | |
| 178 complexf_t eq_coeff[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; | |
| 179 /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ | |
| 180 complexf_t eq_coeff_save[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; | |
| 181 /*! \brief The equalizer signal buffer. */ | |
| 182 complexf_t eq_buf[V17_EQUALIZER_PRE_LEN + 1 + V17_EQUALIZER_POST_LEN]; | |
| 183 | |
| 184 /*! Low band edge filter for symbol sync. */ | |
| 185 float symbol_sync_low[2]; | |
| 186 /*! High band edge filter for symbol sync. */ | |
| 187 float symbol_sync_high[2]; | |
| 188 /*! DC filter for symbol sync. */ | |
| 189 float symbol_sync_dc_filter[2]; | |
| 190 /*! Baud phase for symbol sync. */ | |
| 191 float baud_phase; | |
| 192 #endif | |
| 193 | |
| 194 /*! \brief The total symbol timing correction since the carrier came up. | |
| 195 This is only for performance analysis purposes. */ | |
| 196 int total_baud_timing_correction; | |
| 197 | |
| 198 /*! \brief Starting phase angles for the coarse carrier aquisition step. */ | |
| 199 int32_t start_angles[2]; | |
| 200 /*! \brief History list of phase angles for the coarse carrier aquisition step. */ | |
| 201 int32_t angles[16]; | |
| 202 /*! \brief A pointer to the current constellation. */ | |
| 203 #if defined(SPANDSP_USE_FIXED_POINTx) | |
| 204 const complexi16_t *constellation; | |
| 205 #else | |
| 206 const complexf_t *constellation; | |
| 207 #endif | |
| 208 /*! \brief A pointer to the current space map. There is a space map for | |
| 209 each trellis state. */ | |
| 210 int space_map; | |
| 211 /*! \brief The number of bits in each symbol at the current bit rate. */ | |
| 212 int bits_per_symbol; | |
| 213 | |
| 214 /*! \brief Current pointer to the trellis buffers */ | |
| 215 int trellis_ptr; | |
| 216 /*! \brief The trellis. */ | |
| 217 int full_path_to_past_state_locations[V17_TRELLIS_STORAGE_DEPTH][8]; | |
| 218 /*! \brief The trellis. */ | |
| 219 int past_state_locations[V17_TRELLIS_STORAGE_DEPTH][8]; | |
| 220 /*! \brief Euclidean distances (actually the squares of the distances) | |
| 221 from the last states of the trellis. */ | |
| 222 #if defined(SPANDSP_USE_FIXED_POINTx) | |
| 223 uint32_t distances[8]; | |
| 224 #else | |
| 225 float distances[8]; | |
| 226 #endif | |
| 227 /*! \brief Error and flow logging control */ | |
| 228 logging_state_t logging; | |
| 229 }; | |
| 230 | |
| 231 #endif | |
| 232 /*- End of file ------------------------------------------------------------*/ |
