comparison spandsp-0.0.6pre17/src/spandsp/v17tx.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 * v17tx.h - ITU V.17 modem transmit part
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2004 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: v17tx.h,v 1.43.4.1 2009/12/24 16:52:30 steveu Exp $
26 */
27
28 /*! \file */
29
30 #if !defined(_SPANDSP_V17TX_H_)
31 #define _SPANDSP_V17TX_H_
32
33 /*! \page v17tx_page The V.17 transmitter
34 \section v17tx_page_sec_1 What does it do?
35 The V.17 transmitter implements the transmit side of a V.17 modem. This can
36 operate at data rates of 14400, 12000, 9600 and 7200 bits/second. The audio
37 output is a stream of 16 bit samples, at 8000 samples/second. The transmit and
38 receive side of V.17 modems operate independantly. V.17 is mostly used for FAX
39 transmission, where it provides the standard 14400 bits/second rate.
40
41 \section v17tx_page_sec_2 How does it work?
42 V.17 uses QAM modulation and trellis coding. The data to be transmitted is
43 scrambled, to whiten it. The least significant 2 bits of each symbol are then
44 differentially encoded, using a simple lookup approach. The resulting 2 bits are
45 convolutionally encoded, producing 3 bits. The extra bit is the redundant bit
46 of the trellis code. The other bits of the symbol pass by the differential
47 and convolutional coding unchanged. The resulting bits define the constellation
48 point to be transmitted for the symbol. The redundant bit doubles the size of the
49 constellation, and so increases the error rate for detecting individual symbols
50 at the receiver. However, when a number of successive symbols are processed at
51 the receiver, the redundancy actually provides several dB of improved error
52 performance.
53
54 The standard method of producing a QAM modulated signal is to use a sampling
55 rate which is a multiple of the baud rate. The raw signal is then a series of
56 complex pulses, each an integer number of samples long. These can be shaped,
57 using a suitable complex filter, and multiplied by a complex carrier signal
58 to produce the final QAM signal for transmission.
59
60 The pulse shaping filter is only vaguely defined by the V.17 spec. Some of the
61 other ITU modem specs. fully define the filter, typically specifying a root
62 raised cosine filter, with 50% excess bandwidth. This is a pity, since it
63 increases the variability of the received signal. However, the receiver's
64 adaptive equalizer will compensate for these differences. The current
65 design uses a root raised cosine filter with 25% excess bandwidth. Greater
66 excess bandwidth will not allow the tranmitted signal to meet the spectral
67 requirements.
68
69 The sampling rate for our transmitter is defined by the channel - 8000 per
70 second. This is not a multiple of the baud rate (i.e. 2400 baud). The baud
71 interval is actually 10/3 sample periods. Instead of using a symmetric
72 FIR to pulse shape the signal, a polyphase filter is used. This consists of
73 10 sets of coefficients, offering zero to 9/10ths of a baud phase shift as well
74 as root raised cosine filtering. The appropriate coefficient set is chosen for
75 each signal sample generated.
76
77 The carrier is generated using the DDS method. Using two second order resonators,
78 started in quadrature, might be more efficient, as it would have less impact on
79 the processor cache than a table lookup approach. However, the DDS approach
80 suits the receiver better, so the same signal generator is also used for the
81 transmitter.
82 */
83
84 /*!
85 V.17 modem transmit side descriptor. This defines the working state for a
86 single instance of a V.17 modem transmitter.
87 */
88 typedef struct v17_tx_state_s v17_tx_state_t;
89
90 #if defined(__cplusplus)
91 extern "C"
92 {
93 #endif
94
95 /*! Adjust a V.17 modem transmit context's power output.
96 \brief Adjust a V.17 modem transmit context's output power.
97 \param s The modem context.
98 \param power The power level, in dBm0 */
99 SPAN_DECLARE(void) v17_tx_power(v17_tx_state_t *s, float power);
100
101 /*! Initialise a V.17 modem transmit context. This must be called before the first
102 use of the context, to initialise its contents.
103 \brief Initialise a V.17 modem transmit context.
104 \param s The modem context.
105 \param bit_rate The bit rate of the modem. Valid values are 7200, 9600, 12000 and 14400.
106 \param tep TRUE is the optional TEP tone is to be transmitted.
107 \param get_bit The callback routine used to get the data to be transmitted.
108 \param user_data An opaque pointer.
109 \return A pointer to the modem context, or NULL if there was a problem. */
110 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);
111
112 /*! Reinitialise an existing V.17 modem transmit context, so it may be reused.
113 \brief Reinitialise an existing V.17 modem transmit context.
114 \param s The modem context.
115 \param bit_rate The bit rate of the modem. Valid values are 7200, 9600, 12000 and 14400.
116 \param tep TRUE is the optional TEP tone is to be transmitted.
117 \param short_train TRUE if the short training sequence should be used.
118 \return 0 for OK, -1 for parameter error. */
119 SPAN_DECLARE(int) v17_tx_restart(v17_tx_state_t *s, int bit_rate, int tep, int short_train);
120
121 /*! Release a V.17 modem transmit context.
122 \brief Release a V.17 modem transmit context.
123 \param s The modem context.
124 \return 0 for OK */
125 SPAN_DECLARE(int) v17_tx_release(v17_tx_state_t *s);
126
127 /*! Free a V.17 modem transmit context.
128 \brief Free a V.17 modem transmit context.
129 \param s The modem context.
130 \return 0 for OK */
131 SPAN_DECLARE(int) v17_tx_free(v17_tx_state_t *s);
132
133 /*! Get the logging context associated with a V.17 modem transmit context.
134 \brief Get the logging context associated with a V.17 modem transmit context.
135 \param s The modem context.
136 \return A pointer to the logging context */
137 SPAN_DECLARE(logging_state_t *) v17_tx_get_logging_state(v17_tx_state_t *s);
138
139 /*! Change the get_bit function associated with a V.17 modem transmit context.
140 \brief Change the get_bit function associated with a V.17 modem transmit context.
141 \param s The modem context.
142 \param get_bit The callback routine used to get the data to be transmitted.
143 \param user_data An opaque pointer. */
144 SPAN_DECLARE(void) v17_tx_set_get_bit(v17_tx_state_t *s, get_bit_func_t get_bit, void *user_data);
145
146 /*! Change the modem status report function associated with a V.17 modem transmit context.
147 \brief Change the modem status report function associated with a V.17 modem transmit context.
148 \param s The modem context.
149 \param handler The callback routine used to report modem status changes.
150 \param user_data An opaque pointer. */
151 SPAN_DECLARE(void) v17_tx_set_modem_status_handler(v17_tx_state_t *s, modem_tx_status_func_t handler, void *user_data);
152
153 /*! Generate a block of V.17 modem audio samples.
154 \brief Generate a block of V.17 modem audio samples.
155 \param s The modem context.
156 \param amp The audio sample buffer.
157 \param len The number of samples to be generated.
158 \return The number of samples actually generated.
159 */
160 SPAN_DECLARE_NONSTD(int) v17_tx(v17_tx_state_t *s, int16_t amp[], int len);
161
162 #if defined(__cplusplus)
163 }
164 #endif
165
166 #endif
167 /*- End of file ------------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.