v27ter_tx.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * v27ter_tx.h - ITU V.27ter 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_V27TER_TX_H_)
00029 #define _SPANDSP_V27TER_TX_H_
00030 
00031 /*! \page v27ter_tx_page The V.27ter transmitter
00032 \section v27ter_tx_page_sec_1 What does it do?
00033 The V.27ter transmitter implements the transmit side of a V.27ter modem. This
00034 can operate at data rates of 4800 and 2400 bits/s. The audio output is a stream
00035 of 16 bit samples, at 8000 samples/second. The transmit and receive side of
00036 V.27ter modems operate independantly. V.27ter is used for FAX transmission,
00037 where it provides the standard 4800 and 2400 bits/s rates. 
00038 
00039 \section v27ter_tx_page_sec_2 How does it work?
00040 V.27ter uses DPSK modulation. A common method of producing a DPSK modulated
00041 signal is to use a sampling rate which is a multiple of the baud rate. The raw
00042 signal is then a series of complex pulses, each an integer number of samples
00043 long. These can be shaped, using a suitable complex filter, and multiplied by a
00044 complex carrier signal to produce the final DPSK signal for transmission. 
00045 
00046 The pulse shaping filter for V.27ter is defined in the spec. It is a root raised
00047 cosine filter with 50% excess bandwidth. 
00048 
00049 The sampling rate for our transmitter is defined by the channel - 8000 samples/s.
00050 This is a multiple of the baud rate at 4800 bits/s (8-PSK at 1600 baud, 5 samples per
00051 symbol), but not at 2400 bits/s (4-PSK at 1200 baud, 20/3 samples per symbol). The baud
00052 interval is actually 20/3 sample periods at 2400bis/s. A symmetric FIR is used to
00053 apply root raised cosine filtering in the 4800bits/s mode. In the 2400bits/s mode
00054 a polyphase FIR filter is used. This consists of 20 sets of coefficients, offering
00055 zero to 19/20ths of a baud phase shift as well as root raised cosine filtering.
00056 The appropriate coefficient set is chosen for each signal sample generated.
00057 
00058 The carrier is generated using the DDS method. Using 2 second order resonators,
00059 started in quadrature, might be more efficient, as it would have less impact on
00060 the processor cache than a table lookup approach. However, the DDS approach
00061 suits the receiver better, so then same signal generator is also used for the
00062 transmitter.
00063 */
00064 
00065 /*!
00066     V.27ter modem transmit side descriptor. This defines the working state for a
00067     single instance of a V.27ter modem transmitter.
00068 */
00069 typedef struct v27ter_tx_state_s v27ter_tx_state_t;
00070 
00071 #if defined(__cplusplus)
00072 extern "C"
00073 {
00074 #endif
00075 
00076 /*! Adjust a V.27ter modem transmit context's power output.
00077     \brief Adjust a V.27ter modem transmit context's output power.
00078     \param s The modem context.
00079     \param power The power level, in dBm0 */
00080 SPAN_DECLARE(void) v27ter_tx_power(v27ter_tx_state_t *s, float power);
00081 
00082 /*! Initialise a V.27ter modem transmit context.
00083     \brief Initialise a V.27ter modem transmit context.
00084     \param s The modem context.
00085     \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800.
00086     \param tep TRUE is the optional TEP tone is to be transmitted.
00087     \param get_bit The callback routine used to get the data to be transmitted.
00088     \param user_data An opaque pointer.
00089     \return A pointer to the modem context, or NULL if there was a problem. */
00090 SPAN_DECLARE(v27ter_tx_state_t *) v27ter_tx_init(v27ter_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data);
00091 
00092 /*! Reinitialise an existing V.27ter modem transmit context, so it may be reused.
00093     \brief Reinitialise an existing V.27ter modem transmit context.
00094     \param s The modem context.
00095     \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800.
00096     \param tep TRUE is the optional TEP tone is to be transmitted.
00097     \return 0 for OK, -1 for bad parameter */
00098 SPAN_DECLARE(int) v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, int tep);
00099 
00100 /*! Release a V.27ter modem transmit context.
00101     \brief Release a V.27ter modem transmit context.
00102     \param s The modem context.
00103     \return 0 for OK */
00104 SPAN_DECLARE(int) v27ter_tx_release(v27ter_tx_state_t *s);
00105 
00106 /*! Free a V.27ter modem transmit context.
00107     \brief Free a V.27ter modem transmit context.
00108     \param s The modem context.
00109     \return 0 for OK */
00110 SPAN_DECLARE(int) v27ter_tx_free(v27ter_tx_state_t *s);
00111 
00112 /*! Get the logging context associated with a V.27ter modem transmit context.
00113     \brief Get the logging context associated with a V.27ter modem transmit context.
00114     \param s The modem context.
00115     \return A pointer to the logging context */
00116 SPAN_DECLARE(logging_state_t *) v27ter_tx_get_logging_state(v27ter_tx_state_t *s);
00117 
00118 /*! Change the get_bit function associated with a V.27ter modem transmit context.
00119     \brief Change the get_bit function associated with a V.27ter modem transmit context.
00120     \param s The modem context.
00121     \param get_bit The callback routine used to get the data to be transmitted.
00122     \param user_data An opaque pointer. */
00123 SPAN_DECLARE(void) v27ter_tx_set_get_bit(v27ter_tx_state_t *s, get_bit_func_t get_bit, void *user_data);
00124 
00125 /*! Change the modem status report function associated with a V.27ter modem transmit context.
00126     \brief Change the modem status report function associated with a V.27ter modem transmit context.
00127     \param s The modem context.
00128     \param handler The callback routine used to report modem status changes.
00129     \param user_data An opaque pointer. */
00130 SPAN_DECLARE(void) v27ter_tx_set_modem_status_handler(v27ter_tx_state_t *s, modem_tx_status_func_t handler, void *user_data);
00131 
00132 /*! Generate a block of V.27ter modem audio samples.
00133     \brief Generate a block of V.27ter modem audio samples.
00134     \param s The modem context.
00135     \param amp The audio sample buffer.
00136     \param len The number of samples to be generated.
00137     \return The number of samples actually generated.
00138 */
00139 SPAN_DECLARE_NONSTD(int) v27ter_tx(v27ter_tx_state_t *s, int16_t amp[], int len);
00140 
00141 #if defined(__cplusplus)
00142 }
00143 #endif
00144 
00145 #endif
00146 /*- End of file ------------------------------------------------------------*/

Generated on 25 Jan 2012 for spandsp by  doxygen 1.6.1