spandsp: v27ter_tx.h Source File

spandsp 0.0.6

v27ter_tx.h
Go to the documentation of this file.
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * v27ter_tx.h - ITU V.27ter modem transmit part
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2003 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_V27TER_TX_H_)
29#define _SPANDSP_V27TER_TX_H_
30
31/*! \page v27ter_tx_page The V.27ter transmitter
32\section v27ter_tx_page_sec_1 What does it do?
33The V.27ter transmitter implements the transmit side of a V.27ter modem. This
34can operate at data rates of 4800 and 2400 bits/s. The audio output is a stream
35of 16 bit samples, at 8000 samples/second. The transmit and receive side of
36V.27ter modems operate independantly. V.27ter is used for FAX transmission,
37where it provides the standard 4800 and 2400 bits/s rates.
38
39\section v27ter_tx_page_sec_2 How does it work?
40V.27ter uses DPSK modulation. A common method of producing a DPSK modulated
41signal is to use a sampling rate which is a multiple of the baud rate. The raw
42signal is then a series of complex pulses, each an integer number of samples
43long. These can be shaped, using a suitable complex filter, and multiplied by a
44complex carrier signal to produce the final DPSK signal for transmission.
45
46The pulse shaping filter for V.27ter is defined in the spec. It is a root raised
47cosine filter with 50% excess bandwidth.
48
49The sampling rate for our transmitter is defined by the channel - 8000 samples/s.
50This is a multiple of the baud rate at 4800 bits/s (8-PSK at 1600 baud, 5 samples per
51symbol), but not at 2400 bits/s (4-PSK at 1200 baud, 20/3 samples per symbol). The baud
52interval is actually 20/3 sample periods at 2400bis/s. A symmetric FIR is used to
53apply root raised cosine filtering in the 4800bits/s mode. In the 2400bits/s mode
54a polyphase FIR filter is used. This consists of 20 sets of coefficients, offering
55zero to 19/20ths of a baud phase shift as well as root raised cosine filtering.
56The appropriate coefficient set is chosen for each signal sample generated.
57
58The carrier is generated using the DDS method. Using 2 second order resonators,
59started in quadrature, might be more efficient, as it would have less impact on
60the processor cache than a table lookup approach. However, the DDS approach
61suits the receiver better, so then same signal generator is also used for the
62transmitter.
63*/
64
65/*!
66 V.27ter modem transmit side descriptor. This defines the working state for a
67 single instance of a V.27ter modem transmitter.
68*/
69 typedef struct v27ter_tx_state_s v27ter_tx_state_t;
70
71#if defined(__cplusplus)
72extern "C"
73{
74#endif
75
76/*! Adjust a V.27ter modem transmit context's power output.
77 \brief Adjust a V.27ter modem transmit context's output power.
78 \param s The modem context.
79 \param power The power level, in dBm0 */
80SPAN_DECLARE(void) v27ter_tx_power(v27ter_tx_state_t *s, float power);
81
82/*! Initialise a V.27ter modem transmit context.
83 \brief Initialise a V.27ter modem transmit context.
84 \param s The modem context.
85 \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800.
86 \param tep TRUE is the optional TEP tone is to be transmitted.
87 \param get_bit The callback routine used to get the data to be transmitted.
88 \param user_data An opaque pointer.
89 \return A pointer to the modem context, or NULL if there was a problem. */
90SPAN_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);
91
92/*! Reinitialise an existing V.27ter modem transmit context, so it may be reused.
93 \brief Reinitialise an existing V.27ter modem transmit context.
94 \param s The modem context.
95 \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800.
96 \param tep TRUE is the optional TEP tone is to be transmitted.
97 \return 0 for OK, -1 for bad parameter */
98SPAN_DECLARE(int) v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, int tep);
99
100/*! Release a V.27ter modem transmit context.
101 \brief Release a V.27ter modem transmit context.
102 \param s The modem context.
103 \return 0 for OK */
104SPAN_DECLARE(int) v27ter_tx_release(v27ter_tx_state_t *s);
105
106/*! Free a V.27ter modem transmit context.
107 \brief Free a V.27ter modem transmit context.
108 \param s The modem context.
109 \return 0 for OK */
110SPAN_DECLARE(int) v27ter_tx_free(v27ter_tx_state_t *s);
111
112/*! Get the logging context associated with a V.27ter modem transmit context.
113 \brief Get the logging context associated with a V.27ter modem transmit context.
114 \param s The modem context.
115 \return A pointer to the logging context */
116SPAN_DECLARE(logging_state_t *) v27ter_tx_get_logging_state(v27ter_tx_state_t *s);
117
118/*! Change the get_bit function associated with a V.27ter modem transmit context.
119 \brief Change the get_bit function associated with a V.27ter modem transmit context.
120 \param s The modem context.
121 \param get_bit The callback routine used to get the data to be transmitted.
122 \param user_data An opaque pointer. */
123SPAN_DECLARE(void) v27ter_tx_set_get_bit(v27ter_tx_state_t *s, get_bit_func_t get_bit, void *user_data);
124
125/*! Change the modem status report function associated with a V.27ter modem transmit context.
126 \brief Change the modem status report function associated with a V.27ter modem transmit context.
127 \param s The modem context.
128 \param handler The callback routine used to report modem status changes.
129 \param user_data An opaque pointer. */
130SPAN_DECLARE(void) v27ter_tx_set_modem_status_handler(v27ter_tx_state_t *s, modem_status_func_t handler, void *user_data);
131
132/*! Generate a block of V.27ter modem audio samples.
133 \brief Generate a block of V.27ter modem audio samples.
134 \param s The modem context.
135 \param amp The audio sample buffer.
136 \param len The number of samples to be generated.
137 \return The number of samples actually generated.
138*/
139SPAN_DECLARE_NONSTD(int) v27ter_tx(v27ter_tx_state_t *s, int16_t amp[], int len);
140
141#if defined(__cplusplus)
142}
143#endif
144
145#endif
146/*- End of file ------------------------------------------------------------*/
modem_status_func_t
void(* modem_status_func_t)(void *user_data, int status)
Definition async.h:114
get_bit_func_t
int(* get_bit_func_t)(void *user_data)
Definition async.h:108
logging_state_s
Definition private/logging.h:34
v27ter_tx_state_s
Definition private/v27ter_tx.h:37
v27ter_tx_state_s::bit_rate
int bit_rate
The bit rate of the modem. Valid values are 2400 and 4800.
Definition private/v27ter_tx.h:39
v27ter_tx_state_s::get_bit
get_bit_func_t get_bit
The callback function used to get the next bit to be transmitted.
Definition private/v27ter_tx.h:41
v27ter_tx_set_modem_status_handler
void v27ter_tx_set_modem_status_handler(v27ter_tx_state_t *s, modem_status_func_t handler, void *user_data)
Change the modem status report function associated with a V.27ter modem transmit context.
Definition v27ter_tx.c:377
v27ter_tx_power
void v27ter_tx_power(v27ter_tx_state_t *s, float power)
Adjust a V.27ter modem transmit context's output power.
Definition v27ter_tx.c:353
v27ter_tx_release
int v27ter_tx_release(v27ter_tx_state_t *s)
Release a V.27ter modem transmit context.
Definition v27ter_tx.c:440
v27ter_tx_restart
int v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, int tep)
Reinitialise an existing V.27ter modem transmit context.
Definition v27ter_tx.c:390
v27ter_tx_free
int v27ter_tx_free(v27ter_tx_state_t *s)
Free a V.27ter modem transmit context.
Definition v27ter_tx.c:446
v27ter_tx_set_get_bit
void v27ter_tx_set_get_bit(v27ter_tx_state_t *s, get_bit_func_t get_bit, void *user_data)
Change the get_bit function associated with a V.27ter modem transmit context.
Definition v27ter_tx.c:368
v27ter_tx_init
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)
Initialise a V.27ter modem transmit context.
Definition v27ter_tx.c:413
v27ter_tx_get_logging_state
logging_state_t * v27ter_tx_get_logging_state(v27ter_tx_state_t *s)
Get the logging context associated with a V.27ter modem transmit context.
Definition v27ter_tx.c:384