00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * v32bis.h - ITU V.32bis modem 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2008 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 * $Id: v32bis.h,v 1.1 2008/05/02 14:26:39 steveu Exp $ 00026 */ 00027 00028 /*! \file */ 00029 00030 /*! \page v32bis_page The V.32bis modem 00031 \section v32bis_page_sec_1 What does it do? 00032 00033 \section v32bis__page_sec_2 How does it work? 00034 */ 00035 00036 #if !defined(_V32BIS_H_) 00037 #define _V32BIS_H_ 00038 00039 /*! 00040 V.32bis modem descriptor. This defines the working state for a single instance 00041 of a V.32bis modem. 00042 */ 00043 typedef struct 00044 { 00045 /*! \brief The bit rate of the modem. Valid values are 1200 and 2400. */ 00046 int bit_rate; 00047 /*! \brief TRUE is this is the calling side modem. */ 00048 int caller; 00049 00050 v17_rx_state_t rx; 00051 v17_tx_state_t tx; 00052 00053 /*! \brief Error and flow logging control */ 00054 logging_state_t logging; 00055 } v32bis_state_t; 00056 00057 extern const complexf_t v32bis_constellation[16]; 00058 00059 #if defined(__cplusplus) 00060 extern "C" 00061 { 00062 #endif 00063 00064 /*! Reinitialise an existing V.32bis modem receive context. 00065 \brief Reinitialise an existing V.32bis modem receive context. 00066 \param s The modem context. 00067 \param bit_rate The bit rate of the modem. Valid values are 1200 and 2400. 00068 \return 0 for OK, -1 for bad parameter */ 00069 int v32bis_rx_restart(v32bis_state_t *s, int bit_rate); 00070 00071 /*! Process a block of received V.32bis modem audio samples. 00072 \brief Process a block of received V.32bis modem audio samples. 00073 \param s The modem context. 00074 \param amp The audio sample buffer. 00075 \param len The number of samples in the buffer. 00076 \return The number of samples unprocessed. */ 00077 int v32bis_rx(v32bis_state_t *s, const int16_t amp[], int len); 00078 00079 /*! Get a snapshot of the current equalizer coefficients. 00080 \brief Get a snapshot of the current equalizer coefficients. 00081 \param coeffs The vector of complex coefficients. 00082 \return The number of coefficients in the vector. */ 00083 int v32bis_equalizer_state(v32bis_state_t *s, complexf_t **coeffs); 00084 00085 /*! Get the current received carrier frequency. 00086 \param s The modem context. 00087 \return The frequency, in Hertz. */ 00088 float v32bis_rx_carrier_frequency(v32bis_state_t *s); 00089 00090 /*! Get the current symbol timing correction since startup. 00091 \param s The modem context. 00092 \return The correction. */ 00093 float v32bis_symbol_timing_correction(v32bis_state_t *s); 00094 00095 /*! Get a current received signal power. 00096 \param s The modem context. 00097 \return The signal power, in dBm0. */ 00098 float v32bis_rx_signal_power(v32bis_state_t *s); 00099 00100 /*! Set the power level at which the carrier detection will cut in 00101 \param s The modem context. 00102 \param cutoff The signal cutoff power, in dBm0. */ 00103 void v32bis_rx_signal_cutoff(v32bis_state_t *s, float cutoff); 00104 00105 /*! Set a handler routine to process QAM status reports 00106 \param s The modem context. 00107 \param handler The handler routine. 00108 \param user_data An opaque pointer passed to the handler routine. */ 00109 void v32bis_set_qam_report_handler(v32bis_state_t *s, qam_report_handler_t *handler, void *user_data); 00110 00111 /*! Generate a block of V.32bis modem audio samples. 00112 \brief Generate a block of V.32bis modem audio samples. 00113 \param s The modem context. 00114 \param amp The audio sample buffer. 00115 \param len The number of samples to be generated. 00116 \return The number of samples actually generated. */ 00117 int v32bis_tx(v32bis_state_t *s, int16_t amp[], int len); 00118 00119 /*! Adjust a V.32bis modem transmit context's power output. 00120 \brief Adjust a V.32bis modem transmit context's output power. 00121 \param s The modem context. 00122 \param power The power level, in dBm0 */ 00123 void v32bis_tx_power(v32bis_state_t *s, float power); 00124 00125 /*! Reinitialise an existing V.32bis modem context, so it may be reused. 00126 \brief Reinitialise an existing V.32bis modem context. 00127 \param s The modem context. 00128 \param bit_rate The bit rate of the modem. Valid values are 4800, 7200, 9600, 12000 and 14400. 00129 \return 0 for OK, -1 for bad parameter */ 00130 int v32bis_restart(v32bis_state_t *s, int bit_rate); 00131 00132 /*! Initialise a V.32bis modem context. This must be called before the first 00133 use of the context, to initialise its contents. 00134 \brief Initialise a V.32bis modem context. 00135 \param s The modem context. 00136 \param bit_rate The bit rate of the modem. Valid values are 4800, 7200, 9600, 12000 and 14400. 00137 \param caller TRUE if this is the calling modem. 00138 \param get_bit The callback routine used to get the data to be transmitted. 00139 \param put_bit The callback routine used to get the data to be transmitted. 00140 \param user_data An opaque pointer, passed in calls to the get and put routines. 00141 \return A pointer to the modem context, or NULL if there was a problem. */ 00142 v32bis_state_t *v32bis_init(v32bis_state_t *s, 00143 int bit_rate, 00144 int caller, 00145 get_bit_func_t get_bit, 00146 put_bit_func_t put_bit, 00147 void *user_data); 00148 00149 /*! Free a V.32bis modem receive context. 00150 \brief Free a V.32bis modem receive context. 00151 \param s The modem context. 00152 \return 0 for OK */ 00153 int v32bis_free(v32bis_state_t *s); 00154 00155 /*! Change the get_bit function associated with a V.32bis modem context. 00156 \brief Change the get_bit function associated with a V.32bis modem context. 00157 \param s The modem context. 00158 \param get_bit The callback routine used to get the data to be transmitted. 00159 \param user_data An opaque pointer. */ 00160 void v32bis_set_get_bit(v32bis_state_t *s, get_bit_func_t get_bit, void *user_data); 00161 00162 /*! Change the get_bit function associated with a V.32bis modem context. 00163 \brief Change the put_bit function associated with a V.32bis modem context. 00164 \param s The modem context. 00165 \param put_bit The callback routine used to process the data received. 00166 \param user_data An opaque pointer. */ 00167 void v32bis_set_put_bit(v32bis_state_t *s, put_bit_func_t put_bit, void *user_data); 00168 00169 #if defined(__cplusplus) 00170 } 00171 #endif 00172 00173 #endif 00174 /*- End of file ------------------------------------------------------------*/