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 General Public License version 2, as 00014 * 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 General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * 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.10 2007/11/18 08:57:14 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 super_tone_tx_step_t *super_tone_tx_make_step(super_tone_tx_step_t *s, 00067 float f1, 00068 float l1, 00069 float f2, 00070 float l2, 00071 int length, 00072 int cycles); 00073 00074 void super_tone_tx_free(super_tone_tx_step_t *s); 00075 00076 /*! Initialise a supervisory tone generator. 00077 \brief Initialise a supervisory tone generator. 00078 \param s The supervisory tone generator context. 00079 \param tree The supervisory tone tree to be generated. 00080 \return The supervisory tone generator context. */ 00081 super_tone_tx_state_t *super_tone_tx_init(super_tone_tx_state_t *s, super_tone_tx_step_t *tree); 00082 00083 /*! Generate a block of audio samples for a supervisory tone pattern. 00084 \brief Generate a block of audio samples for a supervisory tone pattern. 00085 \param tone The supervisory tone context. 00086 \param amp The audio sample buffer. 00087 \param max_samples The maximum number of samples to be generated. 00088 \return The number of samples generated. */ 00089 int super_tone_tx(super_tone_tx_state_t *s, int16_t amp[], int max_samples); 00090 00091 #endif 00092 /*- End of file ------------------------------------------------------------*/