line_model.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * line_model.h - Model a telephone line.
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2004 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 General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025  *
00026  * $Id: line_model.h,v 1.5 2005/12/29 12:46:20 steveu Exp $
00027  */
00028 
00029 /*! \file */
00030 
00031 /*! \page line_model_page Telephone line model
00032 \section line_model_page_sec_1 What does it do?
00033 The telephone line modelling module provides simple modelling of one way and two
00034 way telephone lines.
00035 
00036 The path being modelled is:
00037 
00038     -    terminal
00039     -      | < hybrid echo (2-way models)
00040     -      |
00041     -      | < noise and filtering
00042     -      |
00043     -      | < hybrid echo (2-way models)
00044     -     CO
00045     -      |
00046     -      | < A-law distortion + bulk delay
00047     -      |
00048     -     CO
00049     -      | < hybrid echo (2-way models)
00050     -      |
00051     -      | < noise and filtering
00052     -      |
00053     -      | < hybrid echo (2-way models)
00054     -    terminal
00055 */
00056 
00057 #if !defined(_LINE_MODEL_H_)
00058 #define _LINE_MODEL_H_
00059 
00060 #define LINE_FILTER_SIZE 129
00061 
00062 /*!
00063     One way line model descriptor. This holds the complete state of
00064     a line model with transmission in only one direction.
00065 */
00066 typedef struct
00067 {
00068     int alaw_munge;
00069     int ulaw_munge;
00070 
00071     /*! The coefficients for the near end analogue section simulation filter */
00072     float *near_filter;
00073     /*! The number of coefficients for the near end analogue section simulation filter */
00074     int near_filter_len;
00075     /*! Last transmitted samples (ring buffer, used by the line filter) */
00076     float near_buf[LINE_FILTER_SIZE];
00077     /*! Pointer of the last transmitted sample in buf */
00078     int near_buf_ptr;
00079     /*! The noise source for local analogue section of the line */
00080     awgn_state_t near_noise;
00081 
00082     /*! The bulk delay of the path, in samples */
00083     int bulk_delay;
00084     /*! A pointer to the current write position in the bulk delay store. */
00085     int bulk_delay_ptr;
00086     /*! The data store for simulating the bulk delay */
00087     int16_t bulk_delay_buf[8000];
00088 
00089     /*! The coefficients for the far end analogue section simulation filter */
00090     float *far_filter;
00091     /*! The number of coefficients for the far end analogue section simulation filter */
00092     int far_filter_len;
00093     /*! Last transmitted samples (ring buffer, used by the line filter) */
00094     float far_buf[LINE_FILTER_SIZE];
00095     /*! Pointer of the last transmitted sample in buf */
00096     int far_buf_ptr;
00097     /*! The noise source for distant analogue section of the line */
00098     awgn_state_t far_noise;
00099 
00100     /*! The scaling factor for the local CPE hybrid echo */
00101     float near_cpe_hybrid_echo;
00102     /*! The scaling factor for the local CO hybrid echo */
00103     float near_co_hybrid_echo;
00104 
00105     /*! The scaling factor for the far CPE hybrid echo */
00106     float far_cpe_hybrid_echo;
00107     /*! The scaling factor for the far CO hybrid echo */
00108     float far_co_hybrid_echo;
00109 } one_way_line_model_state_t;
00110 
00111 /*!
00112     Two way line model descriptor. This holds the complete state of
00113     a line model with transmission in both directions.
00114 */
00115 typedef struct
00116 {
00117     one_way_line_model_state_t line1;
00118     one_way_line_model_state_t line2;
00119     float fout1;
00120     float fout2; 
00121 } both_ways_line_model_state_t;
00122 
00123 #ifdef __cplusplus
00124 extern "C" {
00125 #endif
00126 
00127 void both_ways_line_model(both_ways_line_model_state_t *s, 
00128                           int16_t *output1,
00129                           const int16_t *input1,
00130                           int16_t *output2,
00131                           const int16_t *input2,
00132                           int samples);
00133 
00134 both_ways_line_model_state_t *both_ways_line_model_init(int model1,
00135                                                         int noise1,
00136                                                         int model2,
00137                                                         int noise2);
00138 
00139 int both_ways_line_model_release(both_ways_line_model_state_t *s);
00140 
00141 void one_way_line_model(one_way_line_model_state_t *s, 
00142                         int16_t *output,
00143                         const int16_t *input,
00144                         int samples);
00145 
00146 one_way_line_model_state_t *one_way_line_model_init(int model, int noise);
00147 
00148 int one_way_line_model_release(one_way_line_model_state_t *s);
00149 
00150 #ifdef __cplusplus
00151 }
00152 #endif
00153 
00154 #endif
00155 /*- End of file ------------------------------------------------------------*/

Generated on Fri Nov 10 09:40:24 2006 for libspandsp by  doxygen 1.5.1