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

Generated on Tue Aug 4 03:35:56 2009 for spandsp by  doxygen 1.5.9