1 /* 2 * SpanDSP - a series of DSP components for telephony 3 * 4 * bell_r2_mf.h - Bell MF and MFC/R2 tone generation and detection. 5 * 6 * Written by Steve Underwood <steveu@coppice.org> 7 * 8 * Copyright (C) 2001 Steve Underwood 9 * 10 * All rights reserved. 11 * 12 * This program is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU Lesser General Public License version 2.1, 14 * as published by the Free Software Foundation. 15 * 16 * This program is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this program; if not, write to the Free Software 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24 */ 25 26 #if !defined(_SPANDSP_PRIVATE_BELL_R2_MF_H_) 27 #define _SPANDSP_PRIVATE_BELL_R2_MF_H_ 28 29 /*! 30 Bell MF generator state descriptor. This defines the state of a single 31 working instance of a Bell MF generator. 32 */ 33 struct bell_mf_tx_state_s 34 { 35 /*! The tone generator. */ 36 tone_gen_state_t tones; 37 int current_sample; 38 union 39 { 40 queue_state_t queue; 41 uint8_t buf[QUEUE_STATE_T_SIZE(MAX_BELL_MF_DIGITS)]; 42 } queue; 43 }; 44 45 /*! 46 Bell MF digit detector descriptor. 47 */ 48 struct bell_mf_rx_state_s 49 { 50 /*! Optional callback funcion to deliver received digits. */ 51 digits_rx_callback_t digits_callback; 52 /*! An opaque pointer passed to the callback function. */ 53 void *digits_callback_data; 54 /*! Tone detector working states */ 55 goertzel_state_t out[6]; 56 /*! Short term history of results from the tone detection, using in persistence checking */ 57 uint8_t hits[5]; 58 /*! The current sample number within a processing block. */ 59 int current_sample; 60 61 /*! The number of digits which have been lost due to buffer overflows. */ 62 int lost_digits; 63 /*! The number of digits currently in the digit buffer. */ 64 int current_digits; 65 /*! The received digits buffer. This is a NULL terminated string. */ 66 char digits[MAX_BELL_MF_DIGITS + 1]; 67 }; 68 69 /*! 70 MFC/R2 tone detector descriptor. 71 */ 72 struct r2_mf_tx_state_s 73 { 74 /*! The tone generator. */ 75 tone_gen_state_t tone; 76 /*! True if generating forward tones, otherwise generating reverse tones. */ 77 bool fwd; 78 /*! The current digit being generated. */ 79 int digit; 80 }; 81 82 /*! 83 MFC/R2 tone detector descriptor. 84 */ 85 struct r2_mf_rx_state_s 86 { 87 /*! Optional callback funcion to deliver received digits. */ 88 tone_report_func_t callback; 89 /*! An opaque pointer passed to the callback function. */ 90 void *callback_data; 91 /*! True if we are detecting forward tones. False if we are detecting backward tones */ 92 bool fwd; 93 /*! Tone detector working states */ 94 goertzel_state_t out[6]; 95 /*! The current sample number within a processing block. */ 96 int current_sample; 97 /*! The currently detected digit. */ 98 int current_digit; 99 }; 100 101 #endif 102 /*- End of file ------------------------------------------------------------*/ 103