00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * bell_r2_mf.h - Bell MF and MFC/R2 tone generation and detection. 00005 * 00006 * Written by Steve Underwood <steveu@coppice.org> 00007 * 00008 * Copyright (C) 2001 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: bell_r2_mf.h,v 1.2 2008/10/13 14:19:18 steveu Exp $ 00026 */ 00027 00028 #if !defined(_SPANDSP_PRIVATE_BELL_R2_MF_H_) 00029 #define _SPANDSP_PRIVATE_BELL_R2_MF_H_ 00030 00031 /*! 00032 Bell MF generator state descriptor. This defines the state of a single 00033 working instance of a Bell MF generator. 00034 */ 00035 struct bell_mf_tx_state_s 00036 { 00037 /*! The tone generator. */ 00038 tone_gen_state_t tones; 00039 int current_sample; 00040 union 00041 { 00042 queue_state_t queue; 00043 uint8_t buf[QUEUE_STATE_T_SIZE(MAX_BELL_MF_DIGITS)]; 00044 } queue; 00045 }; 00046 00047 /*! 00048 Bell MF digit detector descriptor. 00049 */ 00050 struct bell_mf_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 /*! Tone detector working states */ 00057 goertzel_state_t out[6]; 00058 /*! Short term history of results from the tone detection, using in persistence checking */ 00059 uint8_t hits[5]; 00060 /*! The current sample number within a processing block. */ 00061 int current_sample; 00062 00063 /*! The number of digits which have been lost due to buffer overflows. */ 00064 int lost_digits; 00065 /*! The number of digits currently in the digit buffer. */ 00066 int current_digits; 00067 /*! The received digits buffer. This is a NULL terminated string. */ 00068 char digits[MAX_BELL_MF_DIGITS + 1]; 00069 }; 00070 00071 /*! 00072 MFC/R2 tone detector descriptor. 00073 */ 00074 struct r2_mf_tx_state_s 00075 { 00076 /*! The tone generator. */ 00077 tone_gen_state_t tone; 00078 /*! TRUE if generating forward tones, otherwise generating reverse tones. */ 00079 int fwd; 00080 /*! The current digit being generated. */ 00081 int digit; 00082 }; 00083 00084 /*! 00085 MFC/R2 tone detector descriptor. 00086 */ 00087 struct r2_mf_rx_state_s 00088 { 00089 /*! Optional callback funcion to deliver received digits. */ 00090 tone_report_func_t callback; 00091 /*! An opaque pointer passed to the callback function. */ 00092 void *callback_data; 00093 /*! TRUE is we are detecting forward tones. FALSE if we are detecting backward tones */ 00094 int fwd; 00095 /*! Tone detector working states */ 00096 goertzel_state_t out[6]; 00097 /*! The current sample number within a processing block. */ 00098 int current_sample; 00099 /*! The currently detected digit. */ 00100 int current_digit; 00101 }; 00102 00103 #endif 00104 /*- End of file ------------------------------------------------------------*/