comparison spandsp-0.0.6pre17/src/spandsp/v27ter_rx.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 * v27ter_rx.h - ITU V.27ter modem receive 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 * $Id: v27ter_rx.h,v 1.61 2009/07/09 13:52:09 steveu Exp $
26 */
27
28 /*! \file */
29
30 #if !defined(_SPANDSP_V27TER_RX_H_)
31 #define _SPANDSP_V27TER_RX_H_
32
33 /*! \page v27ter_rx_page The V.27ter receiver
34
35 \section v27ter_rx_page_sec_1 What does it do?
36 The V.27ter receiver implements the receive side of a V.27ter modem. This can operate
37 at data rates of 4800 and 2400 bits/s. The audio input is a stream of 16 bit samples,
38 at 8000 samples/second. The transmit and receive side of V.27ter modems operate
39 independantly. V.27ter is mostly used for FAX transmission, where it provides the
40 standard 4800 bits/s rate (the 2400 bits/s mode is not used for FAX).
41
42 \section v27ter_rx_page_sec_2 How does it work?
43 V.27ter defines two modes of operation. One uses 8-PSK at 1600 baud, giving 4800bps.
44 The other uses 4-PSK at 1200 baud, giving 2400bps. A training sequence is specified
45 at the start of transmission, which makes the design of a V.27ter receiver relatively
46 straightforward.
47 */
48
49 /*!
50 V.27ter modem receive side descriptor. This defines the working state for a
51 single instance of a V.27ter modem receiver.
52 */
53 typedef struct v27ter_rx_state_s v27ter_rx_state_t;
54
55 #if defined(__cplusplus)
56 extern "C"
57 {
58 #endif
59
60 /*! Initialise a V.27ter modem receive context.
61 \brief Initialise a V.27ter modem receive context.
62 \param s The modem context.
63 \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800.
64 \param put_bit The callback routine used to put the received data.
65 \param user_data An opaque pointer passed to the put_bit routine.
66 \return A pointer to the modem context, or NULL if there was a problem. */
67 SPAN_DECLARE(v27ter_rx_state_t *) v27ter_rx_init(v27ter_rx_state_t *s, int bit_rate, put_bit_func_t put_bit, void *user_data);
68
69 /*! Reinitialise an existing V.27ter modem receive context.
70 \brief Reinitialise an existing V.27ter modem receive context.
71 \param s The modem context.
72 \param bit_rate The bit rate of the modem. Valid values are 2400 and 4800.
73 \param old_train TRUE if a previous trained values are to be reused.
74 \return 0 for OK, -1 for bad parameter */
75 SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_train);
76
77 /*! Release a V.27ter modem receive context.
78 \brief Release a V.27ter modem receive context.
79 \param s The modem context.
80 \return 0 for OK */
81 SPAN_DECLARE(int) v27ter_rx_release(v27ter_rx_state_t *s);
82
83 /*! Free a V.27ter modem receive context.
84 \brief Free a V.27ter modem receive context.
85 \param s The modem context.
86 \return 0 for OK */
87 SPAN_DECLARE(int) v27ter_rx_free(v27ter_rx_state_t *s);
88
89 /*! Get the logging context associated with a V.27ter modem receive context.
90 \brief Get the logging context associated with a V.27ter modem receive context.
91 \param s The modem context.
92 \return A pointer to the logging context */
93 SPAN_DECLARE(logging_state_t *) v27ter_rx_get_logging_state(v27ter_rx_state_t *s);
94
95 /*! Change the put_bit function associated with a V.27ter modem receive context.
96 \brief Change the put_bit function associated with a V.27ter modem receive context.
97 \param s The modem context.
98 \param put_bit The callback routine used to handle received bits.
99 \param user_data An opaque pointer. */
100 SPAN_DECLARE(void) v27ter_rx_set_put_bit(v27ter_rx_state_t *s, put_bit_func_t put_bit, void *user_data);
101
102 /*! Change the modem status report function associated with a V.27ter modem receive context.
103 \brief Change the modem status report function associated with a V.27ter modem receive context.
104 \param s The modem context.
105 \param handler The callback routine used to report modem status changes.
106 \param user_data An opaque pointer. */
107 SPAN_DECLARE(void) v27ter_rx_set_modem_status_handler(v27ter_rx_state_t *s, modem_rx_status_func_t handler, void *user_data);
108
109 /*! Process a block of received V.27ter modem audio samples.
110 \brief Process a block of received V.27ter modem audio samples.
111 \param s The modem context.
112 \param amp The audio sample buffer.
113 \param len The number of samples in the buffer.
114 \return The number of samples unprocessed.
115 */
116 SPAN_DECLARE_NONSTD(int) v27ter_rx(v27ter_rx_state_t *s, const int16_t amp[], int len);
117
118 /*! Fake processing of a missing block of received V.27ter modem audio samples.
119 (e.g due to packet loss).
120 \brief Fake processing of a missing block of received V.27ter modem audio samples.
121 \param s The modem context.
122 \param len The number of samples to fake.
123 \return The number of samples unprocessed.
124 */
125 SPAN_DECLARE(int) v27ter_rx_fillin(v27ter_rx_state_t *s, int len);
126
127 /*! Get a snapshot of the current equalizer coefficients.
128 \brief Get a snapshot of the current equalizer coefficients.
129 \param coeffs The vector of complex coefficients.
130 \return The number of coefficients in the vector. */
131 SPAN_DECLARE(int) v27ter_rx_equalizer_state(v27ter_rx_state_t *s, complexf_t **coeffs);
132
133 /*! Get the current received carrier frequency.
134 \param s The modem context.
135 \return The frequency, in Hertz. */
136 SPAN_DECLARE(float) v27ter_rx_carrier_frequency(v27ter_rx_state_t *s);
137
138 /*! Get the current symbol timing correction since startup.
139 \param s The modem context.
140 \return The correction. */
141 SPAN_DECLARE(float) v27ter_rx_symbol_timing_correction(v27ter_rx_state_t *s);
142
143 /*! Get a current received signal power.
144 \param s The modem context.
145 \return The signal power, in dBm0. */
146 SPAN_DECLARE(float) v27ter_rx_signal_power(v27ter_rx_state_t *s);
147
148 /*! Set the power level at which the carrier detection will cut in
149 \param s The modem context.
150 \param cutoff The signal cutoff power, in dBm0. */
151 SPAN_DECLARE(void) v27ter_rx_signal_cutoff(v27ter_rx_state_t *s, float cutoff);
152
153 /*! Set a handler routine to process QAM status reports
154 \param s The modem context.
155 \param handler The handler routine.
156 \param user_data An opaque pointer passed to the handler routine. */
157 SPAN_DECLARE(void) v27ter_rx_set_qam_report_handler(v27ter_rx_state_t *s, qam_report_handler_t handler, void *user_data);
158
159 #if defined(__cplusplus)
160 }
161 #endif
162
163 #endif
164 /*- End of file ------------------------------------------------------------*/

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