spandsp 0.0.6

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