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.3 2009/04/12 14:18:02 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     /*! \brief TRUE if the notch may be used in the media flow. */
00057     int notch_allowed;
00058 
00059     /*! \brief The tone on persistence check, in audio samples. */
00060     int tone_on_check_time;
00061     /*! \brief The tone off persistence check, in audio samples. */
00062     int tone_off_check_time;
00063 
00064     /*! \brief ??? */
00065     int tones;
00066     /*! \brief The coefficients for the cascaded bi-quads notch filter. */
00067     struct
00068     {
00069 #if defined(SPANDSP_USE_FIXED_POINT)
00070         int32_t notch_a1[3];
00071         int32_t notch_b1[3];
00072         int32_t notch_a2[3];
00073         int32_t notch_b2[3];
00074         int notch_postscale;
00075 #else
00076         float notch_a1[3];
00077         float notch_b1[3];
00078         float notch_a2[3];
00079         float notch_b2[3];
00080 #endif
00081     } tone[2];
00082 
00083 
00084 #if defined(SPANDSP_USE_FIXED_POINT)
00085     /*! \brief Flat mode bandpass bi-quad parameters */
00086     int32_t broad_a[3];
00087     /*! \brief Flat mode bandpass bi-quad parameters */
00088     int32_t broad_b[3];
00089     /*! \brief Post filter scaling */
00090     int broad_postscale;
00091 #else
00092     /*! \brief Flat mode bandpass bi-quad parameters */
00093     float broad_a[3];
00094     /*! \brief Flat mode bandpass bi-quad parameters */
00095     float broad_b[3];
00096 #endif
00097     /*! \brief The coefficients for the post notch leaky integrator. */
00098     int32_t notch_slugi;
00099     /*! \brief ??? */
00100     int32_t notch_slugp;
00101 
00102     /*! \brief The coefficients for the post modulus leaky integrator in the
00103                unfiltered data path.  The prescale value incorporates the
00104                detection ratio. This is called the guard ratio in some
00105                protocols. */
00106     int32_t unfiltered_slugi;
00107     /*! \brief ??? */
00108     int32_t unfiltered_slugp;
00109 
00110     /*! \brief The coefficients for the post modulus leaky integrator in the
00111                bandpass filter data path. */
00112     int32_t broad_slugi;
00113     /*! \brief ??? */
00114     int32_t broad_slugp;
00115 
00116     /*! \brief Masks which effectively threshold the notched, weighted and
00117                bandpassed data. */
00118     int32_t notch_threshold;
00119     /*! \brief ??? */
00120     int32_t unfiltered_threshold;
00121     /*! \brief ??? */
00122     int32_t broad_threshold;
00123 };
00124 
00125 /*!
00126     Signaling tone transmit state
00127  */
00128 struct sig_tone_tx_state_s
00129 {
00130     /*! \brief The callback function used to handle signaling changes. */
00131     sig_tone_func_t sig_update;
00132     /*! \brief A user specified opaque pointer passed to the callback function. */
00133     void *user_data;
00134 
00135     /*! \brief Tone descriptor */
00136     sig_tone_descriptor_t *desc;
00137 
00138     /*! The scaling values for the high and low level tones */
00139     int16_t tone_scaling[2];
00140     /*! The sample timer, used to switch between the high and low level tones. */
00141     int high_low_timer;
00142 
00143     /*! The phase rates for the one or two tones */
00144     int32_t phase_rate[2];
00145     /*! The phase accumulators for the one or two tones */
00146     uint32_t phase_acc[2];
00147 
00148     /*! \brief Current transmit tone */
00149     int current_tx_tone;
00150     /*! \brief Current transmit timeout */
00151     int current_tx_timeout;
00152     /*! \brief Time in current signaling state, in samples. */
00153     int signaling_state_duration;
00154 };
00155 
00156 /*!
00157     Signaling tone receive state
00158  */
00159 struct sig_tone_rx_state_s
00160 {
00161     /*! \brief The callback function used to handle signaling changes. */
00162     sig_tone_func_t sig_update;
00163     /*! \brief A user specified opaque pointer passed to the callback function. */
00164     void *user_data;
00165 
00166     /*! \brief Tone descriptor */
00167     sig_tone_descriptor_t *desc;
00168 
00169     /*! \brief The current receive tone */
00170     int current_rx_tone;
00171     /*! \brief The timeout for switching from the high level to low level tone detector. */
00172     int high_low_timer;
00173 
00174     struct
00175     {
00176 #if defined(SPANDSP_USE_FIXED_POINT)
00177         /*! \brief The z's for the notch filter */
00178         int32_t notch_z1[3];
00179         /*! \brief The z's for the notch filter */
00180         int32_t notch_z2[3];
00181 #else
00182         /*! \brief The z's for the notch filter */
00183         float notch_z1[3];
00184         /*! \brief The z's for the notch filter */
00185         float notch_z2[3];
00186 #endif
00187 
00188         /*! \brief The z's for the notch integrators. */
00189         int32_t notch_zl;
00190     } tone[2];
00191 
00192 #if defined(SPANDSP_USE_FIXED_POINT)
00193     /*! \brief The z's for the weighting/bandpass filter. */
00194     int32_t broad_z[3];
00195 #else
00196     /*! \brief The z's for the weighting/bandpass filter. */
00197     float broad_z[3];
00198 #endif
00199     /*! \brief The z for the broadband integrator. */
00200     int32_t broad_zl;
00201 
00202     /*! \brief ??? */
00203     int flat_mode;
00204     /*! \brief ??? */
00205     int tone_present;
00206     /*! \brief ??? */
00207     int notch_enabled;
00208     /*! \brief ??? */
00209     int flat_mode_timeout;
00210     /*! \brief ??? */
00211     int notch_insertion_timeout;
00212     /*! \brief ??? */
00213     int tone_persistence_timeout;
00214     
00215     /*! \brief ??? */
00216     int signaling_state_duration;
00217 };
00218 
00219 #endif
00220 /*- End of file ------------------------------------------------------------*/

Generated by  doxygen 1.6.2