silence_gen.h

00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * silence_gen.c - A silence generator, for inserting timed silences.
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2006 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: silence_gen.h,v 1.17 2009/04/12 03:29:58 steveu Exp $
00026  */
00027 
00028 #if !defined(_SPANDSP_SILENCE_GEN_H_)
00029 #define _SPANDSP_SILENCE_GEN_H_
00030 
00031 typedef struct silence_gen_state_s silence_gen_state_t;
00032 
00033 #if defined(__cplusplus)
00034 extern "C"
00035 {
00036 #endif
00037 
00038 /*! Generate a block of silent audio samples.
00039     \brief Generate a block of silent audio samples.
00040     \param s The silence generator context.
00041     \param amp The audio sample buffer.
00042     \param max_len The number of samples to be generated.
00043     \return The number of samples actually generated. This will be zero when
00044             there is nothing to send.
00045 */
00046 SPAN_DECLARE(int) silence_gen(silence_gen_state_t *s, int16_t *amp, int max_len);
00047 
00048 /*! Set a silence generator context to output continuous silence.
00049     \brief Set a silence generator context to output continuous silence.
00050     \param s The silence generator context.
00051 */
00052 SPAN_DECLARE(void) silence_gen_always(silence_gen_state_t *s);
00053 
00054 /*! Set a silence generator context to output a specified period of silence.
00055     \brief Set a silence generator context to output a specified period of silence.
00056     \param s The silence generator context.
00057     \param silent_samples The number of samples to be generated.
00058 */
00059 SPAN_DECLARE(void) silence_gen_set(silence_gen_state_t *s, int silent_samples);
00060 
00061 /*! Alter the period of a silence generator context by a specified amount.
00062     \brief Alter the period of a silence generator context by a specified amount.
00063     \param s The silence generator context.
00064     \param silent_samples The number of samples to change the setting by. A positive number
00065                           increases the duration. A negative number reduces it. The duration
00066                           is prevented from going negative.
00067 */
00068 SPAN_DECLARE(void) silence_gen_alter(silence_gen_state_t *s, int silent_samples);
00069 
00070 /*! Find how long a silence generator context has to run.
00071     \brief Find how long a silence generator context has to run.
00072     \param s The silence generator context.
00073     \return The number of samples remaining.
00074 */
00075 SPAN_DECLARE(int) silence_gen_remainder(silence_gen_state_t *s);
00076 
00077 /*! Find the total silence generated to date by a silence generator context.
00078     \brief Find the total silence generated to date.
00079     \param s The silence generator context.
00080     \return The number of samples generated.
00081 */
00082 SPAN_DECLARE(int) silence_gen_generated(silence_gen_state_t *s);
00083 
00084 /*! Change the status reporting function associated with a silence generator context.
00085     \brief Change the status reporting function associated with a silence generator context.
00086     \param s The silence generator context.
00087     \param handler The callback routine used to report status changes.
00088     \param user_data An opaque pointer. */
00089 SPAN_DECLARE(void) silence_gen_status_handler(silence_gen_state_t *s, modem_tx_status_func_t handler, void *user_data);
00090 
00091 /*! Initialise a timed silence generator context.
00092     \brief Initialise a timed silence generator context.
00093     \param s The silence generator context.
00094     \param silent_samples The initial number of samples to set the silence to.
00095     \return A pointer to the silence generator context.
00096 */
00097 SPAN_DECLARE(silence_gen_state_t *) silence_gen_init(silence_gen_state_t *s, int silent_samples);
00098 
00099 SPAN_DECLARE(int) silence_gen_release(silence_gen_state_t *s);
00100 
00101 SPAN_DECLARE(int) silence_gen_free(silence_gen_state_t *s);
00102 
00103 /* The following dummy routines, to absorb data, don't really have a proper home,
00104    so they have been put here. */
00105 
00106 /*! A dummy routine to use as a receive callback, when we aren't really
00107     trying to process what is received. It just absorbs and ignores the
00108     data.
00109     \brief Dummy receive callback.
00110     \param user_data The context.
00111     \param amp The signal.buffer
00112     \param len The length of the signal buffer
00113     \return 0.
00114 */
00115 SPAN_DECLARE_NONSTD(int) span_dummy_rx(void *user_data, const int16_t amp[], int len);
00116 
00117 /*! A dummy routine to use as a signal modifier callback, when we aren't
00118     really trying to process the signal. It just returns without affecting
00119     anything.
00120     \brief Dummy signal modifier callback.
00121     \param user_data The context.
00122     \param amp The signal.buffer
00123     \param len The length of the signal buffer
00124     \return 0.
00125 */
00126 SPAN_DECLARE(int) span_dummy_mod(void *user_data, int16_t amp[], int len);
00127 
00128 #if defined(__cplusplus)
00129 }
00130 #endif
00131 
00132 #endif
00133 /*- End of file ------------------------------------------------------------*/

Generated by  doxygen 1.6.2