private/sig_tone.h

00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * private/sig_tone.h - Signalling tone processing for the 2280Hz, 2400Hz, 2600Hz
00005  *                      and similar signalling tone used in older protocols.
00006  *
00007  * Written by Steve Underwood <steveu@coppice.org>
00008  *
00009  * Copyright (C) 2004 Steve Underwood
00010  *
00011  * All rights reserved.
00012  *
00013  * This program is free software; you can redistribute it and/or modify
00014  * it under the terms of the GNU Lesser General Public License version 2.1,
00015  * as published by the Free Software Foundation.
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 Lesser General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU Lesser General Public
00023  * License along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025  *
00026  * $Id: sig_tone.h,v 1.1 2008/11/30 13:08:42 steveu Exp $
00027  */
00028 
00029 #if !defined(_SPANDSP_PRIVATE_SIG_TONE_H_)
00030 #define _SPANDSP_PRIVATE_SIG_TONE_H_
00031 
00032 /*!
00033     Signaling tone descriptor. This defines the working state for a
00034     single instance of the transmit and receive sides of a signaling
00035     tone processor.
00036 */
00037 struct sig_tone_descriptor_s
00038 {
00039     /*! \brief The tones used. */
00040     int tone_freq[2];
00041     /*! \brief The high and low tone amplitudes. */
00042     int tone_amp[2];
00043 
00044     /*! \brief The delay, in audio samples, before the high level tone drops
00045                to a low level tone. */
00046     int high_low_timeout;
00047 
00048     /*! \brief Some signaling tone detectors use a sharp initial filter,
00049                changing to a broader band filter after some delay. This
00050                parameter defines the delay. 0 means it never changes. */
00051     int sharp_flat_timeout;
00052 
00053     /*! \brief Parameters to control the behaviour of the notch filter, used
00054                to remove the tone from the voice path in some protocols. */
00055     int notch_lag_time;
00056     int notch_allowed;
00057 
00058     /*! \brief The tone on persistence check, in audio samples. */
00059     int tone_on_check_time;
00060     /*! \brief The tone off persistence check, in audio samples. */
00061     int tone_off_check_time;
00062 
00063     int tones;
00064     /*! \brief The coefficients for the cascaded bi-quads notch filter. */
00065     struct
00066     {
00067 #if defined(SPANDSP_USE_FIXED_POINT)
00068         int32_t notch_a1[3];
00069         int32_t notch_b1[3];
00070         int32_t notch_a2[3];
00071         int32_t notch_b2[3];
00072         int notch_postscale;
00073 #else
00074         float notch_a1[3];
00075         float notch_b1[3];
00076         float notch_a2[3];
00077         float notch_b2[3];
00078 #endif
00079     } tone[2];
00080 
00081 
00082     /*! \brief Flat mode bandpass bi-quad parameters */
00083 #if defined(SPANDSP_USE_FIXED_POINT)
00084     int32_t broad_a[3];
00085     int32_t broad_b[3];
00086     int broad_postscale;
00087 #else
00088     float broad_a[3];
00089     float broad_b[3];
00090 #endif
00091     /*! \brief The coefficients for the post notch leaky integrator. */
00092     int32_t notch_slugi;
00093     int32_t notch_slugp;
00094 
00095     /*! \brief The coefficients for the post modulus leaky integrator in the
00096                unfiltered data path.  The prescale value incorporates the
00097                detection ratio. This is called the guard ratio in some
00098                protocols. */
00099     int32_t unfiltered_slugi;
00100     int32_t unfiltered_slugp;
00101 
00102     /*! \brief The coefficients for the post modulus leaky integrator in the
00103                bandpass filter data path. */
00104     int32_t broad_slugi;
00105     int32_t broad_slugp;
00106 
00107     /*! \brief Masks which effectively threshold the notched, weighted and
00108                bandpassed data. */
00109     int32_t notch_threshold;
00110     int32_t unfiltered_threshold;
00111     int32_t broad_threshold;
00112 };
00113 
00114 struct sig_tone_tx_state_s
00115 {
00116     /*! \brief The callback function used to handle signaling changes. */
00117     sig_tone_func_t sig_update;
00118     /*! \brief A user specified opaque pointer passed to the callback function. */
00119     void *user_data;
00120 
00121     sig_tone_descriptor_t *desc;
00122 
00123     /*! The scaling values for the high and low level tones */
00124     int32_t tone_scaling[2];
00125     /*! The sample timer, used to switch between the high and low level tones. */
00126     int high_low_timer;
00127 
00128     /*! The phase rates for the one or two tones */
00129     int32_t phase_rate[2];
00130     /*! The phase accumulators for the one or two tones */
00131     uint32_t phase_acc[2];
00132 
00133     int current_tx_tone;
00134     int current_tx_timeout;
00135     int signaling_state_duration;
00136 };
00137 
00138 struct sig_tone_rx_state_s
00139 {
00140     /*! \brief The callback function used to handle signaling changes. */
00141     sig_tone_func_t sig_update;
00142     /*! \brief A user specified opaque pointer passed to the callback function. */
00143     void *user_data;
00144 
00145     sig_tone_descriptor_t *desc;
00146 
00147     int current_rx_tone;
00148     int high_low_timer;
00149 
00150     struct
00151     {
00152         /*! \brief The z's for the notch filter */
00153 #if defined(SPANDSP_USE_FIXED_POINT)
00154         int32_t notch_z1[3];
00155         int32_t notch_z2[3];
00156 #else
00157         float notch_z1[3];
00158         float notch_z2[3];
00159 #endif
00160 
00161         /*! \brief The z's for the notch integrators. */
00162         int32_t notch_zl;
00163     } tone[2];
00164 
00165     /*! \brief The z's for the weighting/bandpass filter. */
00166 #if defined(SPANDSP_USE_FIXED_POINT)
00167     int32_t broad_z[3];
00168 #else
00169     float broad_z[3];
00170 #endif
00171     /*! \brief The z for the broadband integrator. */
00172     int32_t broad_zl;
00173 
00174     int flat_mode;
00175     int tone_present;
00176     int notch_enabled;
00177     int flat_mode_timeout;
00178     int notch_insertion_timeout;
00179     int tone_persistence_timeout;
00180     
00181     int signaling_state_duration;
00182 };
00183 
00184 #endif
00185 /*- End of file ------------------------------------------------------------*/

Generated on Thu Feb 12 14:16:07 2009 for spandsp by  doxygen 1.5.5