private/dtmf.h

00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * private/dtmf.h - DTMF tone generation and detection 
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2001, 2005 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 
00026 #if !defined(_SPANDSP_PRIVATE_DTMF_H_)
00027 #define _SPANDSP_PRIVATE_DTMF_H_
00028 
00029 /*!
00030     DTMF generator state descriptor. This defines the state of a single
00031     working instance of a DTMF generator.
00032 */
00033 struct dtmf_tx_state_s
00034 {
00035     tone_gen_state_t tones;
00036     float low_level;
00037     float high_level;
00038     int on_time;
00039     int off_time;
00040     union
00041     {
00042         queue_state_t queue;
00043         uint8_t buf[QUEUE_STATE_T_SIZE(MAX_DTMF_DIGITS)];
00044     } queue;
00045 };
00046 
00047 /*!
00048     DTMF digit detector descriptor.
00049 */
00050 struct dtmf_rx_state_s
00051 {
00052     /*! Optional callback funcion to deliver received digits. */
00053     digits_rx_callback_t digits_callback;
00054     /*! An opaque pointer passed to the callback function. */
00055     void *digits_callback_data;
00056     /*! Optional callback funcion to deliver real time digit state changes. */
00057     tone_report_func_t realtime_callback;
00058     /*! An opaque pointer passed to the real time callback function. */
00059     void *realtime_callback_data;
00060     /*! TRUE if dialtone should be filtered before processing */
00061     int filter_dialtone;
00062 #if defined(SPANDSP_USE_FIXED_POINT)
00063     /*! 350Hz filter state for the optional dialtone filter. */
00064     float z350[2];
00065     /*! 440Hz filter state for the optional dialtone filter. */
00066     float z440[2];
00067     /*! Maximum acceptable "normal" (lower bigger than higher) twist ratio. */
00068     float normal_twist;
00069     /*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio. */
00070     float reverse_twist;
00071     /*! Minimum acceptable tone level for detection. */
00072     int32_t threshold;
00073     /*! The accumlating total energy on the same period over which the Goertzels work. */
00074     int32_t energy;
00075 #else
00076     /*! 350Hz filter state for the optional dialtone filter. */
00077     float z350[2];
00078     /*! 440Hz filter state for the optional dialtone filter. */
00079     float z440[2];
00080     /*! Maximum acceptable "normal" (lower bigger than higher) twist ratio. */
00081     float normal_twist;
00082     /*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio. */
00083     float reverse_twist;
00084     /*! Minimum acceptable tone level for detection. */
00085     float threshold;
00086     /*! The accumlating total energy on the same period over which the Goertzels work. */
00087     float energy;
00088 #endif
00089     /*! Tone detector working states for the row tones. */
00090     goertzel_state_t row_out[4];
00091     /*! Tone detector working states for the column tones. */
00092     goertzel_state_t col_out[4];
00093     /*! The result of the last tone analysis. */
00094     uint8_t last_hit;
00095     /*! The confirmed digit we are currently receiving */
00096     uint8_t in_digit;
00097     /*! The current sample number within a processing block. */
00098     int current_sample;
00099 
00100     /*! The number of digits which have been lost due to buffer overflows. */
00101     int lost_digits;
00102     /*! The number of digits currently in the digit buffer. */
00103     int current_digits;
00104     /*! The received digits buffer. This is a NULL terminated string. */
00105     char digits[MAX_DTMF_DIGITS + 1];
00106 };
00107 
00108 #endif
00109 /*- End of file ------------------------------------------------------------*/

Generated on Thu Dec 9 21:11:49 2010 for spandsp by  doxygen 1.5.9