v29tx.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * v29tx.h - ITU V.29 modem transmit part
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2003 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_V29TX_H_)
00029 #define _SPANDSP_V29TX_H_
00030 
00031 /*! \page v29tx_page The V.29 transmitter
00032 \section v29tx_page_sec_1 What does it do?
00033 The V.29 transmitter implements the transmit side of a V.29 modem. This can
00034 operate at data rates of 9600, 7200 and 4800 bits/s. The audio output is a
00035 stream of 16 bit samples, at 8000 samples/second. The transmit and receive side
00036 of V.29 modems operate independantly. V.29 is mostly used for FAX transmission,
00037 where it provides the standard 9600 and 7200 bits/s rates (the 4800 bits/s mode
00038 is not used for FAX). 
00039 
00040 \section v29tx_page_sec_2 How does it work?
00041 V.29 uses QAM modulation. The standard method of producing a QAM modulated
00042 signal is to use a sampling rate which is a multiple of the baud rate. The raw
00043 signal is then a series of complex pulses, each an integer number of samples
00044 long. These can be shaped, using a suitable complex filter, and multiplied by a
00045 complex carrier signal to produce the final QAM signal for transmission. 
00046 
00047 The pulse shaping filter is only vaguely defined by the V.29 spec. Some of the
00048 other ITU modem specs. fully define the filter, typically specifying a root
00049 raised cosine filter, with 50% excess bandwidth. This is a pity, since it
00050 increases the variability of the received signal. However, the receiver's
00051 adaptive equalizer will compensate for these differences. The current
00052 design uses a root raised cosine filter with 25% excess bandwidth. Greater
00053 excess bandwidth will not allow the tranmitted signal to meet the spectral
00054 requirements.
00055 
00056 The sampling rate for our transmitter is defined by the channel - 8000 per
00057 second. This is not a multiple of the baud rate (i.e. 2400 baud). The baud
00058 interval is actually 10/3 sample periods. Instead of using a symmetric
00059 FIR to pulse shape the signal, a polyphase filter is used. This consists of
00060 10 sets of coefficients, offering zero to 9/10ths of a baud phase shift as well
00061 as root raised cosine filtering. The appropriate coefficient set is chosen for
00062 each signal sample generated.
00063 
00064 The carrier is generated using the DDS method. Using two second order resonators,
00065 started in quadrature, might be more efficient, as it would have less impact on
00066 the processor cache than a table lookup approach. However, the DDS approach
00067 suits the receiver better, so the same signal generator is also used for the
00068 transmitter. 
00069 
00070 The equation defining QAM modulation is:
00071 
00072     s(n) = A*cos(2*pi*f*n + phi(n))
00073 
00074 where phi(n) is the phase of the information, and A is the amplitude of the information
00075 
00076 using the identity
00077 
00078     cos(x + y) = cos(x)*cos(y) - sin(x)*sin(y)
00079     
00080 we get
00081 
00082     s(n) = A {cos(2*pi*f*n)*cos(phi(n)) - sin(2*pi*f*n)*sin(phi(n))}
00083     
00084 substituting with the constellation positions
00085 
00086     I(n) = A*cos(phi(n))
00087     Q(n) = A*sin(phi(n))
00088     
00089 gives
00090 
00091     s(n) = I(n)*cos(2*pi*f*n) - Q(n)*sin(2*pi*f*n)
00092 
00093 */
00094 
00095 /*!
00096     V.29 modem transmit side descriptor. This defines the working state for a
00097     single instance of a V.29 modem transmitter.
00098 */
00099 typedef struct v29_tx_state_s v29_tx_state_t;
00100 
00101 #if defined(__cplusplus)
00102 extern "C"
00103 {
00104 #endif
00105 
00106 /*! Adjust a V.29 modem transmit context's power output.
00107     \brief Adjust a V.29 modem transmit context's output power.
00108     \param s The modem context.
00109     \param power The power level, in dBm0 */
00110 SPAN_DECLARE(void) v29_tx_power(v29_tx_state_t *s, float power);
00111 
00112 /*! Initialise a V.29 modem transmit context. This must be called before the first
00113     use of the context, to initialise its contents.
00114     \brief Initialise a V.29 modem transmit context.
00115     \param s The modem context.
00116     \param bit_rate The bit rate of the modem. Valid values are 4800, 7200 and 9600.
00117     \param tep TRUE is the optional TEP tone is to be transmitted.
00118     \param get_bit The callback routine used to get the data to be transmitted.
00119     \param user_data An opaque pointer.
00120     \return A pointer to the modem context, or NULL if there was a problem. */
00121 SPAN_DECLARE(v29_tx_state_t *) v29_tx_init(v29_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data);
00122 
00123 /*! Reinitialise an existing V.29 modem transmit context, so it may be reused.
00124     \brief Reinitialise an existing V.29 modem transmit context.
00125     \param s The modem context.
00126     \param bit_rate The bit rate of the modem. Valid values are 4800, 7200 and 9600.
00127     \param tep TRUE is the optional TEP tone is to be transmitted.
00128     \return 0 for OK, -1 for bad parameter */
00129 SPAN_DECLARE(int) v29_tx_restart(v29_tx_state_t *s, int bit_rate, int tep);
00130 
00131 /*! Release a V.29 modem transmit context.
00132     \brief Release a V.29 modem transmit context.
00133     \param s The modem context.
00134     \return 0 for OK */
00135 SPAN_DECLARE(int) v29_tx_release(v29_tx_state_t *s);
00136 
00137 /*! Free a V.29 modem transmit context.
00138     \brief Free a V.29 modem transmit context.
00139     \param s The modem context.
00140     \return 0 for OK */
00141 SPAN_DECLARE(int) v29_tx_free(v29_tx_state_t *s);
00142 
00143 /*! Get the logging context associated with a V.29 modem transmit context.
00144     \brief Get the logging context associated with a V.29 modem transmit context.
00145     \param s The modem context.
00146     \return A pointer to the logging context */
00147 SPAN_DECLARE(logging_state_t *) v29_tx_get_logging_state(v29_tx_state_t *s);
00148 
00149 /*! Change the get_bit function associated with a V.29 modem transmit context.
00150     \brief Change the get_bit function associated with a V.29 modem transmit context.
00151     \param s The modem context.
00152     \param get_bit The callback routine used to get the data to be transmitted.
00153     \param user_data An opaque pointer. */
00154 SPAN_DECLARE(void) v29_tx_set_get_bit(v29_tx_state_t *s, get_bit_func_t get_bit, void *user_data);
00155 
00156 /*! Change the modem status report function associated with a V.29 modem transmit context.
00157     \brief Change the modem status report function associated with a V.29 modem transmit context.
00158     \param s The modem context.
00159     \param handler The callback routine used to report modem status changes.
00160     \param user_data An opaque pointer. */
00161 SPAN_DECLARE(void) v29_tx_set_modem_status_handler(v29_tx_state_t *s, modem_tx_status_func_t handler, void *user_data);
00162 
00163 /*! Generate a block of V.29 modem audio samples.
00164     \brief Generate a block of V.29 modem audio samples.
00165     \param s The modem context.
00166     \param amp The audio sample buffer.
00167     \param len The number of samples to be generated.
00168     \return The number of samples actually generated.
00169 */
00170 SPAN_DECLARE_NONSTD(int) v29_tx(v29_tx_state_t *s, int16_t amp[], int len);
00171 
00172 #if defined(__cplusplus)
00173 }
00174 #endif
00175 
00176 #endif
00177 /*- End of file ------------------------------------------------------------*/

Generated on 18 Oct 2012 for spandsp by  doxygen 1.6.1