v17tx.h

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

Generated by  doxygen 1.6.2