spandsp
0.0.6
|
00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * v17tx.h - ITU V.17 modem transmit part 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2004 Steve Underwood 00009 * 00010 * All rights reserved. 00011 * 00012 * This program is free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 2.1, 00014 * as published by the Free Software Foundation. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Lesser General Public 00022 * License along with this program; if not, write to the Free Software 00023 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 */ 00025 00026 /*! \file */ 00027 00028 #if !defined(_SPANDSP_V17TX_H_) 00029 #define _SPANDSP_V17TX_H_ 00030 00031 /*! \page v17tx_page The V.17 transmitter 00032 \section v17tx_page_sec_1 What does it do? 00033 The V.17 transmitter implements the transmit side of a V.17 modem. This can 00034 operate at data rates of 14400, 12000, 9600 and 7200 bits/second. The audio 00035 output is a stream of 16 bit samples, at 8000 samples/second. The transmit and 00036 receive side of V.17 modems operate independantly. V.17 is mostly used for FAX 00037 transmission, where it provides the standard 14400 bits/second rate. 00038 00039 \section v17tx_page_sec_2 How does it work? 00040 V.17 uses QAM modulation and trellis coding. The data to be transmitted is 00041 scrambled, to whiten it. The least significant 2 bits of each symbol are then 00042 differentially encoded, using a simple lookup approach. The resulting 2 bits are 00043 convolutionally encoded, producing 3 bits. The extra bit is the redundant bit 00044 of the trellis code. The other bits of the symbol pass by the differential 00045 and convolutional coding unchanged. The resulting bits define the constellation 00046 point to be transmitted for the symbol. The redundant bit doubles the size of the 00047 constellation, and so increases the error rate for detecting individual symbols 00048 at the receiver. However, when a number of successive symbols are processed at 00049 the receiver, the redundancy actually provides several dB of improved error 00050 performance. 00051 00052 The standard method of producing a QAM modulated signal is to use a sampling 00053 rate which is a multiple of the baud rate. The raw signal is then a series of 00054 complex pulses, each an integer number of samples long. These can be shaped, 00055 using a suitable complex filter, and multiplied by a complex carrier signal 00056 to produce the final QAM signal for transmission. 00057 00058 The pulse shaping filter is only vaguely defined by the V.17 spec. Some of the 00059 other ITU modem specs. fully define the filter, typically specifying a root 00060 raised cosine filter, with 50% excess bandwidth. This is a pity, since it 00061 increases the variability of the received signal. However, the receiver's 00062 adaptive equalizer will compensate for these differences. The current 00063 design uses a root raised cosine filter with 25% excess bandwidth. Greater 00064 excess bandwidth will not allow the tranmitted signal to meet the spectral 00065 requirements. 00066 00067 The sampling rate for our transmitter is defined by the channel - 8000 per 00068 second. This is not a multiple of the baud rate (i.e. 2400 baud). The baud 00069 interval is actually 10/3 sample periods. Instead of using a symmetric 00070 FIR to pulse shape the signal, a polyphase filter is used. This consists of 00071 10 sets of coefficients, offering zero to 9/10ths of a baud phase shift as well 00072 as root raised cosine filtering. The appropriate coefficient set is chosen for 00073 each signal sample generated. 00074 00075 The carrier is generated using the DDS method. Using two second order resonators, 00076 started in quadrature, might be more efficient, as it would have less impact on 00077 the processor cache than a table lookup approach. However, the DDS approach 00078 suits the receiver better, so the same signal generator is also used for the 00079 transmitter. 00080 */ 00081 00082 /*! 00083 V.17 modem transmit side descriptor. This defines the working state for a 00084 single instance of a V.17 modem transmitter. 00085 */ 00086 typedef struct v17_tx_state_s v17_tx_state_t; 00087 00088 #if defined(__cplusplus) 00089 extern "C" 00090 { 00091 #endif 00092 00093 /*! Adjust a V.17 modem transmit context's power output. 00094 \brief Adjust a V.17 modem transmit context's output power. 00095 \param s The modem context. 00096 \param power The power level, in dBm0 */ 00097 SPAN_DECLARE(void) v17_tx_power(v17_tx_state_t *s, float power); 00098 00099 /*! Initialise a V.17 modem transmit context. This must be called before the first 00100 use of the context, to initialise its contents. 00101 \brief Initialise a V.17 modem transmit context. 00102 \param s The modem context. 00103 \param bit_rate The bit rate of the modem. Valid values are 7200, 9600, 12000 and 14400. 00104 \param tep TRUE is the optional TEP tone is to be transmitted. 00105 \param get_bit The callback routine used to get the data to be transmitted. 00106 \param user_data An opaque pointer. 00107 \return A pointer to the modem context, or NULL if there was a problem. */ 00108 SPAN_DECLARE(v17_tx_state_t *) v17_tx_init(v17_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data); 00109 00110 /*! Reinitialise an existing V.17 modem transmit context, so it may be reused. 00111 \brief Reinitialise an existing V.17 modem transmit context. 00112 \param s The modem context. 00113 \param bit_rate The bit rate of the modem. Valid values are 7200, 9600, 12000 and 14400. 00114 \param tep TRUE is the optional TEP tone is to be transmitted. 00115 \param short_train TRUE if the short training sequence should be used. 00116 \return 0 for OK, -1 for parameter error. */ 00117 SPAN_DECLARE(int) v17_tx_restart(v17_tx_state_t *s, int bit_rate, int tep, int short_train); 00118 00119 /*! Release a V.17 modem transmit context. 00120 \brief Release a V.17 modem transmit context. 00121 \param s The modem context. 00122 \return 0 for OK */ 00123 SPAN_DECLARE(int) v17_tx_release(v17_tx_state_t *s); 00124 00125 /*! Free a V.17 modem transmit context. 00126 \brief Free a V.17 modem transmit context. 00127 \param s The modem context. 00128 \return 0 for OK */ 00129 SPAN_DECLARE(int) v17_tx_free(v17_tx_state_t *s); 00130 00131 /*! Get the logging context associated with a V.17 modem transmit context. 00132 \brief Get the logging context associated with a V.17 modem transmit context. 00133 \param s The modem context. 00134 \return A pointer to the logging context */ 00135 SPAN_DECLARE(logging_state_t *) v17_tx_get_logging_state(v17_tx_state_t *s); 00136 00137 /*! Change the get_bit function associated with a V.17 modem transmit context. 00138 \brief Change the get_bit function associated with a V.17 modem transmit context. 00139 \param s The modem context. 00140 \param get_bit The callback routine used to get the data to be transmitted. 00141 \param user_data An opaque pointer. */ 00142 SPAN_DECLARE(void) v17_tx_set_get_bit(v17_tx_state_t *s, get_bit_func_t get_bit, void *user_data); 00143 00144 /*! Change the modem status report function associated with a V.17 modem transmit context. 00145 \brief Change the modem status report function associated with a V.17 modem transmit context. 00146 \param s The modem context. 00147 \param handler The callback routine used to report modem status changes. 00148 \param user_data An opaque pointer. */ 00149 SPAN_DECLARE(void) v17_tx_set_modem_status_handler(v17_tx_state_t *s, modem_tx_status_func_t handler, void *user_data); 00150 00151 /*! Generate a block of V.17 modem audio samples. 00152 \brief Generate a block of V.17 modem audio samples. 00153 \param s The modem context. 00154 \param amp The audio sample buffer. 00155 \param len The number of samples to be generated. 00156 \return The number of samples actually generated. 00157 */ 00158 SPAN_DECLARE_NONSTD(int) v17_tx(v17_tx_state_t *s, int16_t amp[], int len); 00159 00160 #if defined(__cplusplus) 00161 } 00162 #endif 00163 00164 #endif 00165 /*- End of file ------------------------------------------------------------*/