00001 /* 00002 * SpanDSP - a series of DSP components for telephony 00003 * 00004 * super_tone_tx.h - Flexible telephony supervisory tone generation. 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: super_tone_tx.h,v 1.13 2008/04/17 14:27:00 steveu Exp $ 00026 */ 00027 00028 #if !defined(_SPANDSP_SUPER_TONE_TX_H_) 00029 #define _SPANDSP_SUPER_TONE_TX_H_ 00030 00031 /*! \page super_tone_tx_page Supervisory tone generation 00032 00033 \section super_tone_tx_page_sec_1 What does it do? 00034 00035 The supervisory tone generator may be configured to generate most of the world's 00036 telephone supervisory tones - things like ringback, busy, number unobtainable, 00037 and so on. It uses tree structure tone descriptions, which can deal with quite 00038 complex cadence patterns. 00039 00040 \section super_tone_tx_page_sec_2 How does it work? 00041 00042 */ 00043 00044 typedef struct super_tone_tx_step_s super_tone_tx_step_t; 00045 00046 struct super_tone_tx_step_s 00047 { 00048 tone_gen_tone_descriptor_t tone[4]; 00049 int tone_on; 00050 int length; 00051 int cycles; 00052 super_tone_tx_step_t *next; 00053 super_tone_tx_step_t *nest; 00054 }; 00055 00056 typedef struct 00057 { 00058 tone_gen_tone_descriptor_t tone[4]; 00059 uint32_t phase[4]; 00060 int current_position; 00061 int level; 00062 super_tone_tx_step_t *levels[4]; 00063 int cycles[4]; 00064 } super_tone_tx_state_t; 00065 00066 #if defined(__cplusplus) 00067 extern "C" 00068 { 00069 #endif 00070 00071 super_tone_tx_step_t *super_tone_tx_make_step(super_tone_tx_step_t *s, 00072 float f1, 00073 float l1, 00074 float f2, 00075 float l2, 00076 int length, 00077 int cycles); 00078 00079 void super_tone_tx_free(super_tone_tx_step_t *s); 00080 00081 /*! Initialise a supervisory tone generator. 00082 \brief Initialise a supervisory tone generator. 00083 \param s The supervisory tone generator context. 00084 \param tree The supervisory tone tree to be generated. 00085 \return The supervisory tone generator context. */ 00086 super_tone_tx_state_t *super_tone_tx_init(super_tone_tx_state_t *s, super_tone_tx_step_t *tree); 00087 00088 /*! Generate a block of audio samples for a supervisory tone pattern. 00089 \brief Generate a block of audio samples for a supervisory tone pattern. 00090 \param s The supervisory tone context. 00091 \param amp The audio sample buffer. 00092 \param max_samples The maximum number of samples to be generated. 00093 \return The number of samples generated. */ 00094 int super_tone_tx(super_tone_tx_state_t *s, int16_t amp[], int max_samples); 00095 00096 #if defined(__cplusplus) 00097 } 00098 #endif 00099 00100 #endif 00101 /*- End of file ------------------------------------------------------------*/