Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/spandsp-sim/spandsp/line_model.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 * line_model.h - Model a telephone line. | |
| 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 * $Id: line_model.h,v 1.7.4.1 2009/12/19 10:16:44 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 /*! \page line_model_page Telephone line model | |
| 31 \section line_model_page_sec_1 What does it do? | |
| 32 The telephone line modelling module provides simple modelling of one way and two | |
| 33 way telephone lines. | |
| 34 | |
| 35 The path being modelled is: | |
| 36 | |
| 37 - terminal | |
| 38 - | < hybrid echo (2-way models) | |
| 39 - | | |
| 40 - | < noise and filtering | |
| 41 - | | |
| 42 - | < hybrid echo (2-way models) | |
| 43 - CO | |
| 44 - | | |
| 45 - | < A-law distortion + bulk delay | |
| 46 - | | |
| 47 - CO | |
| 48 - | < hybrid echo (2-way models) | |
| 49 - | | |
| 50 - | < noise and filtering | |
| 51 - | | |
| 52 - | < hybrid echo (2-way models) | |
| 53 - terminal | |
| 54 */ | |
| 55 | |
| 56 #if !defined(_SPANDSP_LINE_MODEL_H_) | |
| 57 #define _SPANDSP_LINE_MODEL_H_ | |
| 58 | |
| 59 #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES | |
| 60 #include <spandsp.h> | |
| 61 | |
| 62 #define LINE_FILTER_SIZE 129 | |
| 63 | |
| 64 /*! | |
| 65 One way line model descriptor. This holds the complete state of | |
| 66 a line model with transmission in only one direction. | |
| 67 */ | |
| 68 typedef struct | |
| 69 { | |
| 70 codec_munge_state_t *munge; | |
| 71 | |
| 72 /*! The coefficients for the near end analogue section simulation filter */ | |
| 73 const float *near_filter; | |
| 74 /*! The number of coefficients for the near end analogue section simulation filter */ | |
| 75 int near_filter_len; | |
| 76 /*! Last transmitted samples (ring buffer, used by the line filter) */ | |
| 77 float near_buf[LINE_FILTER_SIZE]; | |
| 78 /*! Pointer of the last transmitted sample in buf */ | |
| 79 int near_buf_ptr; | |
| 80 /*! The noise source for local analogue section of the line */ | |
| 81 awgn_state_t near_noise; | |
| 82 | |
| 83 /*! The bulk delay of the path, in samples */ | |
| 84 int bulk_delay; | |
| 85 /*! A pointer to the current write position in the bulk delay store. */ | |
| 86 int bulk_delay_ptr; | |
| 87 /*! The data store for simulating the bulk delay */ | |
| 88 int16_t bulk_delay_buf[8000]; | |
| 89 | |
| 90 /*! The coefficients for the far end analogue section simulation filter */ | |
| 91 const float *far_filter; | |
| 92 /*! The number of coefficients for the far end analogue section simulation filter */ | |
| 93 int far_filter_len; | |
| 94 /*! Last transmitted samples (ring buffer, used by the line filter) */ | |
| 95 float far_buf[LINE_FILTER_SIZE]; | |
| 96 /*! Pointer of the last transmitted sample in buf */ | |
| 97 int far_buf_ptr; | |
| 98 /*! The noise source for distant analogue section of the line */ | |
| 99 awgn_state_t far_noise; | |
| 100 | |
| 101 /*! The scaling factor for the local CPE hybrid echo */ | |
| 102 float near_cpe_hybrid_echo; | |
| 103 /*! The scaling factor for the local CO hybrid echo */ | |
| 104 float near_co_hybrid_echo; | |
| 105 | |
| 106 /*! The scaling factor for the far CPE hybrid echo */ | |
| 107 float far_cpe_hybrid_echo; | |
| 108 /*! The scaling factor for the far CO hybrid echo */ | |
| 109 float far_co_hybrid_echo; | |
| 110 /*! DC offset impairment */ | |
| 111 float dc_offset; | |
| 112 | |
| 113 /*! Mains pickup impairment */ | |
| 114 int mains_interference; | |
| 115 tone_gen_state_t mains_tone; | |
| 116 } one_way_line_model_state_t; | |
| 117 | |
| 118 /*! | |
| 119 Two way line model descriptor. This holds the complete state of | |
| 120 a line model with transmission in both directions. | |
| 121 */ | |
| 122 typedef struct | |
| 123 { | |
| 124 one_way_line_model_state_t line1; | |
| 125 one_way_line_model_state_t line2; | |
| 126 float fout1; | |
| 127 float fout2; | |
| 128 } both_ways_line_model_state_t; | |
| 129 | |
| 130 #ifdef __cplusplus | |
| 131 extern "C" | |
| 132 { | |
| 133 #endif | |
| 134 | |
| 135 SPAN_DECLARE_DATA extern const float *line_models[]; | |
| 136 | |
| 137 SPAN_DECLARE(void) both_ways_line_model(both_ways_line_model_state_t *s, | |
| 138 int16_t output1[], | |
| 139 const int16_t input1[], | |
| 140 int16_t output2[], | |
| 141 const int16_t input2[], | |
| 142 int samples); | |
| 143 | |
| 144 SPAN_DECLARE(void) both_ways_line_model_set_dc(both_ways_line_model_state_t *s, float dc1, float dc2); | |
| 145 | |
| 146 SPAN_DECLARE(void) both_ways_line_model_set_mains_pickup(both_ways_line_model_state_t *s, int f, float level1, float level2); | |
| 147 | |
| 148 SPAN_DECLARE(both_ways_line_model_state_t *) both_ways_line_model_init(int model1, | |
| 149 float noise1, | |
| 150 int model2, | |
| 151 float noise2, | |
| 152 int codec, | |
| 153 int rbs_pattern); | |
| 154 | |
| 155 SPAN_DECLARE(int) both_ways_line_model_release(both_ways_line_model_state_t *s); | |
| 156 | |
| 157 SPAN_DECLARE(void) one_way_line_model(one_way_line_model_state_t *s, | |
| 158 int16_t output[], | |
| 159 const int16_t input[], | |
| 160 int samples); | |
| 161 | |
| 162 SPAN_DECLARE(void) one_way_line_model_set_dc(one_way_line_model_state_t *s, float dc); | |
| 163 | |
| 164 SPAN_DECLARE(void) one_way_line_model_set_mains_pickup(one_way_line_model_state_t *s, int f, float level); | |
| 165 | |
| 166 SPAN_DECLARE(one_way_line_model_state_t *) one_way_line_model_init(int model, float noise, int codec, int rbs_pattern); | |
| 167 | |
| 168 SPAN_DECLARE(int) one_way_line_model_release(one_way_line_model_state_t *s); | |
| 169 | |
| 170 #ifdef __cplusplus | |
| 171 } | |
| 172 #endif | |
| 173 | |
| 174 #endif | |
| 175 /*- End of file ------------------------------------------------------------*/ |
